Exemple #1
0
        /// <summary>
        /// Train a KMeans++ clustering algorithm.
        /// </summary>
        /// <param name="catalog">The clustering catalog trainer object.</param>
        /// <param name="options">Algorithm advanced options.</param>
        public static KMeansPlusPlusTrainer KMeans(this ClusteringCatalog.ClusteringTrainers catalog, KMeansPlusPlusTrainer.Options options)
        {
            Contracts.CheckValue(catalog, nameof(catalog));
            Contracts.CheckValue(options, nameof(options));

            var env = CatalogUtils.GetEnvironment(catalog);

            return(new KMeansPlusPlusTrainer(env, options));
        }
Exemple #2
0
        /// <summary>
        /// Train a KMeans++ clustering algorithm.
        /// </summary>
        /// <param name="catalog">The clustering catalog trainer object.</param>
        /// <param name="featureColumn">The features, or independent variables.</param>
        /// <param name="weights">The optional example weights.</param>
        /// <param name="clustersCount">The number of clusters to use for KMeans.</param>
        /// <example>
        /// <format type="text/markdown">
        /// <![CDATA[
        ///  [!code-csharp[KMeans](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/KMeans.cs)]
        /// ]]></format>
        /// </example>
        public static KMeansPlusPlusTrainer KMeans(this ClusteringCatalog.ClusteringTrainers catalog,
                                                   string featureColumn = DefaultColumnNames.Features,
                                                   string weights       = null,
                                                   int clustersCount    = KMeansPlusPlusTrainer.Defaults.ClustersCount)
        {
            Contracts.CheckValue(catalog, nameof(catalog));
            var env = CatalogUtils.GetEnvironment(catalog);

            var options = new KMeansPlusPlusTrainer.Options
            {
                FeatureColumn = featureColumn,
                WeightColumn  = weights != null ? Optional <string> .Explicit(weights) : Optional <string> .Implicit(DefaultColumnNames.Weight),
                ClustersCount = clustersCount
            };

            return(new KMeansPlusPlusTrainer(env, options));
        }
Exemple #3
0
        /// <summary>
        /// Train a KMeans++ clustering algorithm.
        /// </summary>
        /// <param name="catalog">The clustering catalog trainer object.</param>
        /// <param name="featureColumnName">The name of the feature column.</param>
        /// <param name="exampleWeightColumnName">The name of the example weight column (optional).</param>
        /// <param name="clustersCount">The number of clusters to use for KMeans.</param>
        /// <example>
        /// <format type="text/markdown">
        /// <![CDATA[
        ///  [!code-csharp[KMeans](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/KMeans.cs)]
        /// ]]></format>
        /// </example>
        public static KMeansPlusPlusTrainer KMeans(this ClusteringCatalog.ClusteringTrainers catalog,
                                                   string featureColumnName       = DefaultColumnNames.Features,
                                                   string exampleWeightColumnName = null,
                                                   int clustersCount = KMeansPlusPlusTrainer.Defaults.ClustersCount)
        {
            Contracts.CheckValue(catalog, nameof(catalog));
            var env = CatalogUtils.GetEnvironment(catalog);

            var options = new KMeansPlusPlusTrainer.Options
            {
                FeatureColumnName       = featureColumnName,
                ExampleWeightColumnName = exampleWeightColumnName,
                ClustersCount           = clustersCount
            };

            return(new KMeansPlusPlusTrainer(env, options));
        }
 public static HierarchicalClusteringTrainer HierarchicalClustering(this ClusteringCatalog.ClusteringTrainers catalog, HierarchicalClustering.Options options)
 {
     return(new HierarchicalClusteringTrainer(options));
 }