-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add a sample for copy columns. #2351
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
Conversation
string labelColumnName = "Label"; | ||
var pipeline = mlContext.Transforms.CopyColumns(labelColumnName, "Age") as IEstimator<ITransformer>; | ||
|
||
// You also may want to copy a column to perform some hand featurization |
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.
I think you mean handy featurization right?
(totally my opinion) but I would change this intro though to be a bit more explicit as to what is happening:
A custom delegate can also be used with CopyColumns to generate new featurization. In this example, we are copying the Parity column to the CustomValue column, however CustomColumn will be set to 1 if the Parity goes above a threshold.
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.
var transformedData = pipeline.Fit(trainData).Transform(trainData); | ||
|
||
// Now let's take a look at what these CopyColumns operations did. | ||
// We can extract the newly created column as an IEnumerable of SampleInfertDataWithLabelAndValue, the class we define below. |
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.
SampleInfertDataWithLabelAndValue [](start = 76, length = 33)
SampleInfertDataTransformed
.Append(mlContext.Transforms.CustomMapping(mapping, null)); | ||
|
||
// Now we can transform the data and look at the output | ||
// Don't forget that this operation doesn't actually evaluate data until we materialize the data below. |
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.
materialize [](start = 88, length = 11)
read
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.
This PR adds a sample for copy columns, and moves the SchemaManipulation transform samples under a Transforms/ folder.
Fixes #2350