/// <summary> /// Predicts a target using a linear multiclass classification model trained with the <see cref="MultiClassNaiveBayesTrainer"/>. /// The <see cref="MultiClassNaiveBayesTrainer"/> trains a multiclass Naive Bayes predictor that supports binary feature values. /// </summary> /// <param name="ctx">The <see cref="MulticlassClassificationContext.MulticlassClassificationTrainers"/>.</param> /// <param name="labelColumn">The name of the label column.</param> /// <param name="featureColumn">The name of the feature column.</param> public static MultiClassNaiveBayesTrainer NaiveBayes(this MulticlassClassificationContext.MulticlassClassificationTrainers ctx, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features) { Contracts.CheckValue(ctx, nameof(ctx)); return(new MultiClassNaiveBayesTrainer(CatalogUtils.GetEnvironment(ctx), labelColumn, featureColumn)); }
/// <summary> /// Predicts a target using a linear multiclass classification model trained with the <see cref="Pkpd"/>. /// </summary> /// <remarks> /// <para> /// In the Pairwise coupling (PKPD) strategy, a binary classification algorithm is used to train one classifier for each pair of classes. /// Prediction is then performed by running these binary classifiers, and computing a score for each class by counting how many of the binary /// classifiers predicted it. The prediction is the class with the highest score. /// </para> /// </remarks> /// <param name="ctx">The <see cref="MulticlassClassificationContext.MulticlassClassificationTrainers"/>.</param> /// <param name="binaryEstimator">An instance of a binary <see cref="ITrainerEstimator{TTransformer, TPredictor}"/> used as the base trainer.</param> /// <param name="calibrator">The calibrator. If a calibrator is not explicitely provided, it will default to <see cref="PlattCalibratorTrainer"/></param> /// <param name="labelColumn">The name of the label colum.</param> /// <param name="imputeMissingLabelsAsNegative">Whether to treat missing labels as having negative labels, instead of keeping them missing.</param> /// <param name="maxCalibrationExamples">Number of instances to train the calibrator.</param> public static Pkpd PairwiseCoupling(this MulticlassClassificationContext.MulticlassClassificationTrainers ctx, ITrainerEstimator <ISingleFeaturePredictionTransformer <IPredictorProducing <float> >, IPredictorProducing <float> > binaryEstimator, string labelColumn = DefaultColumnNames.Label, bool imputeMissingLabelsAsNegative = false, ICalibratorTrainer calibrator = null, int maxCalibrationExamples = 1000000000) { Contracts.CheckValue(ctx, nameof(ctx)); return(new Pkpd(CatalogUtils.GetEnvironment(ctx), binaryEstimator, labelColumn, imputeMissingLabelsAsNegative, calibrator, maxCalibrationExamples)); }
Sdca <TVal>(this MulticlassClassificationContext.MulticlassClassificationTrainers ctx, Key <uint, TVal> label, Vector <float> features, ISupportSdcaClassificationLoss loss = null, Scalar <float> weights = null, float?l2Const = null, float?l1Threshold = null, int?maxIterations = null, Action <MulticlassLogisticRegressionModelParameters> onFit = null) {
/// <summary> /// Predict a target using a linear multiclass classification model trained with the <see cref="Microsoft.ML.Learners.MulticlassLogisticRegression"/> trainer. /// </summary> /// <param name="ctx">The <see cref="MulticlassClassificationContext.MulticlassClassificationTrainers"/>.</param> /// <param name="options">Advanced arguments to the algorithm.</param> public static MulticlassLogisticRegression LogisticRegression(this MulticlassClassificationContext.MulticlassClassificationTrainers ctx, MulticlassLogisticRegression.Options options) { Contracts.CheckValue(ctx, nameof(ctx)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(ctx); return(new MulticlassLogisticRegression(env, options)); }
/// <summary> /// Predict a target using a linear multiclass classification model trained with the SDCA trainer. /// </summary> /// <param name="ctx">The multiclass classification context trainer object.</param> /// <param name="options">Advanced arguments to the algorithm.</param> public static SdcaMultiClassTrainer StochasticDualCoordinateAscent(this MulticlassClassificationContext.MulticlassClassificationTrainers ctx, SdcaMultiClassTrainer.Options options) { Contracts.CheckValue(ctx, nameof(ctx)); Contracts.CheckValue(options, nameof(options)); var env = CatalogUtils.GetEnvironment(ctx); return(new SdcaMultiClassTrainer(env, options)); }
Sdca <TVal>(this MulticlassClassificationContext.MulticlassClassificationTrainers ctx, Key <uint, TVal> label, Vector <float> features, ISupportSdcaClassificationLoss loss = null, Scalar <float> weights = null, float?l2Const = null, float?l1Threshold = null, int?maxIterations = null, Action <SdcaMultiClassTrainer.Arguments> advancedSettings = null, Action <MulticlassLogisticRegressionPredictor> onFit = null) {
LightGbm <TVal>(this MulticlassClassificationContext.MulticlassClassificationTrainers ctx, Key <uint, TVal> label, Vector <float> features, Scalar <float> weights = null, int?numLeaves = null, int?minDataPerLeaf = null, double?learningRate = null, int numBoostRound = LightGbmArguments.Defaults.NumBoostRound, Action <LightGbmArguments> advancedSettings = null, Action <OvaPredictor> onFit = null) {
MultiClassLogisticRegression <TVal>(this MulticlassClassificationContext.MulticlassClassificationTrainers ctx, Key <uint, TVal> label, Vector <float> features, Scalar <float> weights = null, float l1Weight = Arguments.Defaults.L1Weight, float l2Weight = Arguments.Defaults.L2Weight, float optimizationTolerance = Arguments.Defaults.OptTol, int memorySize = Arguments.Defaults.MemorySize, bool enoforceNoNegativity = Arguments.Defaults.EnforceNonNegativity, Action <MulticlassLogisticRegressionPredictor> onFit = null) {
/// <summary> /// Predict a target using a linear multiclass classification model trained with the SDCA trainer. /// </summary> /// <param name="ctx">The multiclass classification context trainer object.</param> /// <param name="labelColumn">The labelColumn, or dependent variable.</param> /// <param name="featureColumn">The features, or independent variables.</param> /// <param name="loss">The optional custom loss.</param> /// <param name="weights">The optional example weights.</param> /// <param name="l2Const">The L2 regularization hyperparameter.</param> /// <param name="l1Threshold">The L1 regularization hyperparameter. Higher values will tend to lead to more sparse model.</param> /// <param name="maxIterations">The maximum number of passes to perform over the data.</param> public static SdcaMultiClassTrainer StochasticDualCoordinateAscent(this MulticlassClassificationContext.MulticlassClassificationTrainers ctx, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weights = null, ISupportSdcaClassificationLoss loss = null, float?l2Const = null, float?l1Threshold = null, int?maxIterations = null) { Contracts.CheckValue(ctx, nameof(ctx)); var env = CatalogUtils.GetEnvironment(ctx); return(new SdcaMultiClassTrainer(env, labelColumn, featureColumn, weights, loss, l2Const, l1Threshold, maxIterations)); }
/// <summary> /// Predict a target using a decision tree binary classification model trained with the <see cref="LightGbmRankingTrainer"/>. /// </summary> /// <param name="ctx">The <see cref="RankingContext"/>.</param> /// <param name="labelColumn">The labelColumn column.</param> /// <param name="featureColumn">The features column.</param> /// <param name="weights">The weights column.</param> /// <param name="numLeaves">The number of leaves to use.</param> /// <param name="numBoostRound">Number of iterations.</param> /// <param name="minDataPerLeaf">The minimal number of documents allowed in a leaf of the tree, out of the subsampled data.</param> /// <param name="learningRate">The learning rate.</param> /// <param name="advancedSettings">A delegate to set more settings. /// The settings here will override the ones provided in the direct signature, /// if both are present and have different values. /// The columns names, however need to be provided directly, not through the <paramref name="advancedSettings"/>.</param> public static LightGbmMulticlassTrainer LightGbm(this MulticlassClassificationContext.MulticlassClassificationTrainers ctx, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weights = null, int?numLeaves = null, int?minDataPerLeaf = null, double?learningRate = null, int numBoostRound = LightGbmArguments.Defaults.NumBoostRound, Action <LightGbmArguments> advancedSettings = null) { Contracts.CheckValue(ctx, nameof(ctx)); var env = CatalogUtils.GetEnvironment(ctx); return(new LightGbmMulticlassTrainer(env, labelColumn, featureColumn, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound, advancedSettings)); }
/// <summary> /// Predict a target using a linear multiclass classification model trained with the <see cref="Microsoft.ML.Learners.MulticlassLogisticRegression"/> trainer. /// </summary> /// <param name="ctx">The <see cref="MulticlassClassificationContext.MulticlassClassificationTrainers"/>.</param> /// <param name="labelColumn">The labelColumn, or dependent variable.</param> /// <param name="featureColumn">The features, or independent variables.</param> /// <param name="weights">The optional example weights.</param> /// <param name="enforceNoNegativity">Enforce non-negative weights.</param> /// <param name="l1Weight">Weight of L1 regularization term.</param> /// <param name="l2Weight">Weight of L2 regularization term.</param> /// <param name="memorySize">Memory size for <see cref="Microsoft.ML.Learners.LogisticRegression"/>. Low=faster, less accurate.</param> /// <param name="optimizationTolerance">Threshold for optimizer convergence.</param> public static MulticlassLogisticRegression LogisticRegression(this MulticlassClassificationContext.MulticlassClassificationTrainers ctx, string labelColumn = DefaultColumnNames.Label, string featureColumn = DefaultColumnNames.Features, string weights = null, float l1Weight = LROptions.Defaults.L1Weight, float l2Weight = LROptions.Defaults.L2Weight, float optimizationTolerance = LROptions.Defaults.OptTol, int memorySize = LROptions.Defaults.MemorySize, bool enforceNoNegativity = LROptions.Defaults.EnforceNonNegativity) { Contracts.CheckValue(ctx, nameof(ctx)); var env = CatalogUtils.GetEnvironment(ctx); return(new MulticlassLogisticRegression(env, labelColumn, featureColumn, weights, l1Weight, l2Weight, optimizationTolerance, memorySize, enforceNoNegativity)); }
MultiClassNaiveBayesTrainer <TVal>(this MulticlassClassificationContext.MulticlassClassificationTrainers ctx, Key <uint, TVal> label, Vector <float> features, Action <MultiClassNaiveBayesModelParameters> onFit = null) {