Package org.ojalgo.data
Class DataProcessors
- java.lang.Object
-
- org.ojalgo.data.DataProcessors
-
public class DataProcessors extends java.lang.Object
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 theTransformation2D
instances in this class assume columns represent variables, and rows samples.
-
-
Field Summary
Fields Modifier and Type Field Description static Transformation2D<java.lang.Double>
CENTER
Variables centered so that their average will be 0.0static Transformation2D<java.lang.Double>
CENTER_AND_SCALE
Variables will be centered around 0.0 AND scaled to be [-1.0,1.0].static Transformation2D<java.lang.Double>
SCALE
Variables scaled to be within [-1.0,1.0] (divide by largest magnitude regardless of sign).static Transformation2D<java.lang.Double>
STANDARD_SCORE
Will normalise each variable - 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 aTransformation2D
that will apply aUnaryFunction
to each column.
-
-
-
Field Detail
-
CENTER
public static final Transformation2D<java.lang.Double> CENTER
Variables centered so that their average will be 0.0
-
CENTER_AND_SCALE
public static final Transformation2D<java.lang.Double> CENTER_AND_SCALE
Variables will be centered around 0.0 AND scaled to be [-1.0,1.0]. The minimum value will be transformed to -1.0 and the maximum to +1.0.
-
SCALE
public static final Transformation2D<java.lang.Double> SCALE
Variables 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 - 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. EachAccess1D
instance 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. 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(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 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
-
-