jsat.datatransform
Class LinearTransform
- java.lang.Object
-
- jsat.datatransform.LinearTransform
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, DataTransform, InPlaceInvertibleTransform, InPlaceTransform, InvertibleTransform
public class LinearTransform extends java.lang.Object implements InPlaceInvertibleTransform
This class transforms all numerical values into a specified range by a linear scaling of all the data point values.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description LinearTransform()Creates a new Linear Transformation that will scale values to the [0, 1] range.LinearTransform(DataSet dataSet)Creates a new Linear Transformation for the input data set so that all values are in the [0, 1] range.LinearTransform(DataSet dataSet, double A, double B)Creates a new Linear Transformation for the input data set.LinearTransform(double A, double B)Creates a new Linear Transformation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description LinearTransformclone()voidfit(DataSet dataSet)Fits this transform to the given dataset.DataPointinverse(DataPoint dp)Applies the inverse or "reverse" transform to approximately undo the effect ofDataTransform.transform(jsat.classifiers.DataPoint)to recover an approximation of the original data point.voidmutableInverse(DataPoint dp)Mutates the given data point.voidmutableTransform(DataPoint dp)Mutates the given data point.booleanmutatesNominal()By default returnsfalse.voidsetRange(double A, double B)Sets the min and max value to scale the data to.DataPointtransform(DataPoint dp)Returns a new data point that is a transformation of the original data point.
-
-
-
Constructor Detail
-
LinearTransform
public LinearTransform()
Creates a new Linear Transformation that will scale values to the [0, 1] range.
-
LinearTransform
public LinearTransform(DataSet dataSet)
Creates a new Linear Transformation for the input data set so that all values are in the [0, 1] range.- Parameters:
dataSet- the data set to learn the transform from
-
LinearTransform
public LinearTransform(double A, double B)Creates a new Linear Transformation.- Parameters:
dataSet- the data set to learn the transform fromA- the maximum value for the transformed data setB- the minimum value for the transformed data set
-
LinearTransform
public LinearTransform(DataSet dataSet, double A, double B)
Creates a new Linear Transformation for the input data set.- Parameters:
dataSet- the data set to learn the transform fromA- the maximum value for the transformed data setB- the minimum value for the transformed data set
-
-
Method Detail
-
setRange
public void setRange(double A, double B)Sets the min and max value to scale the data to. If given in the wrong order, this method will swap them- Parameters:
A- the maximum value for the transformed data setB- the minimum value for the transformed data set
-
fit
public void fit(DataSet dataSet)
Description copied from interface:DataTransformFits this transform to the given dataset. Some transforms can only be learned from classification or regression datasets. If an incompatible dataset type is given, aFailedToFitExceptionexception may be thrown.- Specified by:
fitin interfaceDataTransform- Parameters:
dataSet- the dataset to fir this transform to
-
transform
public DataPoint transform(DataPoint dp)
Description copied from interface:DataTransformReturns a new data point that is a transformation of the original data point. This new data point is a different object, but may contain the same references as the original data point. It is not guaranteed that you can mutate the transformed point without having a side effect on the original point.- Specified by:
transformin interfaceDataTransform- Parameters:
dp- the data point to apply a transformation to- Returns:
- a transformed data point
-
clone
public LinearTransform clone()
- Specified by:
clonein interfaceDataTransform- Specified by:
clonein interfaceInPlaceInvertibleTransform- Specified by:
clonein interfaceInvertibleTransform- Overrides:
clonein classjava.lang.Object
-
mutableInverse
public void mutableInverse(DataPoint dp)
Description copied from interface:InPlaceInvertibleTransformMutates the given data point. This causes side effects, altering the data point to have the same value as the output ofInvertibleTransform.inverse(jsat.classifiers.DataPoint)- Specified by:
mutableInversein interfaceInPlaceInvertibleTransform- Parameters:
dp- the data point to alter with an inverse transformation
-
mutableTransform
public void mutableTransform(DataPoint dp)
Description copied from interface:InPlaceTransformMutates the given data point. This causes side effects, altering the data point to have the same value as the output ofDataTransform.transform(jsat.classifiers.DataPoint).- Specified by:
mutableTransformin interfaceInPlaceTransform- Parameters:
dp- the data point to alter
-
mutatesNominal
public boolean mutatesNominal()
Description copied from interface:InPlaceTransformBy default returnsfalse. Only returns true if this transform will mutableTransform the nominal feature values of a data point.- Specified by:
mutatesNominalin interfaceInPlaceTransform- Returns:
trueif nominal feature values are mutated,falseotherwise.
-
inverse
public DataPoint inverse(DataPoint dp)
Description copied from interface:InvertibleTransformApplies the inverse or "reverse" transform to approximately undo the effect ofDataTransform.transform(jsat.classifiers.DataPoint)to recover an approximation of the original data point.- Specified by:
inversein interfaceInvertibleTransform- Parameters:
dp- the transformed data point- Returns:
- the original data point, or a reasonable approximation
-
-
DataMelt 3.0 © DataMelt by jWork.ORG