- java.lang.Object
-
- org.ojalgo.data.DataProcessors
-
public class DataProcessors extends java.lang.ObjectVarious data processors that could be useful when doing data science or similar. With ojAlgo it is highly advantageous to store data in columns (rather than rows). All theTransformation2Dinstances in this class assume columns represent variables, and rows samples.
-
-
Field Summary
Fields Modifier and Type Field Description static Transformation2D<java.lang.Double>CENTERVariables (columns) centered so that their average will be 0.0static Transformation2D<java.lang.Double>CENTER_AND_SCALEVariables (columns) will be transformed to be [-1.0,1.0].static Transformation2D<java.lang.Double>SCALEVariables (columns) scaled to be within [-1.0,1.0] (divide by largest magnitude regardless of sign).static Transformation2D<java.lang.Double>STANDARD_SCOREWill normalise each variable (columns) - replace each value with its standard score.
-
Constructor Summary
Constructors Constructor Description DataProcessors()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <M extends Mutate2D>
Mcorrelations(Factory2D<M> factory, Access1D<?>... data)Calculate the correlation matrix from a set of variables' samples.static <M extends Mutate2D>
Mcovariances(Factory2D<M> factory, double[]... data)static <D extends Access2D<?> & Access2D.Sliceable<?>,M extends Mutate2D>
Mcovariances(Factory2D<M> factory, D data)Variables in columns and matching samples in rows.static <M extends PhysicalStore<java.lang.Double>>
Mcovariances(Factory2D<M> factory, SingularValue<java.lang.Double> svd)static <M extends PhysicalStore<java.lang.Double>>
Mcovariances(Factory2D<M> factory, SingularValue<java.lang.Double> svd, double threshold)static <M extends PhysicalStore<java.lang.Double>>
Mcovariances(Factory2D<M> factory, SingularValue<java.lang.Double> svd, int complexity)static <M extends Mutate2D>
Mcovariances(Factory2D<M> factory, Access1D<?>... data)Calculate the covariance matrix from a set of variables' samples.static Transformation2D<java.lang.Double>newColumnsTransformer(java.util.function.Function<SampleSet,UnaryFunction<java.lang.Double>> definition)Creates aTransformation2Dthat will apply aUnaryFunctionto each column.static Transformation2D<java.lang.Double>newRowsTransformer(java.util.function.Function<SampleSet,UnaryFunction<java.lang.Double>> definition)
-
-
-
Field Detail
-
CENTER
public static final Transformation2D<java.lang.Double> CENTER
Variables (columns) centered so that their average will be 0.0
-
CENTER_AND_SCALE
public static final Transformation2D<java.lang.Double> CENTER_AND_SCALE
Variables (columns) will be transformed to be [-1.0,1.0]. The minimum value will be transformed to -1.0 and the maximum to +1.0. The midrange will be transformed to 0.0.
-
SCALE
public static final Transformation2D<java.lang.Double> SCALE
Variables (columns) scaled to be within [-1.0,1.0] (divide by largest magnitude regardless of sign). If all values are positive the range will within [0.0,1.0]. If all are negative the range will be within [-1.0,0.0]
-
STANDARD_SCORE
public static final Transformation2D<java.lang.Double> STANDARD_SCORE
Will normalise each variable (columns) - replace each value with its standard score.
-
-
Method Detail
-
correlations
public static <M extends Mutate2D> M correlations(Factory2D<M> factory, Access1D<?>... data)
Calculate the correlation matrix from a set of variables' samples. EachAccess1Dinstance represents one variable, and contains an ordered sequence of samples.
-
covariances
public static <M extends Mutate2D> M covariances(Factory2D<M> factory, Access1D<?>... data)
Calculate the covariance matrix from a set of variables' samples. EachAccess1Dinstance represents one variable, and contains an ordered sequence of samples.
-
covariances
public static <D extends Access2D<?> & Access2D.Sliceable<?>,M extends Mutate2D> M covariances(Factory2D<M> factory, D data)
Variables in columns and matching samples in rows.- See Also:
covariances(Factory2D, Access1D...)
-
covariances
public static <M extends Mutate2D> M covariances(Factory2D<M> factory, double[]... data)
- See Also:
covariances(Factory2D, Access1D...)
-
covariances
public static <M extends PhysicalStore<java.lang.Double>> M covariances(Factory2D<M> factory, SingularValue<java.lang.Double> svd)
-
covariances
public static <M extends PhysicalStore<java.lang.Double>> M covariances(Factory2D<M> factory, SingularValue<java.lang.Double> svd, double threshold)
-
covariances
public static <M extends PhysicalStore<java.lang.Double>> M covariances(Factory2D<M> factory, SingularValue<java.lang.Double> svd, int complexity)
- Parameters:
factory- A factory that will produce the returned covariance matrixsvd- A pre-decomposed SVD instance. The original matrix is assumed to have centered data in its columnscomplexity- The maximum number of singular values that should be considered
-
newColumnsTransformer
public static Transformation2D<java.lang.Double> newColumnsTransformer(java.util.function.Function<SampleSet,UnaryFunction<java.lang.Double>> definition)
Creates aTransformation2Dthat will apply aUnaryFunctionto each column. That unary function will be created by the providedFunctionusing aSampleSet(of that column) as input.The constants
CENTER,SCALE,CENTER_AND_SCALEandSTANDARD_SCOREare predefinedTransformation2Dinstances created by calling this method.- Parameters:
definition- AFunctionthat will create aUnaryFunctionfrom aSampleSetto be applied to each column- Returns:
- A
Transformation2Dthat will apply aUnaryFunctionto each column
-
newRowsTransformer
public static Transformation2D<java.lang.Double> newRowsTransformer(java.util.function.Function<SampleSet,UnaryFunction<java.lang.Double>> definition)
-
-