Package smile.validation
Record Class RegressionMetrics
java.lang.Object
java.lang.Record
smile.validation.RegressionMetrics
- Record Components:
fitTime
- the time in milliseconds of fitting the model.scoreTime
- the time in milliseconds of scoring the validation data.size
- the validation data size.rss
- the residual sum of squares on validation data.mse
- the mean squared error on validation data.rmse
- the root mean squared error on validation data.mad
- the mean absolute deviation on validation data.r2
- the R-squared score on validation data.
- All Implemented Interfaces:
Serializable
public record RegressionMetrics(double fitTime, double scoreTime, int size, double rss, double mse, double rmse, double mad, double r2)
extends Record
implements Serializable
The regression validation metrics.
- See Also:
-
Constructor Summary
ConstructorDescriptionRegressionMetrics
(double fitTime, double scoreTime, int size, double rss, double mse, double rmse, double mad, double r2) Creates an instance of aRegressionMetrics
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.double
fitTime()
Returns the value of thefitTime
record component.final int
hashCode()
Returns a hash code value for this object.double
mad()
Returns the value of themad
record component.double
mse()
Returns the value of themse
record component.static RegressionMetrics
of
(double fitTime, double scoreTime, double[] truth, double[] prediction) Computes the regression metrics.static <M extends DataFrameRegression>
RegressionMetricsTrains and validates a model on a train/validation split.static <T,
M extends Regression<T>>
RegressionMetricsof
(double fitTime, M model, T[] testx, double[] testy) Validates a model on a test data.static <M extends DataFrameRegression>
RegressionMetricsTrains and validates a model on a train/validation split.static <T,
M extends Regression<T>>
RegressionMetricsof
(M model, T[] testx, double[] testy) Validates a model on a test data.double
r2()
Returns the value of ther2
record component.double
rmse()
Returns the value of thermse
record component.double
rss()
Returns the value of therss
record component.double
Returns the value of thescoreTime
record component.int
size()
Returns the value of thesize
record component.toString()
Returns a string representation of this record class.
-
Constructor Details
-
RegressionMetrics
public RegressionMetrics(double fitTime, double scoreTime, int size, double rss, double mse, double rmse, double mad, double r2) Creates an instance of aRegressionMetrics
record class.- Parameters:
fitTime
- the value for thefitTime
record componentscoreTime
- the value for thescoreTime
record componentsize
- the value for thesize
record componentrss
- the value for therss
record componentmse
- the value for themse
record componentrmse
- the value for thermse
record componentmad
- the value for themad
record componentr2
- the value for ther2
record component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
of
public static RegressionMetrics of(double fitTime, double scoreTime, double[] truth, double[] prediction) Computes the regression metrics.- Parameters:
fitTime
- the time in milliseconds of fitting the model.scoreTime
- the time in milliseconds of scoring the validation data.truth
- the ground truth.prediction
- the predictions.- Returns:
- the validation metrics.
-
of
Validates a model on a test data.- Type Parameters:
T
- the data type of samples.M
- the model type.- Parameters:
model
- the model.testx
- the validation data.testy
- the responsible variable of validation data.- Returns:
- the validation metrics.
-
of
public static <T,M extends Regression<T>> RegressionMetrics of(double fitTime, M model, T[] testx, double[] testy) Validates a model on a test data.- Type Parameters:
T
- the data type of samples.M
- the model type.- Parameters:
fitTime
- the time in milliseconds of fitting the model.model
- the model.testx
- the validation data.testy
- the responsible variable of validation data.- Returns:
- the validation metrics.
-
of
public static <M extends DataFrameRegression> RegressionMetrics of(M model, Formula formula, DataFrame test) Trains and validates a model on a train/validation split.- Type Parameters:
M
- the model type.- Parameters:
model
- the model.formula
- the model formula.test
- the validation data.- Returns:
- the validation metrics.
-
of
public static <M extends DataFrameRegression> RegressionMetrics of(double fitTime, M model, Formula formula, DataFrame test) Trains and validates a model on a train/validation split.- Type Parameters:
M
- the model type.- Parameters:
fitTime
- the time in milliseconds of fitting the model.model
- the model.formula
- the model formula.test
- the validation data.- Returns:
- the validation metrics.
-
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
fitTime
public double fitTime()Returns the value of thefitTime
record component.- Returns:
- the value of the
fitTime
record component
-
scoreTime
public double scoreTime()Returns the value of thescoreTime
record component.- Returns:
- the value of the
scoreTime
record component
-
size
public int size()Returns the value of thesize
record component.- Returns:
- the value of the
size
record component
-
rss
public double rss()Returns the value of therss
record component.- Returns:
- the value of the
rss
record component
-
mse
public double mse()Returns the value of themse
record component.- Returns:
- the value of the
mse
record component
-
rmse
public double rmse()Returns the value of thermse
record component.- Returns:
- the value of the
rmse
record component
-
mad
public double mad()Returns the value of themad
record component.- Returns:
- the value of the
mad
record component
-
r2
public double r2()Returns the value of ther2
record component.- Returns:
- the value of the
r2
record component
-