Esempio n. 1
0
        /// <summary>
        /// Predict a target using a linear regression model trained with the <see cref="OrdinaryLeastSquaresRegressionTrainer"/>.
        /// </summary>
        /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param>
        /// <param name="options">Algorithm advanced options. See <see cref="OrdinaryLeastSquaresRegressionTrainer.Options"/>.</param>
        /// <example>
        /// <format type="text/markdown">
        /// <![CDATA[
        /// [!code-csharp[OrdinaryLeastSquares](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/OrdinaryLeastSquaresWithOptions.cs)]
        /// ]]>
        /// </format>
        /// </example>
        public static OrdinaryLeastSquaresRegressionTrainer OrdinaryLeastSquares(
            this RegressionCatalog.RegressionTrainers catalog,
            OrdinaryLeastSquaresRegressionTrainer.Options options)
        {
            Contracts.CheckValue(catalog, nameof(catalog));
            Contracts.CheckValue(options, nameof(options));

            var env = CatalogUtils.GetEnvironment(catalog);

            return(new OrdinaryLeastSquaresRegressionTrainer(env, options));
        }
Esempio n. 2
0
        /// <summary>
        /// Predict a target using a linear regression model trained with the <see cref="OrdinaryLeastSquaresRegressionTrainer"/>.
        /// </summary>
        /// <param name="catalog">The <see cref="RegressionCatalog"/>.</param>
        /// <param name="labelColumnName">The name of the label column.</param>
        /// <param name="featureColumnName">The name of the feature column.</param>
        /// <param name="exampleWeightColumnName">The name of the example weight column (optional).</param>
        /// <example>
        /// <format type="text/markdown">
        /// <![CDATA[
        /// [!code-csharp[OrdinaryLeastSquares](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/Regression/OrdinaryLeastSquares.cs)]
        /// ]]>
        /// </format>
        /// </example>
        public static OrdinaryLeastSquaresRegressionTrainer OrdinaryLeastSquares(this RegressionCatalog.RegressionTrainers catalog,
                                                                                 string labelColumnName         = DefaultColumnNames.Label,
                                                                                 string featureColumnName       = DefaultColumnNames.Features,
                                                                                 string exampleWeightColumnName = null)
        {
            Contracts.CheckValue(catalog, nameof(catalog));
            var env     = CatalogUtils.GetEnvironment(catalog);
            var options = new OrdinaryLeastSquaresRegressionTrainer.Options
            {
                LabelColumnName         = labelColumnName,
                FeatureColumnName       = featureColumnName,
                ExampleWeightColumnName = exampleWeightColumnName
            };

            return(new OrdinaryLeastSquaresRegressionTrainer(env, options));
        }