internal LdSvmTrainer(IHostEnvironment env, Options options)
     : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue),
            TrainerUtils.MakeR4VecFeature(options.FeatureColumnName),
            TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName),
            TrainerUtils.MakeR4ScalarWeightColumn(options.ExampleWeightColumnName))
 {
     Host.CheckValue(options, nameof(options));
     CheckOptions(Host, options);
     _options = options;
 }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of <see cref="SymbolicStochasticGradientDescentClassificationTrainer"/>
        /// </summary>
        internal SymbolicStochasticGradientDescentClassificationTrainer(IHostEnvironment env, Options options)
            : base(Contracts.CheckRef(env, nameof(env)).Register(LoadNameValue), TrainerUtils.MakeR4VecFeature(options.FeatureColumnName),
                   TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName))
        {
            Host.CheckValue(options, nameof(options));
            options.Check(Host);

            _options = options;
            Info     = new TrainerInfo(supportIncrementalTrain: true);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of <see cref="LogisticRegression"/>
        /// </summary>
        /// <param name="env">The environment to use.</param>
        /// <param name="labelColumn">The name of the label column.</param>
        /// <param name="featureColumn">The name of the feature column.</param>
        /// <param name="weights">The name for the example weight column.</param>
        /// <param name="enforceNoNegativity">Enforce non-negative weights.</param>
        /// <param name="l1Weight">Weight of L1 regularizer term.</param>
        /// <param name="l2Weight">Weight of L2 regularizer term.</param>
        /// <param name="memorySize">Memory size for <see cref="LogisticRegression"/>. Low=faster, less accurate.</param>
        /// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
        internal LogisticRegression(IHostEnvironment env,
                                    string labelColumn          = DefaultColumnNames.Label,
                                    string featureColumn        = DefaultColumnNames.Features,
                                    string weights              = null,
                                    float l1Weight              = Options.Defaults.L1Weight,
                                    float l2Weight              = Options.Defaults.L2Weight,
                                    float optimizationTolerance = Options.Defaults.OptTol,
                                    int memorySize              = Options.Defaults.MemorySize,
                                    bool enforceNoNegativity    = Options.Defaults.EnforceNonNegativity)
            : base(env, featureColumn, TrainerUtils.MakeBoolScalarLabel(labelColumn), weights,
                   l1Weight, l2Weight, optimizationTolerance, memorySize, enforceNoNegativity)
        {
            Host.CheckNonEmpty(featureColumn, nameof(featureColumn));
            Host.CheckNonEmpty(labelColumn, nameof(labelColumn));

            _posWeight        = 0;
            ShowTrainingStats = LbfgsTrainerOptions.ShowTrainingStats;
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of <see cref="LogisticRegressionBinaryTrainer"/>
        /// </summary>
        /// <param name="env">The environment to use.</param>
        /// <param name="labelColumn">The name of the label column.</param>
        /// <param name="featureColumn">The name of the feature column.</param>
        /// <param name="exampleWeightColumnName">The name for the example weight column.</param>
        /// <param name="enforceNoNegativity">Enforce non-negative weights.</param>
        /// <param name="l1Regularization">Weight of L1 regularizer term.</param>
        /// <param name="l2Regularization">Weight of L2 regularizer term.</param>
        /// <param name="memorySize">Memory size for <see cref="LogisticRegressionBinaryTrainer"/>. Low=faster, less accurate.</param>
        /// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
        internal LogisticRegressionBinaryTrainer(IHostEnvironment env,
                                                 string labelColumn             = DefaultColumnNames.Label,
                                                 string featureColumn           = DefaultColumnNames.Features,
                                                 string exampleWeightColumnName = null,
                                                 float l1Regularization         = Options.Defaults.L1Regularization,
                                                 float l2Regularization         = Options.Defaults.L2Regularization,
                                                 float optimizationTolerance    = Options.Defaults.OptimizationTolerance,
                                                 int memorySize           = Options.Defaults.HistorySize,
                                                 bool enforceNoNegativity = Options.Defaults.EnforceNonNegativity)
            : base(env, featureColumn, TrainerUtils.MakeBoolScalarLabel(labelColumn), exampleWeightColumnName,
                   l1Regularization, l2Regularization, optimizationTolerance, memorySize, enforceNoNegativity)
        {
            Host.CheckNonEmpty(featureColumn, nameof(featureColumn));
            Host.CheckNonEmpty(labelColumn, nameof(labelColumn));

            _posWeight        = 0;
            ShowTrainingStats = LbfgsTrainerOptions.ShowTrainingStatistics;
        }
Beispiel #5
0
 internal AveragedPerceptronTrainer(IHostEnvironment env, Options options)
     : base(options, env, UserNameValue, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName))
 {
     _args        = options;
     LossFunction = _args.LossFunction ?? _args.LossFunctionFactory.CreateComponent(env);
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of <see cref="LogisticRegression"/>
 /// </summary>
 internal LogisticRegression(IHostEnvironment env, Options options)
     : base(env, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName))
 {
     _posWeight        = 0;
     ShowTrainingStats = LbfgsTrainerOptions.ShowTrainingStats;
 }