org.openimaj.math.model.fit

Class LMedS<I,D,M extends EstimatableModel<I,D>>

• Type Parameters:
`I` - type of independent data
`D` - type of dependent data
`M` - concrete type of model learned
All Implemented Interfaces:
ModelFitting<I,D,M>, RobustModelFitting<I,D,M>

```@Reference(type=Article,
author="Peter J. Rousseeuw",
title="Least Median of Squares Regression",
year="1984",
journal="Journal of the American Statistical Association",
pages={"871","","880"},
url="http://www.jstor.org/stable/2288718",
month="December",
number="388",
volume="79")
public class LMedS<I,D,M extends EstimatableModel<I,D>>
extends Object
implements RobustModelFitting<I,D,M>```
Least Median of Squares robust model fitting
Author:
Jonathon Hare (jsh2@ecs.soton.ac.uk)
• Field Summary

Fields
Modifier and Type Field and Description
`protected M` `bestModel`
`protected boolean` `improveEstimate`
`protected List<IndependentPair<I,D>>` `inliers`
`protected M` `model`
`protected List<IndependentPair<I,D>>` `outliers`
`protected ResidualCalculator<I,D,M>` `residualEstimator`
`protected CollectionSampler<IndependentPair<I,D>>` `sampler`
• Constructor Summary

Constructors
Constructor and Description
```LMedS(M model, ResidualCalculator<I,D,M> residualEstimator, boolean impEst)```
Construct with the given model and residual calculator.
```LMedS(M model, ResidualCalculator<I,D,M> residualEstimator, boolean impEst, CollectionSampler<IndependentPair<I,D>> sampler)```
Construct with the given model and residual calculator.
```LMedS(M model, ResidualCalculator<I,D,M> residualEstimator, double outlierProportion, boolean impEst)```
Construct with the given model, residual calculator and estimated proportion of outliers.
```LMedS(M model, ResidualCalculator<I,D,M> residualEstimator, double outlierProportion, boolean impEst, CollectionSampler<IndependentPair<I,D>> sampler)```
Construct with the given model, residual calculator and estimated proportion of outliers.
```LMedS(M model, ResidualCalculator<I,D,M> residualEstimator, double outlierProportion, double inlierNoiseLevel, double degreesOfFreedom, boolean impEst)```
Construct with the given model, residual calculator and estimated proportion of outliers.
```LMedS(M model, ResidualCalculator<I,D,M> residualEstimator, double outlierProportion, double inlierNoiseLevel, double degreesOfFreedom, boolean impEst, CollectionSampler<IndependentPair<I,D>> sampler)```
Construct with the given model, residual calculator and estimated proportion of outliers.
• Method Summary

All Methods
Modifier and Type Method and Description
`boolean` `fitData(List<? extends IndependentPair<I,D>> data)`
Attempt to fit the given data to the model.
`List<? extends IndependentPair<I,D>>` `getInliers()`
`M` `getModel()`
`List<? extends IndependentPair<I,D>>` `getOutliers()`
`int` `numItemsToEstimate()`
• Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• Field Detail

• residualEstimator

`protected ResidualCalculator<I,D,M extends EstimatableModel<I,D>> residualEstimator`
• improveEstimate

`protected boolean improveEstimate`
• model

`protected M extends EstimatableModel<I,D> model`
• bestModel

`protected M extends EstimatableModel<I,D> bestModel`
• inliers

`protected List<IndependentPair<I,D>> inliers`
• outliers

`protected List<IndependentPair<I,D>> outliers`
• sampler

`protected CollectionSampler<IndependentPair<I,D>> sampler`
• Constructor Detail

• LMedS

```public LMedS(M model,
ResidualCalculator<I,D,M> residualEstimator,
boolean impEst)```
Construct with the given model and residual calculator. The proportion of outliers is assumed to be 0.4. The threshold for determining inliers and outliers is automatically computed. Uniform random sampling is used for creating the subsets.
Parameters:
`model` - the model to estimate
`residualEstimator` - the algorithm to compute residuals of the model
`impEst` - True if we want to perform a final fitting of the model with all inliers, false otherwise
• LMedS

```public LMedS(M model,
ResidualCalculator<I,D,M> residualEstimator,
double outlierProportion,
boolean impEst)```
Construct with the given model, residual calculator and estimated proportion of outliers. The threshold for determining inliers and outliers is automatically computed. Uniform random sampling is used for creating the subsets.
Parameters:
`model` - the model to estimate
`residualEstimator` - the algorithm to compute residuals of the model
`outlierProportion` - Expected proportion of outliers
`impEst` - True if we want to perform a final fitting of the model with all inliers, false otherwise
• LMedS

```public LMedS(M model,
ResidualCalculator<I,D,M> residualEstimator,
double outlierProportion,
double inlierNoiseLevel,
double degreesOfFreedom,
boolean impEst)```
Construct with the given model, residual calculator and estimated proportion of outliers. The given inlier noise level and number of degrees of freedom of the model are used to estimate the optimal threshold for determining inliers versus outliers. Uniform random sampling is used for creating the subsets.
Parameters:
`model` - the model to estimate
`residualEstimator` - the algorithm to compute residuals of the model
`outlierProportion` - Expected proportion of outliers
`inlierNoiseLevel` - The level of inlier noise (standard deviation of Gaussian noise inherent in the data).
`degreesOfFreedom` - Number of degrees of freedom of the model
`impEst` - True if we want to perform a final fitting of the model with all inliers, false otherwise
• LMedS

```public LMedS(M model,
ResidualCalculator<I,D,M> residualEstimator,
boolean impEst,
CollectionSampler<IndependentPair<I,D>> sampler)```
Construct with the given model and residual calculator. The proportion of outliers is assumed to be 0.4. The threshold for determining inliers and outliers is automatically computed.
Parameters:
`model` - the model to estimate
`residualEstimator` - the algorithm to compute residuals of the model
`impEst` - True if we want to perform a final fitting of the model with all inliers, false otherwise
`sampler` - the sampling algorithm for selecting random subsets
• LMedS

```public LMedS(M model,
ResidualCalculator<I,D,M> residualEstimator,
double outlierProportion,
boolean impEst,
CollectionSampler<IndependentPair<I,D>> sampler)```
Construct with the given model, residual calculator and estimated proportion of outliers. The threshold for determining inliers and outliers is automatically computed.
Parameters:
`model` - the model to estimate
`residualEstimator` - the algorithm to compute residuals of the model
`outlierProportion` - Expected proportion of outliers
`impEst` - True if we want to perform a final fitting of the model with all inliers, false otherwise
`sampler` - the sampling algorithm for selecting random subsets
• LMedS

```public LMedS(M model,
ResidualCalculator<I,D,M> residualEstimator,
double outlierProportion,
double inlierNoiseLevel,
double degreesOfFreedom,
boolean impEst,
CollectionSampler<IndependentPair<I,D>> sampler)```
Construct with the given model, residual calculator and estimated proportion of outliers. The given inlier noise level and number of degrees of freedom of the model are used to estimate the optimal threshold for determining inliers versus outliers.
Parameters:
`model` - the model to estimate
`residualEstimator` - the algorithm to compute residuals of the model
`outlierProportion` - Expected proportion of outliers
`inlierNoiseLevel` - The level of inlier noise (standard deviation of Gaussian noise inherent in the data).
`degreesOfFreedom` - Number of degrees of freedom of the model
`impEst` - True if we want to perform a final fitting of the model with all inliers, false otherwise
`sampler` - the sampling algorithm for selecting random subsets
• Method Detail

• fitData

`public boolean fitData(List<? extends IndependentPair<I,D>> data)`
Description copied from interface: `ModelFitting`
Attempt to fit the given data to the model.
Specified by:
`fitData` in interface `ModelFitting<I,D,M extends EstimatableModel<I,D>>`
Parameters:
`data` - Data to be fitted
Returns:
true on success, false otherwise
• getModel

`public M getModel()`
Specified by:
`getModel` in interface `ModelFitting<I,D,M extends EstimatableModel<I,D>>`
Returns:
the trained model object
• getInliers

`public List<? extends IndependentPair<I,D>> getInliers()`
Specified by:
`getInliers` in interface `RobustModelFitting<I,D,M extends EstimatableModel<I,D>>`
Returns:
list of the inliers in the original data
• getOutliers

`public List<? extends IndependentPair<I,D>> getOutliers()`
Specified by:
`getOutliers` in interface `RobustModelFitting<I,D,M extends EstimatableModel<I,D>>`
Returns:
list of the outliers in the original data
• numItemsToEstimate

`public int numItemsToEstimate()`
Specified by:
`numItemsToEstimate` in interface `ModelFitting<I,D,M extends EstimatableModel<I,D>>`
Returns:
The minimum number of observations required to estimate the model.