internal ConversionTransforms(TransformsCatalog owner) { _env = owner.GetEnvironment(); }
/// <summary> /// Create a custom mapping of input columns to output columns. /// </summary> /// <typeparam name="TSrc">The class defining which columns to take from the incoming data.</typeparam> /// <typeparam name="TDst">The class defining which new columns are added to the data.</typeparam> /// <param name="catalog">The transform catalog</param> /// <param name="mapAction">The mapping action. This must be thread-safe and free from side effects.</param> /// <param name="contractName">The contract name, used by ML.NET for loading the model. If <c>null</c> is specified, such a trained model would not be save-able.</param> /// <param name="inputSchemaDefinition">Additional parameters for schema mapping between <typeparamref name="TSrc"/> and input data.</param> /// <param name="outputSchemaDefinition">Additional parameters for schema mapping between <typeparamref name="TDst"/> and output data.</param> /// <example> /// <format type="text/markdown"> /// <![CDATA[ /// [!code-csharp[FastTree](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/CustomMapping.cs)] /// ]]></format> /// </example> public static CustomMappingEstimator <TSrc, TDst> CustomMapping <TSrc, TDst>(this TransformsCatalog catalog, Action <TSrc, TDst> mapAction, string contractName, SchemaDefinition inputSchemaDefinition = null, SchemaDefinition outputSchemaDefinition = null) where TSrc : class, new() where TDst : class, new() => new CustomMappingEstimator <TSrc, TDst>(catalog.GetEnvironment(), mapAction, contractName, inputSchemaDefinition, outputSchemaDefinition);
internal CategoricalTransforms(TransformsCatalog owner) { _env = owner.GetEnvironment(); }
internal FeatureSelectionTransforms(TransformsCatalog owner) { _env = owner.GetEnvironment(); }
internal ProjectionTransforms(TransformsCatalog owner) { _env = owner.GetEnvironment(); }
internal TextTransforms(TransformsCatalog owner) { _env = owner.GetEnvironment(); }
/// <summary> /// Create a <see cref="StatefulCustomMappingEstimator{TSrc, TState, TDst}"/>, which applies a custom mapping of input columns to output columns, /// while allowing a per-cursor state. /// </summary> /// <typeparam name="TSrc">The class defining which columns to take from the incoming data.</typeparam> /// <typeparam name="TState">The type that describes per-cursor state.</typeparam> /// <typeparam name="TDst">The class defining which new columns are added to the data.</typeparam> /// <param name="catalog">The transform catalog.</param> /// <param name="mapAction">The mapping action. In addition to the input and output objects, the action is given a state object that it can look at and/or modify. /// If the resulting transformer needs to be save-able, the class defining <paramref name="mapAction"/> should implement /// <see cref="StatefulCustomMappingFactory{TSrc, TDst, TState}"/> and needs to be decorated with /// <see cref="CustomMappingFactoryAttributeAttribute"/> with the provided <paramref name="contractName"/>. /// The assembly containing the class should be registered in the environment where it is loaded back /// using <see cref="ComponentCatalog.RegisterAssembly(System.Reflection.Assembly, bool)"/>.</param> /// <param name="stateInitAction">The action to initialize the state object, that is called once before the cursor is initialized.</param> /// <param name="contractName">The contract name, used by ML.NET for loading the model. /// If <see langword="null"/> is specified, resulting transformer would not be save-able.</param> public static StatefulCustomMappingEstimator <TSrc, TDst, TState> StatefulCustomMapping <TSrc, TDst, TState>(this TransformsCatalog catalog, Action <TSrc, TDst, TState> mapAction, Action <TState> stateInitAction, string contractName) where TSrc : class, new() where TDst : class, new() where TState : class, new() => new StatefulCustomMappingEstimator <TSrc, TDst, TState>(catalog.GetEnvironment(), mapAction, contractName, stateInitAction);