Package 'GGClassification'

Title: Gabriel Graph Based Large-Margin Classifiers
Description: Contains the implementation of a binary large margin classifier based on Gabriel Graph. References for this method can be found in L.C.B. Torres et al. (2015) <doi:10.1049/el.2015.1644>.
Authors: Thiago Coutinho [aut], Felipe Campos [aut, cre], Gustavo Silva [aut], Luiz Torres [aut], Antonio Braga [aut]
Maintainer: Felipe Campos <[email protected]>
License: GPL (>= 2)
Version: 0.1
Built: 2024-11-24 03:38:32 UTC
Source: https://github.com/cran/GGClassification

Help Index


Gabriel Graph Based Large-Margin Classifiers.

Description

Contains the implementation of a binary large margin classifier based on Gabriel Graph.

Details

Functions were implemented in C++.

The first function, "GabrielGraph", generates a graph based on Gabriel Graph's construction rule. Edges are linked according to the Euclidean distance among data samples.

The second function, called "model", is used to calculate classifier parameters. It returns a named list with four parameters, the midpoints between opposite-class edges, a vector w containing all weights, a vector representing classifier's bias terms and the corresponding labels of input data.

The third function, named "predict", takes the parameters returned by function "model" in order to classify input data.

Author(s)

Thiago Malta Coutinho <[email protected]>, Felipe Velloso Campos <[email protected]>, Gustavo Rodrigues Lacerda Silva <[email protected]>, Luiz Carlos Bambirra <[email protected]>, Antonio de Padua Braga <[email protected]>

References

Gabriel, K. R., & Sokal, R. R. (1969). A New Statistical Approach to Geographic Variation Analysis. Systematic Zoology, 18(3), 259. doi:10.2307/2412323

Matula, David & Sokal, Robert. (1980). Properties of Gabriel Graphs Relevant to Geographic Variation Research and the Clustering of Points in the Plane. Geographical Analysis. 12. 205 - 222. 10.1111/j.1538-4632.1980.tb00031.x.

L. C. B. Torres, C. L. Castro, F. Coelho, F. Sill Torres and A. P. Braga, "Distance-based large margin classifier suitable for integrated circuit implementation," in Electronics Letters, vol. 51, no. 24, pp. 1967-1969, 19 11 2015.

See Also

For more related papers, please check our research group website: http://litc.cpdee.ufmg.br/

Examples

# The example shows a binary classification problem, characterized by two Gaussian classes, 
    # in order to demonstrate how to use the classification functions.
     
    nc = 100
    
    xc1 <- matrix(0.3 * rnorm(nc) + 2.5, ncol = 2)
    xc2 <- matrix(0.3 * rnorm(nc) + 3.5, ncol = 2)
  
    xc1 <- cbind(xc1, rep(0, times = nc/2))
    xc2 <- cbind(xc2, rep(1, times = nc/2))
  
    X <- rbind(xc1, xc2)
    suffled_indexes <- sample(nc)
  
    train_size = nc * 0.7
  
    X_train <- X[suffled_indexes[1:train_size], cbind(1,2)]
    y_train <- X[suffled_indexes[1:train_size], 3]
  
    X_test <- X[suffled_indexes[(71:100)], cbind(1,2)]
    y_test <- X[suffled_indexes[(71:100)], 3]
  
    mdl <- model(X_train, y_train)
    prd <- predict(mdl, X_test)

Constructs a Gabriel Graph from data.

Description

Constructs a Gabriel Graph from data and returns its adjacency matrix.

Usage

GabrielGraph(X)

Arguments

X

Matrix containing data.

Value

The adjacency matrix of the Gabriel Graph, given the data matrix X.

References

Gabriel, K. R., & Sokal, R. R. (1969). A New Statistical Approach to Geographic Variation Analysis. Systematic Zoology, 18(3), 259. doi:10.2307/2412323

Matula, David & Sokal, Robert. (1980). Properties of Gabriel Graphs Relevant to Geographic Variation Research and the Clustering of Points in the Plane. Geographical Analysis. 12. 205 - 222. 10.1111/j.1538-4632.1980.tb00031.x.

Examples

X <- matrix(0.3 * rnorm(100) + 2.5, ncol = 2)
adjacency_matrix = GabrielGraph(X)

Calculates the parameters of a large-margin classifier based on the Gabriel Graph.

Description

The function computes the Gabriel Graph and applies a filter on the graph to remove noise in the margin region.

Then a new Graph is calculated considering the filtered data, and the parameters of a large-margin classifier are obtained and returned as a named list.

Usage

model(X, y, normalize=FALSE)

Arguments

X

Matrix containing data.

y

Vector of labels.

normalize

If data should be normalized or not.

Value

A named list containing the parameters of the classifier.

References

Gabriel, K. R., & Sokal, R. R. (1969). A New Statistical Approach to Geographic Variation Analysis. Systematic Zoology, 18(3), 259. doi:10.2307/2412323

L. C. B. Torres, C. L. Castro, F. Coelho, F. Sill Torres and A. P. Braga, "Distance-based large margin classifier suitable for integrated circuit implementation," in Electronics Letters, vol. 51, no. 24, pp. 1967-1969, 19 11 2015.

Examples

X <- matrix(0.3 * rnorm(100) + 2.5, ncol = 2)
y <- c(rep(0, times = 25), rep(1, times = 25))

mdl <- model(X, y)

Inference of classes based on received parameters of large-margin classifier.

Description

The function receives a model containing the parameters of the classifier and a data matrix to be classified Using the parameters and data, the classes/labels of input data is infered and returned as a vector.

Usage

predict(model, X)

Arguments

model

Large-margin classifier parameters computed using GGClassification::model function.

X

Data matrix to be classified.

Value

A vector of labels returned by the classifier.

Examples

X <- matrix(0.3 * rnorm(100) + 2.5, ncol = 2)
y <- c(rep(0, times = 25), rep(1, times = 25))

mdl <- model(X, y)

x_prd <- matrix(0.3 * rnorm(100) + 4.5, ncol=2)

y_hat <- predict(mdl, x_prd)