-
Notifications
You must be signed in to change notification settings - Fork 1.9k
swapping the order or arguments on the constructors of the ConversionExtensionsCatalog. Internalizing the constructors. #2118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ab70ee0
07fba20
88ff284
8a3cd83
e27b453
60ab6cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,16 +20,16 @@ public static class ConversionsExtensionsCatalog | |
/// Hashes the values in the input column. | ||
/// </summary> | ||
/// <param name="catalog">The transform's catalog.</param> | ||
/// <param name="inputColumn">Name of the input column.</param> | ||
/// <param name="outputColumn">Name of the column to be transformed. If this is null '<paramref name="inputColumn"/>' will be used.</param> | ||
/// <param name="name">Name of the column resulting from the transformation of <paramref name="source"/>.</param> | ||
/// <param name="source">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="name"/> will be used as source.</param> | ||
/// <param name="hashBits">Number of bits to hash into. Must be between 1 and 31, inclusive.</param> | ||
/// <param name="invertHash">During hashing we constuct mappings between original values and the produced hash values. | ||
/// Text representation of original values are stored in the slot names of the metadata for the new column.Hashing, as such, can map many initial values to one. | ||
/// <paramref name="invertHash"/> specifies the upper bound of the number of distinct input values mapping to a hash that should be retained. | ||
/// <value>0</value> does not retain any input values. <value>-1</value> retains all input values mapping to each hash.</param> | ||
public static HashingEstimator Hash(this TransformsCatalog.ConversionTransforms catalog, string inputColumn, string outputColumn = null, | ||
public static HashingEstimator Hash(this TransformsCatalog.ConversionTransforms catalog, string name, string source = null, | ||
int hashBits = HashDefaults.HashBits, int invertHash = HashDefaults.InvertHash) | ||
=> new HashingEstimator(CatalogUtils.GetEnvironment(catalog), inputColumn, outputColumn, hashBits, invertHash); | ||
=> new HashingEstimator(CatalogUtils.GetEnvironment(catalog), name, source ?? name, hashBits, invertHash); | ||
|
||
/// <summary> | ||
/// Hashes the values in the input column. | ||
|
@@ -43,12 +43,12 @@ public static HashingEstimator Hash(this TransformsCatalog.ConversionTransforms | |
/// Changes column type of the input column. | ||
/// </summary> | ||
/// <param name="catalog">The transform's catalog.</param> | ||
/// <param name="inputColumn">Name of the input column.</param> | ||
/// <param name="outputColumn">Name of the column to be transformed. If this is null '<paramref name="inputColumn"/>' will be used.</param> | ||
/// <param name="name">Name of the column resulting from the transformation of <paramref name="source"/>.</param> | ||
/// <param name="source">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="name"/> will be used as source.</param> | ||
/// <param name="outputKind">Number of bits to hash into. Must be between 1 and 31, inclusive.</param> | ||
public static TypeConvertingEstimator ConvertType(this TransformsCatalog.ConversionTransforms catalog, string inputColumn, string outputColumn = null, | ||
public static TypeConvertingEstimator ConvertType(this TransformsCatalog.ConversionTransforms catalog, string name, string source = null, | ||
DataKind outputKind = ConvertDefaults.DefaultOutputKind) | ||
=> new TypeConvertingEstimator(CatalogUtils.GetEnvironment(catalog), inputColumn, outputColumn, outputKind); | ||
=> new TypeConvertingEstimator(CatalogUtils.GetEnvironment(catalog), name, source, outputKind); | ||
|
||
/// <summary> | ||
/// Changes column type of the input column. | ||
|
@@ -62,9 +62,9 @@ public static TypeConvertingEstimator ConvertType(this TransformsCatalog.Convers | |
/// Convert the key types back to their original values. | ||
/// </summary> | ||
/// <param name="catalog">The categorical transform's catalog.</param> | ||
/// <param name="inputColumn">Name of the input column.</param> | ||
public static KeyToValueMappingEstimator MapKeyToValue(this TransformsCatalog.ConversionTransforms catalog, string inputColumn) | ||
=> new KeyToValueMappingEstimator(CatalogUtils.GetEnvironment(catalog), inputColumn); | ||
/// <param name="source">Name of the input column.</param> | ||
public static KeyToValueMappingEstimator MapKeyToValue(this TransformsCatalog.ConversionTransforms catalog, string source) | ||
=> new KeyToValueMappingEstimator(CatalogUtils.GetEnvironment(catalog), source); | ||
|
||
/// <summary> | ||
/// Convert the key types (name of the column specified in the first item of the tuple) back to their original values | ||
|
@@ -88,43 +88,28 @@ public static KeyToVectorMappingEstimator MapKeyToVector(this TransformsCatalog. | |
/// Convert the key types back to their original vectors. | ||
/// </summary> | ||
/// <param name="catalog">The categorical transform's catalog.</param> | ||
/// <param name="inputColumn">The name of the input column.</param> | ||
/// <param name="outputColumn">The name of the output column.</param> | ||
/// <param name="name">Name of the column resulting from the transformation of <paramref name="source"/>.</param> | ||
/// <param name="source">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="name"/> will be used as source.</param> | ||
/// <param name="bag">Whether bagging is used for the conversion. </param> | ||
public static KeyToVectorMappingEstimator MapKeyToVector(this TransformsCatalog.ConversionTransforms catalog, | ||
string inputColumn, string outputColumn = null, bool bag = KeyToVectorMappingEstimator.Defaults.Bag) | ||
=> new KeyToVectorMappingEstimator(CatalogUtils.GetEnvironment(catalog), inputColumn, outputColumn, bag); | ||
string name, string source = null, bool bag = KeyToVectorMappingEstimator.Defaults.Bag) | ||
=> new KeyToVectorMappingEstimator(CatalogUtils.GetEnvironment(catalog), name, source ?? name, bag); | ||
|
||
/// <summary> | ||
/// Converts value types into <see cref="KeyType"/>. | ||
/// </summary> | ||
/// <param name="catalog">The categorical transform's catalog.</param> | ||
/// <param name="inputColumn">Name of the column to be transformed.</param> | ||
/// <param name="outputColumn">Name of the output column. If this is null '<paramref name="inputColumn"/>' will be used.</param> | ||
/// <param name="name">Name of the column resulting from the transformation of <paramref name="source"/>.</param> | ||
/// <param name="source">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="name"/> will be used as source.</param> | ||
/// <param name="maxNumTerms">Maximum number of keys to keep per column when auto-training.</param> | ||
/// <param name="sort">How items should be ordered when vectorized. If <see cref="ValueToKeyMappingTransformer.SortOrder.Occurrence"/> choosen they will be in the order encountered. | ||
/// If <see cref="ValueToKeyMappingTransformer.SortOrder.Value"/>, items are sorted according to their default comparison, for example, text sorting will be case sensitive (for example, 'A' then 'Z' then 'a').</param> | ||
public static ValueToKeyMappingEstimator MapValueToKey(this TransformsCatalog.ConversionTransforms catalog, | ||
string inputColumn, | ||
string outputColumn = null, | ||
string name, | ||
string source = null, | ||
int maxNumTerms = ValueToKeyMappingEstimator.Defaults.MaxNumTerms, | ||
ValueToKeyMappingTransformer.SortOrder sort = ValueToKeyMappingEstimator.Defaults.Sort) | ||
=> new ValueToKeyMappingEstimator(CatalogUtils.GetEnvironment(catalog), inputColumn, outputColumn, maxNumTerms, sort); | ||
|
||
/// <summary> | ||
/// Converts value types into <see cref="KeyType"/> loading the keys to use from <paramref name="file"/>. | ||
/// </summary> | ||
/// <param name="catalog">The categorical transform's catalog.</param> | ||
/// <param name="columns">The data columns to map to keys.</param> | ||
/// <param name="file">The path of the file containing the terms.</param> | ||
/// <param name="termsColumn"></param> | ||
/// <param name="loaderFactory"></param> | ||
public static ValueToKeyMappingEstimator MapValueToKey(this TransformsCatalog.ConversionTransforms catalog, | ||
ValueToKeyMappingTransformer.ColumnInfo[] columns, | ||
string file = null, | ||
string termsColumn = null, | ||
IComponentFactory<IMultiStreamSource, IDataLoader> loaderFactory = null) | ||
=> new ValueToKeyMappingEstimator(CatalogUtils.GetEnvironment(catalog), columns, file, termsColumn, loaderFactory); | ||
=> new ValueToKeyMappingEstimator(CatalogUtils.GetEnvironment(catalog), name, source, maxNumTerms, sort); | ||
|
||
/// <summary> | ||
/// Maps specified keys to specified values | ||
|
@@ -141,7 +126,7 @@ public static ValueMappingEstimator<TInputType, TOutputType> ValueMap<TInputType | |
this TransformsCatalog.ConversionTransforms catalog, | ||
IEnumerable<TInputType> keys, | ||
IEnumerable<TOutputType> values, | ||
params (string source, string name)[] columns) | ||
params (string inputColumn, string outputColumn)[] columns) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Remember, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also I think for conistency sake we want the column mapping to be at the head, even when we have to forgo the convenience of the In reply to: 248079402 [](ancestors = 248079402) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will do this on the next PR, because the tuple is passed directly from the estimator -> transfomer-> OneToOnetransformer base class. I agree that it is confusing to review, because i did partial work with renaming the tuple items. In reply to: 248079667 [](ancestors = 248079667,248079402) |
||
=> new ValueMappingEstimator<TInputType, TOutputType>(CatalogUtils.GetEnvironment(catalog), keys, values, columns); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. Our samples have been written with Python variable naming conventions, not C# ones? I'll have to file an issue about this... #2155. #WontFix