/// <summary>
 /// <see cref="ValueMappingEstimator"/>
 /// </summary>
 /// <typeparam name="TInputType">The key type.</typeparam>
 /// <typeparam name="TOutputType">The value type.</typeparam>
 /// <param name="catalog">The categorical transform's catalog</param>
 /// <param name="keys">The list of keys to use for the mapping. The mapping is 1-1 with <paramref name="values"/>. The length of this list  must be the same length as <paramref name="values"/> and
 /// cannot contain duplicate keys.</param>
 /// <param name="values">The list of values to pair with the keys for the mapping of TOutputType[]. The length of this list  must be equal to the same length as <paramref name="keys"/>.</param>
 /// <param name="columns">The columns to apply this transform on.</param>
 /// <returns>An instance of the <see cref="ValueMappingEstimator"/></returns>
 /// <example>
 /// <format type="text/markdown">
 /// <![CDATA[
 ///  [!code-csharp[ValueMappingEstimator](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ValueMapping.cs)]
 ///  [!code-csharp[ValueMappingEstimator](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ValueMappingStringToKeyType.cs)]
 ///  [!code-csharp[ValueMappingEstimator](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ValueMappingFloatToString.cs)]
 ///  [!code-csharp[ValueMappingEstimator](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ValueMappingStringToArray.cs)]
 /// ]]></format>
 /// </example>
 public static ValueMappingEstimator <TInputType, TOutputType> ValueMap <TInputType, TOutputType>(
     this TransformsCatalog.ConversionTransforms catalog,
     IEnumerable <TInputType> keys,
     IEnumerable <TOutputType[]> values,
     params SimpleColumnInfo[] columns)
 => new ValueMappingEstimator <TInputType, TOutputType>(CatalogUtils.GetEnvironment(catalog), keys, values,
                                                        SimpleColumnInfo.ConvertToValueTuples(columns));
Example #2
0
 /// <include file='doc.xml' path='doc/members/member[@name="MutualInformationFeatureSelection"]/*' />
 /// <param name="catalog">The transform's catalog.</param>
 /// <param name="labelColumn">Name of the column to use for labels.</param>
 /// <param name="slotsInOutput">The maximum number of slots to preserve in the output. The number of slots to preserve is taken across all input columns.</param>
 /// <param name="numBins">Max number of bins used to approximate mutual information between each input column and the label column. Power of 2 recommended.</param>
 /// <param name="columns">Specifies the names of the input columns for the transformation, and their respective output column names.</param>
 /// <example>
 /// <format type="text/markdown">
 /// <![CDATA[
 /// [!code-csharp[SelectFeaturesBasedOnMutualInformation](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/FeatureSelectionTransform.cs?range=1-4,10-121)]
 /// ]]>
 /// </format>
 /// </example>
 public static MutualInformationFeatureSelectingEstimator SelectFeaturesBasedOnMutualInformation(this TransformsCatalog.FeatureSelectionTransforms catalog,
                                                                                                 string labelColumn = MutualInfoSelectDefaults.LabelColumn,
                                                                                                 int slotsInOutput  = MutualInfoSelectDefaults.SlotsInOutput,
                                                                                                 int numBins        = MutualInfoSelectDefaults.NumBins,
                                                                                                 params SimpleColumnInfo[] columns)
 => new MutualInformationFeatureSelectingEstimator(CatalogUtils.GetEnvironment(catalog), labelColumn, slotsInOutput, numBins,
                                                   SimpleColumnInfo.ConvertToValueTuples(columns));
 /// <summary>
 /// Creates a new output column, of boolean type, with the same number of slots as the input column. The value in the output column
 /// is true if the value in the input column is missing.
 /// </summary>
 /// <param name="catalog">The transform extensions' catalog.</param>
 /// <param name="columns">The names of the input columns of the transformation and the corresponding names for the output columns.</param>
 public static MissingValueIndicatorEstimator IndicateMissingValues(this TransformsCatalog catalog,
                                                                    params SimpleColumnInfo[] columns)
 => new MissingValueIndicatorEstimator(CatalogUtils.GetEnvironment(catalog), SimpleColumnInfo.ConvertToValueTuples(columns));
 /// <summary>
 ///  Convert the key types (name of the column specified in the first item of the tuple) back to their original values
 ///  (named as specified in the second item of the tuple).
 /// </summary>
 /// <param name="catalog">The categorical transform's catalog</param>
 /// <param name="columns">The pairs of input and output columns.</param>
 /// <example>
 /// <format type="text/markdown">
 /// <![CDATA[
 ///  [!code-csharp[KeyToValueMappingEstimator](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ValueMappingStringToKeyType.cs)]
 /// ]]></format>
 /// </example>
 public static KeyToValueMappingEstimator MapKeyToValue(this TransformsCatalog.ConversionTransforms catalog, params SimpleColumnInfo[] columns)
 => new KeyToValueMappingEstimator(CatalogUtils.GetEnvironment(catalog), SimpleColumnInfo.ConvertToValueTuples(columns));
 /// <summary>
 /// <see cref="ValueMappingEstimator"/>
 /// </summary>
 /// <param name="catalog">The categorical transform's catalog</param>
 /// <param name="lookupMap">An instance of <see cref="IDataView"/> that contains the key and value columns.</param>
 /// <param name="keyColumn">Name of the key column in <paramref name="lookupMap"/>.</param>
 /// <param name="valueColumn">Name of the value column in <paramref name="lookupMap"/>.</param>
 /// <param name="columns">The columns to apply this transform on.</param>
 /// <returns>A instance of the ValueMappingEstimator</returns>
 /// <example>
 /// <format type="text/markdown">
 /// <![CDATA[
 ///  [!code-csharp[ValueMappingEstimator](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ValueMapping.cs)]
 ///  [!code-csharp[ValueMappingEstimator](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ValueMappingStringToKeyType.cs)]
 ///  [!code-csharp[ValueMappingEstimator](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ValueMappingFloatToString.cs)]
 ///  [!code-csharp[ValueMappingEstimator](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ValueMappingStringToArray.cs)]
 /// ]]></format>
 /// </example>
 public static ValueMappingEstimator ValueMap(
     this TransformsCatalog.ConversionTransforms catalog,
     IDataView lookupMap, string keyColumn, string valueColumn, params SimpleColumnInfo[] columns)
 => new ValueMappingEstimator(CatalogUtils.GetEnvironment(catalog), lookupMap, keyColumn, valueColumn,
                              SimpleColumnInfo.ConvertToValueTuples(columns));
 /// <summary>
 /// Normalize (rescale) several columns according to the specified <paramref name="mode"/>.
 /// </summary>
 /// <param name="catalog">The transform catalog</param>
 /// <param name="mode">The <see cref="NormalizingEstimator.NormalizerMode"/> used to map the old values to the new ones. </param>
 /// <param name="columns">The pairs of input and output columns.</param>
 /// <example>
 /// <format type="text/markdown">
 /// <![CDATA[
 /// [!code-csharp[Normalize](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Normalizer.cs)]
 /// ]]>
 /// </format>
 /// </example>
 public static NormalizingEstimator Normalize(this TransformsCatalog catalog,
                                              NormalizingEstimator.NormalizerMode mode,
                                              params SimpleColumnInfo[] columns)
 => new NormalizingEstimator(CatalogUtils.GetEnvironment(catalog), mode, SimpleColumnInfo.ConvertToValueTuples(columns));
Example #7
0
 /// <summary>
 /// Loads the images from the <see cref="ImageLoadingTransformer.ImageFolder" /> into memory.
 /// </summary>
 /// <remarks>
 /// The image get loaded in memory as a <see cref="System.Drawing.Bitmap" /> type.
 /// Loading is the first step of almost every pipeline that does image processing, and further analysis on images.
 /// The images to load need to be in the formats supported by <see cref = "System.Drawing.Bitmap" />.
 /// For end-to-end image processing pipelines, and scenarios in your applications, see the
 /// <a href="https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started"> examples in the machinelearning-samples github repository.</a>
 /// <seealso cref = "ImageEstimatorsCatalog" />
 /// </remarks>
 /// <param name="catalog">The transform's catalog.</param>
 /// <param name="imageFolder">The images folder.</param>
 /// <param name="columnPairs">The name of the columns containing the image paths(first item of the tuple), and the name of the resulting output column (second item of the tuple).</param>
 /// <example>
 /// <format type="text/markdown">
 /// <![CDATA[
 ///  [!code-csharp[LoadImages](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ImageAnalytics/LoadImages.cs)]
 /// ]]></format>
 /// </example>
 public static ImageLoadingEstimator LoadImages(this TransformsCatalog catalog, string imageFolder, params SimpleColumnInfo[] columnPairs)
 => new ImageLoadingEstimator(CatalogUtils.GetEnvironment(catalog), imageFolder, SimpleColumnInfo.ConvertToValueTuples(columnPairs));
Example #8
0
 /// <include file='doc.xml' path='doc/members/member[@name="ImageGrayscalingEstimator"]/*' />
 /// <param name="catalog">The transform's catalog.</param>
 /// <param name="columnPairs">The name of the columns containing the name of the resulting output column (first item of the tuple), and the paths of the images to work on (second item of the tuple).</param>
 /// <example>
 /// <format type="text/markdown">
 /// <![CDATA[
 ///  [!code-csharp[ConvertToGrayscale](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ImageAnalytics/ConvertToGrayscale.cs)]
 /// ]]></format>
 /// </example>
 public static ImageGrayscalingEstimator ConvertToGrayscale(this TransformsCatalog catalog, params SimpleColumnInfo[] columnPairs)
 => new ImageGrayscalingEstimator(CatalogUtils.GetEnvironment(catalog), SimpleColumnInfo.ConvertToValueTuples(columnPairs));