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
ConstructorsConstructorDescriptionRegressionMetrics(double fitTime, double scoreTime, int size, double rss, double mse, double rmse, double mad, double r2) Creates an instance of aRegressionMetricsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.doublefitTime()Returns the value of thefitTimerecord component.final inthashCode()Returns a hash code value for this object.doublemad()Returns the value of themadrecord component.doublemse()Returns the value of themserecord component.static RegressionMetricsof(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.doubler2()Returns the value of ther2record component.doublermse()Returns the value of thermserecord component.doublerss()Returns the value of therssrecord component.doubleReturns the value of thescoreTimerecord component.intsize()Returns the value of thesizerecord 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 aRegressionMetricsrecord class.- Parameters:
fitTime- the value for thefitTimerecord componentscoreTime- the value for thescoreTimerecord componentsize- the value for thesizerecord componentrss- the value for therssrecord componentmse- the value for themserecord componentrmse- the value for thermserecord componentmad- the value for themadrecord componentr2- the value for ther2record 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 thefitTimerecord component.- Returns:
- the value of the
fitTimerecord component
-
scoreTime
public double scoreTime()Returns the value of thescoreTimerecord component.- Returns:
- the value of the
scoreTimerecord component
-
size
public int size()Returns the value of thesizerecord component.- Returns:
- the value of the
sizerecord component
-
rss
public double rss()Returns the value of therssrecord component.- Returns:
- the value of the
rssrecord component
-
mse
public double mse()Returns the value of themserecord component.- Returns:
- the value of the
mserecord component
-
rmse
public double rmse()Returns the value of thermserecord component.- Returns:
- the value of the
rmserecord component
-
mad
public double mad()Returns the value of themadrecord component.- Returns:
- the value of the
madrecord component
-
r2
public double r2()Returns the value of ther2record component.- Returns:
- the value of the
r2record component
-