smile.classification
Class PlattScaling
- java.lang.Object
-
- smile.classification.PlattScaling
-
- All Implemented Interfaces:
- java.io.Serializable
public class PlattScaling extends java.lang.Object implements java.io.SerializablePlatt scaling or Platt calibration is a way of transforming the outputs of a classification model into a probability distribution over classes. The method was invented by John Platt in the context of support vector machines, but can be applied to other classification models. Platt scaling works by fitting a logistic regression model to a classifier's scores. Platt suggested using the Levenberg–Marquardt algorithm to optimize the parameters, but a Newton algorithm was later proposed that should be more numerically stable, which is implemented in this class.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description PlattScaling(double[] scores, int[] y)Trains the Platt scaling.PlattScaling(double[] scores, int[] y, int maxIters)Trains the Platt scaling.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static voidmulticlass(int k, double[][] r, double[] p)Estimates the multiclass probabilies.doublepredict(double y)Returns the posterior probability estimate P(y = 1 | x).
-
-
-
Constructor Detail
-
PlattScaling
public PlattScaling(double[] scores, int[] y)Trains the Platt scaling.- Parameters:
scores- The predicted scores.y- The training labels.
-
PlattScaling
public PlattScaling(double[] scores, int[] y, int maxIters)Trains the Platt scaling.- Parameters:
scores- The predicted scores.y- The training labels.maxIters- The maximal number of iterations.
-
-
Method Detail
-
predict
public double predict(double y)
Returns the posterior probability estimate P(y = 1 | x).- Parameters:
y- the binary classifier output score.- Returns:
- the estimated probability.
-
multiclass
public static void multiclass(int k, double[][] r, double[] p)Estimates the multiclass probabilies.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG