Title: | Tabular Maximum Likelihood Classifier |
---|---|
Description: | The maximum likelihood classifier (MLC) is one of the most common classifiers used for remote sensing imagery. This package uses 'RcppArmadillo' to provide a fast implementation of the MLC to train and predict over tabular data (data.frame). The algorithms were based on Mather (1985) <doi:10.1080/01431168508948456> method. |
Authors: | Caio Hamamura [aut, cre] |
Maintainer: | Caio Hamamura <[email protected]> |
License: | GPL-3 |
Version: | 0.0.3 |
Built: | 2024-11-22 06:30:49 UTC |
Source: | CRAN |
Maximum likelihood is a common classifier used for land use classification. It calculates the likelihood of an object to belong to each class based on an expected distribution and a metric of distance.
The most common implementation, like in this package, will assume normal distributed variables within classes, and calculate the distance, based on Mahalanobis distance.
Maintainer: Caio Hamamura [email protected] (ORCID)
Mather, P. M. (1985). Remote sensing letters: A computationally efficient maximum-likelihood classifier employing prior probabilities for remotely-sensed data. International Journal of Remote Sensing, 6(2), 369–376. doi:10.1080/01431168508948456
Imports
Useful links:
Report bugs at https://github.com/caiohamamura/tabularMLC/issues
Function to create the classifier class from the training set
MLC(x, ...) ## S3 method for class 'formula' MLC(formula, data = NULL, ...) ## Default S3 method: MLC(x, y = NULL, ...)
MLC(x, ...) ## S3 method for class 'formula' MLC(formula, data = NULL, ...) ## Default S3 method: MLC(x, y = NULL, ...)
x |
feature vector for the training set |
... |
for other signatures |
formula |
|
data |
the dataset |
y |
factor vector with the training set labels |
An object of class MLC.model
parameters used for the model
data(iris) x = iris[, -5] y = iris$Species # Default x y interface mlcModel1 = MLC(x, y) # Formula interface mlcModel2 = MLC(Species ~ Petal.Length + Petal.Width, iris) # Formula except one column mlcModel3 = MLC(Species ~ . - Sepal.Length, iris)
data(iris) x = iris[, -5] y = iris$Species # Default x y interface mlcModel1 = MLC(x, y) # Formula interface mlcModel2 = MLC(Species ~ Petal.Length + Petal.Width, iris) # Formula except one column mlcModel3 = MLC(Species ~ . - Sepal.Length, iris)
Maximum likelihood model class
k
the constant fraction to be used in model
mu
mean () list for each variable and class
inverseCovarianceMatrices
inverted covariance matrix () for each class
groups
the classification levels
vars
the variables used for trainning the model
MLC
which creates this class
predict
is inherited from the generic function for predictions from the results.
## S3 method for class 'MLC.model' predict(object, x = NULL, likelihood = FALSE, ...)
## S3 method for class 'MLC.model' predict(object, x = NULL, likelihood = FALSE, ...)
object |
|
x |
data.frame. The feature vector to predict |
likelihood |
logical. Whether to return or not the likelihood values, default FALSE. |
... |
inherited from generic function (not in use) |
a factor vector with the predicted value. If likelihood is TRUE, then it will also return the calculated likelihoods.
data(iris) n = length(iris$Species) # Split training by sample training = sample(1:n, size=n*0.7) validation = (1:n)[-training] # Train model with training dataset mlcModel = MLC(Species ~ ., iris[training,]) # Predict using validation dataset predict = predict(mlcModel, iris[validation,]) # Print confusion matrix confusionMatrix = table(predicted=predict, observed=iris$Species[validation]) print(confusionMatrix)
data(iris) n = length(iris$Species) # Split training by sample training = sample(1:n, size=n*0.7) validation = (1:n)[-training] # Train model with training dataset mlcModel = MLC(Species ~ ., iris[training,]) # Predict using validation dataset predict = predict(mlcModel, iris[validation,]) # Print confusion matrix confusionMatrix = table(predicted=predict, observed=iris$Species[validation]) print(confusionMatrix)