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 class
RegressionEvaluation.Metric
-
Field Summary
Fields Modifier and Type Field Description protected int
axis
static int
DEFAULT_PRECISION
-
Constructor Summary
Constructors Modifier Constructor Description RegressionEvaluation()
protected
RegressionEvaluation(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 double
averagecorrelationR2()
Deprecated.UseaveragePearsonCorrelation()
instead.double
averageMeanAbsoluteError()
Average MAE across all columnsdouble
averageMeanSquaredError()
Average MSE across all columnsdouble
averagePearsonCorrelation()
Average Pearson Correlation Coefficient across all columnsdouble
averagerelativeSquaredError()
Average RSE across all columnsdouble
averagerootMeanSquaredError()
Average RMSE across all columnsdouble
averageRSquared()
Average R2 across all columnsdouble
correlationR2(int column)
Deprecated.UsepearsonCorrelation(int)
instead.void
eval(INDArray labels, INDArray predictions)
void
eval(INDArray labelsArr, INDArray predictionsArr, INDArray maskArr)
void
eval(INDArray labels, INDArray networkPredictions, INDArray maskArray, List<? extends Serializable> recordMetaData)
static RegressionEvaluation
fromJson(String json)
int
getAxis()
Get the axis - seesetAxis(int)
for detailsdouble
getValue(IMetric metric)
Get the value of a given metric for this evaluation.double
meanAbsoluteError(int column)
double
meanSquaredError(int column)
void
merge(RegressionEvaluation other)
RegressionEvaluation
newInstance()
Get a new instance of this evaluation, with the same configuration but no data.int
numColumns()
double
pearsonCorrelation(int column)
Pearson Correlation Coefficient for samplesdouble
relativeSquaredError(int column)
void
reset()
double
rootMeanSquaredError(int column)
double
rSquared(int column)
Coefficient of Determination (R^2 Score)double
scoreForMetric(RegressionEvaluation.Metric metric)
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 = 3String
stats()
-
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:
eval
in interfaceIEvaluation<RegressionEvaluation>
- Overrides:
eval
in 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:
eval
in interfaceIEvaluation<RegressionEvaluation>
- Overrides:
eval
in 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:IEvaluation
Get 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:IEvaluation
Get a new instance of this evaluation, with the same configuration but no data.
-
-