Class RegressionMetric

java.lang.Object
org.tribuo.regression.evaluation.RegressionMetric
All Implemented Interfaces:
EvaluationMetric<Regressor,org.tribuo.regression.evaluation.RegressionMetric.Context>

public class RegressionMetric extends Object implements EvaluationMetric<Regressor,org.tribuo.regression.evaluation.RegressionMetric.Context>
A EvaluationMetric for Regressors which calculates the metric based on a the true values and the predicted values.
  • Constructor Details

    • RegressionMetric

      public RegressionMetric(MetricTarget<Regressor> tgt, String name, ToDoubleBiFunction<MetricTarget<Regressor>,org.tribuo.regression.evaluation.RegressionMetric.Context> impl)
      Construct a new RegressionMetric for the supplied metric target, using the supplied function. This does not use example weights.
      Parameters:
      tgt - The metric target.
      name - The name of the metric.
      impl - The implementing function.
    • RegressionMetric

      public RegressionMetric(MetricTarget<Regressor> tgt, String name, ToDoubleBiFunction<MetricTarget<Regressor>,org.tribuo.regression.evaluation.RegressionMetric.Context> impl, boolean useExampleWeights)
      Construct a new RegressionMetric for the supplied metric target, using the supplied function.
      Parameters:
      tgt - The metric target.
      name - The name of the metric.
      impl - The implementing function.
      useExampleWeights - If true then the example weights are used to scale the example importance.
  • Method Details

    • compute

      public double compute(org.tribuo.regression.evaluation.RegressionMetric.Context context)
      Description copied from interface: EvaluationMetric
      Compute the result of this metric from the input context.
      Specified by:
      compute in interface EvaluationMetric<Regressor,org.tribuo.regression.evaluation.RegressionMetric.Context>
      Parameters:
      context - The context to use.
      Returns:
      The value of the metric.
    • getTarget

      public MetricTarget<Regressor> getTarget()
      Description copied from interface: EvaluationMetric
      The target for this metric instance.
      Specified by:
      getTarget in interface EvaluationMetric<Regressor,org.tribuo.regression.evaluation.RegressionMetric.Context>
      Returns:
      The metric target.
    • getName

      public String getName()
      Description copied from interface: EvaluationMetric
      The name of this metric.
      Specified by:
      getName in interface EvaluationMetric<Regressor,org.tribuo.regression.evaluation.RegressionMetric.Context>
      Returns:
      The name.
    • createContext

      public org.tribuo.regression.evaluation.RegressionMetric.Context createContext(Model<Regressor> model, List<Prediction<Regressor>> predictions)
      Description copied from interface: EvaluationMetric
      Creates the context this metric uses to compute it's value.
      Specified by:
      createContext in interface EvaluationMetric<Regressor,org.tribuo.regression.evaluation.RegressionMetric.Context>
      Parameters:
      model - The model to use.
      predictions - The predictions to use.
      Returns:
      The metric context.