Package org.ojalgo.data
Class DataProcessors
java.lang.Object
org.ojalgo.data.DataProcessors
Various 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 the
Transformation2D
instances in
this class assume columns represent variables, and rows samples.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Transformation2D
<Double> Variables (columns) centered so that their average will be 0.0static final Transformation2D
<Double> Variables (columns) will be transformed to be [-1.0,1.0].static final Transformation2D
<Double> Variables (columns) scaled to be within [-1.0,1.0] (divide by largest magnitude regardless of sign).static final Transformation2D
<Double> Will normalise each variable (columns) - replace each value with its standard score. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <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<Double>>
Mcovariances
(Factory2D<M> factory, SingularValue<Double> svd) static <M extends PhysicalStore<Double>>
Mcovariances
(Factory2D<M> factory, SingularValue<Double> svd, double threshold) static <M extends PhysicalStore<Double>>
Mcovariances
(Factory2D<M> factory, SingularValue<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
<Double> newColumnsTransformer
(Function<SampleSet, UnaryFunction<Double>> definition) Creates aTransformation2D
that will apply aUnaryFunction
to each column.static Transformation2D
<Double> newRowsTransformer
(Function<SampleSet, UnaryFunction<Double>> definition)
-
Field Details
-
CENTER
Variables (columns) centered so that their average will be 0.0 -
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
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
Will normalise each variable (columns) - replace each value with its standard score.
-
-
Constructor Details
-
DataProcessors
public DataProcessors()
-
-
Method Details
-
correlations
Calculate the correlation matrix from a set of variables' samples. EachAccess1D
instance represents one variable, and contains an ordered sequence of samples. -
covariances
Calculate the covariance matrix from a set of variables' samples. EachAccess1D
instance 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
- See Also:
-
covariances
public static <M extends PhysicalStore<Double>> M covariances(Factory2D<M> factory, SingularValue<Double> svd) - See Also:
-
covariances
public static <M extends PhysicalStore<Double>> M covariances(Factory2D<M> factory, SingularValue<Double> svd, double threshold) - See Also:
-
covariances
public static <M extends PhysicalStore<Double>> M covariances(Factory2D<M> factory, SingularValue<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<Double> newColumnsTransformer(Function<SampleSet, UnaryFunction<Double>> definition) Creates aTransformation2D
that will apply aUnaryFunction
to each column. That unary function will be created by the providedFunction
using aSampleSet
(of that column) as input.The constants
CENTER
,SCALE
,CENTER_AND_SCALE
andSTANDARD_SCORE
are predefinedTransformation2D
instances created by calling this method.- Parameters:
definition
- AFunction
that will create aUnaryFunction
from aSampleSet
to be applied to each column- Returns:
- A
Transformation2D
that will apply aUnaryFunction
to each column
-
newRowsTransformer
public static Transformation2D<Double> newRowsTransformer(Function<SampleSet, UnaryFunction<Double>> definition)
-