Skip to content

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

Merged
merged 2 commits into from
Feb 1, 2019
Merged

Conversation

rogancarr
Copy link
Contributor

@rogancarr rogancarr commented Jan 31, 2019

This PR adds a sample for copy columns, and moves the SchemaManipulation transform samples under a Transforms/ folder.

Fixes #2350

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
Copy link
Member

@singlis singlis Jan 31, 2019

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.

Copy link
Member

@singlis singlis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

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.
Copy link
Member

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.
Copy link
Member

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

Copy link
Member

@sfilipi sfilipi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@rogancarr rogancarr merged commit 8904af0 into dotnet:master Feb 1, 2019
@rogancarr rogancarr deleted the 2350_copycols_docs branch February 1, 2019 01:07
@ghost ghost locked as resolved and limited conversation to collaborators Mar 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants