Package org.nd4j.evaluation.regression
Class RegressionEvaluation
- java.lang.Object
-
- org.nd4j.evaluation.BaseEvaluation<RegressionEvaluation>
-
- org.nd4j.evaluation.regression.RegressionEvaluation
-
- All Implemented Interfaces:
Serializable,IEvaluation<RegressionEvaluation>
public class RegressionEvaluation extends BaseEvaluation<RegressionEvaluation>
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRegressionEvaluation.Metric
-
Field Summary
Fields Modifier and Type Field Description protected intaxisstatic intDEFAULT_PRECISION
-
Constructor Summary
Constructors Modifier Constructor Description RegressionEvaluation()protectedRegressionEvaluation(int axis, List<String> columnNames, long precision)RegressionEvaluation(long nColumns)Create a regression evaluation object with the specified number of columns, and default precision for the stats() method.RegressionEvaluation(long nColumns, long precision)Create a regression evaluation object with the specified number of columns, and specified precision for the stats() method.RegressionEvaluation(String... columnNames)Create a regression evaluation object with default precision for the stats() methodRegressionEvaluation(List<String> columnNames)Create a regression evaluation object with default precision for the stats() methodRegressionEvaluation(List<String> columnNames, long precision)Create a regression evaluation object with specified precision for the stats() method
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description doubleaveragecorrelationR2()Deprecated.UseaveragePearsonCorrelation()instead.doubleaverageMeanAbsoluteError()Average MAE across all columnsdoubleaverageMeanSquaredError()Average MSE across all columnsdoubleaveragePearsonCorrelation()Average Pearson Correlation Coefficient across all columnsdoubleaveragerelativeSquaredError()Average RSE across all columnsdoubleaveragerootMeanSquaredError()Average RMSE across all columnsdoubleaverageRSquared()Average R2 across all columnsdoublecorrelationR2(int column)Deprecated.UsepearsonCorrelation(int)instead.voideval(INDArray labels, INDArray predictions)voideval(INDArray labelsArr, INDArray predictionsArr, INDArray maskArr)voideval(INDArray labels, INDArray networkPredictions, INDArray maskArray, List<? extends Serializable> recordMetaData)static RegressionEvaluationfromJson(String json)intgetAxis()Get the axis - seesetAxis(int)for detailsdoublegetValue(IMetric metric)Get the value of a given metric for this evaluation.doublemeanAbsoluteError(int column)doublemeanSquaredError(int column)voidmerge(RegressionEvaluation other)RegressionEvaluationnewInstance()Get a new instance of this evaluation, with the same configuration but no data.intnumColumns()doublepearsonCorrelation(int column)Pearson Correlation Coefficient for samplesdoublerelativeSquaredError(int column)voidreset()doublerootMeanSquaredError(int column)doublerSquared(int column)Coefficient of Determination (R^2 Score)doublescoreForMetric(RegressionEvaluation.Metric metric)voidsetAxis(int axis)Set the axis for evaluation - this is the dimension along which the probability (and label classes) are present.
For DL4J, this can be left as the default setting (axis = 1).
Axis should be set as follows:
For 2D (OutputLayer), shape [minibatch, numClasses] - axis = 1
For 3D, RNNs/CNN1D (DL4J RnnOutputLayer), NCW format, shape [minibatch, numClasses, sequenceLength] - axis = 1
For 3D, RNNs/CNN1D (DL4J RnnOutputLayer), NWC format, shape [minibatch, sequenceLength, numClasses] - axis = 2
For 4D, CNN2D (DL4J CnnLossLayer), NCHW format, shape [minibatch, channels, height, width] - axis = 1
For 4D, CNN2D, NHWC format, shape [minibatch, height, width, channels] - axis = 3Stringstats()-
Methods inherited from class org.nd4j.evaluation.BaseEvaluation
attempFromLegacyFromJson, eval, evalTimeSeries, evalTimeSeries, fromJson, fromYaml, reshapeAndExtractNotMasked, toJson, toString, toYaml
-
-
-
-
Field Detail
-
DEFAULT_PRECISION
public static final int DEFAULT_PRECISION
- See Also:
- Constant Field Values
-
axis
protected int axis
-
-
Constructor Detail
-
RegressionEvaluation
protected RegressionEvaluation(int axis, List<String> columnNames, long precision)
-
RegressionEvaluation
public RegressionEvaluation()
-
RegressionEvaluation
public RegressionEvaluation(long nColumns)
Create a regression evaluation object with the specified number of columns, and default precision for the stats() method.- Parameters:
nColumns- Number of columns
-
RegressionEvaluation
public RegressionEvaluation(long nColumns, long precision)Create a regression evaluation object with the specified number of columns, and specified precision for the stats() method.- Parameters:
nColumns- Number of columns
-
RegressionEvaluation
public RegressionEvaluation(String... columnNames)
Create a regression evaluation object with default precision for the stats() method- Parameters:
columnNames- Names of the columns
-
RegressionEvaluation
public RegressionEvaluation(List<String> columnNames)
Create a regression evaluation object with default precision for the stats() method- Parameters:
columnNames- Names of the columns
-
-
Method Detail
-
setAxis
public void setAxis(int axis)
Set the axis for evaluation - this is the dimension along which the probability (and label classes) are present.
For DL4J, this can be left as the default setting (axis = 1).
Axis should be set as follows:
For 2D (OutputLayer), shape [minibatch, numClasses] - axis = 1
For 3D, RNNs/CNN1D (DL4J RnnOutputLayer), NCW format, shape [minibatch, numClasses, sequenceLength] - axis = 1
For 3D, RNNs/CNN1D (DL4J RnnOutputLayer), NWC format, shape [minibatch, sequenceLength, numClasses] - axis = 2
For 4D, CNN2D (DL4J CnnLossLayer), NCHW format, shape [minibatch, channels, height, width] - axis = 1
For 4D, CNN2D, NHWC format, shape [minibatch, height, width, channels] - axis = 3- Parameters:
axis- Axis to use for evaluation
-
getAxis
public int getAxis()
Get the axis - seesetAxis(int)for details
-
reset
public void reset()
-
eval
public void eval(INDArray labels, INDArray predictions)
- Specified by:
evalin interfaceIEvaluation<RegressionEvaluation>- Overrides:
evalin classBaseEvaluation<RegressionEvaluation>
-
eval
public void eval(INDArray labels, INDArray networkPredictions, INDArray maskArray, List<? extends Serializable> recordMetaData)
-
eval
public void eval(INDArray labelsArr, INDArray predictionsArr, INDArray maskArr)
- Specified by:
evalin interfaceIEvaluation<RegressionEvaluation>- Overrides:
evalin classBaseEvaluation<RegressionEvaluation>
-
merge
public void merge(RegressionEvaluation other)
-
stats
public String stats()
- Returns:
-
numColumns
public int numColumns()
-
meanSquaredError
public double meanSquaredError(int column)
-
meanAbsoluteError
public double meanAbsoluteError(int column)
-
rootMeanSquaredError
public double rootMeanSquaredError(int column)
-
correlationR2
@Deprecated public double correlationR2(int column)
Deprecated.UsepearsonCorrelation(int)instead. For the R2 score userSquared(int).Legacy method for the correlation score.- Parameters:
column- Column to evaluate- Returns:
- Pearson Correlation for the given column
-
pearsonCorrelation
public double pearsonCorrelation(int column)
Pearson Correlation Coefficient for samples- Parameters:
column- Column to evaluate- Returns:
- Pearson Correlation Coefficient for column with index
column - See Also:
- Wikipedia
-
rSquared
public double rSquared(int column)
Coefficient of Determination (R^2 Score)- Parameters:
column- Column to evaluate- Returns:
- R^2 score for column with index
column - See Also:
- Wikipedia
-
relativeSquaredError
public double relativeSquaredError(int column)
-
averageMeanSquaredError
public double averageMeanSquaredError()
Average MSE across all columns- Returns:
-
averageMeanAbsoluteError
public double averageMeanAbsoluteError()
Average MAE across all columns- Returns:
-
averagerootMeanSquaredError
public double averagerootMeanSquaredError()
Average RMSE across all columns- Returns:
-
averagerelativeSquaredError
public double averagerelativeSquaredError()
Average RSE across all columns- Returns:
-
averagecorrelationR2
@Deprecated public double averagecorrelationR2()
Deprecated.UseaveragePearsonCorrelation()instead. For the R2 score useaverageRSquared().Legacy method for the correlation average across all columns.- Returns:
- Pearson Correlation averaged over all columns
-
averagePearsonCorrelation
public double averagePearsonCorrelation()
Average Pearson Correlation Coefficient across all columns- Returns:
- Pearson Correlation Coefficient across all columns
-
averageRSquared
public double averageRSquared()
Average R2 across all columns- Returns:
- R2 score accross all columns
-
getValue
public double getValue(IMetric metric)
Description copied from interface:IEvaluationGet the value of a given metric for this evaluation.
-
scoreForMetric
public double scoreForMetric(RegressionEvaluation.Metric metric)
-
fromJson
public static RegressionEvaluation fromJson(String json)
-
newInstance
public RegressionEvaluation newInstance()
Description copied from interface:IEvaluationGet a new instance of this evaluation, with the same configuration but no data.
-
-