Skip to content

Updated sample for Concatenate API. #3262

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 5 commits into from
Apr 10, 2019
Merged

Conversation

zeahmed
Copy link
Contributor

@zeahmed zeahmed commented Apr 9, 2019

Related to #1209.

@codecov
Copy link

codecov bot commented Apr 9, 2019

Codecov Report

Merging #3262 into master will decrease coverage by <.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #3262      +/-   ##
==========================================
- Coverage   72.62%   72.62%   -0.01%     
==========================================
  Files         807      807              
  Lines      145080   145080              
  Branches    16213    16213              
==========================================
- Hits       105367   105366       -1     
- Misses      35296    35297       +1     
  Partials     4417     4417
Flag Coverage Δ
#Debug 72.62% <ø> (-0.01%) ⬇️
#production 68.17% <ø> (-0.01%) ⬇️
#test 88.92% <ø> (ø) ⬆️
Impacted Files Coverage Δ
...soft.ML.Data/DataLoadSave/Text/TextLoaderCursor.cs 84.7% <0%> (-0.21%) ⬇️

@zeahmed zeahmed requested a review from Ivanidzo4ka April 9, 2019 20:43
private class InputData
{
public float Feature1;
public float[] Feature2;
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Apr 9, 2019

Choose a reason for hiding this comment

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

I would put VectorType(3) here.
Otherwise you concat scalar+VarVector+Scalar which would be VarVector and you can't use it for trainers.
Or maybe include that in sample, two concats, one on varvector, one on vector.... #Resolved


// A pipeline for concatenating the Age, Parity and Induced columns together into a vector that will be the Features column.
// A pipeline for concatenating the "Feature1", "Feature2" and "Feature3" columns together into a vector that will be the Features column.
// Concatenation is necessary because learners take **feature vectors** as inputs.
// e.g. var regressionTrainer = mlContext.Regression.Trainers.FastTree(labelColumn: "Label", featureColumn: "Features");
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Apr 9, 2019

Choose a reason for hiding this comment

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

is this comment necessary? #Resolved

//
// Please note that the "Feature3" column is converted from int32 to float using the ConvertType API.
// The Concatenate API requires all the columns to be of same type.
var pipeline = mlContext.Transforms.Conversion.ConvertType("Feature4", "Feature3", outputKind: DataKind.Single)
Copy link
Contributor

@rogancarr rogancarr Apr 9, 2019

Choose a reason for hiding this comment

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

"Feature4", "Feature3" [](start = 71, length = 22)

Maybe just keep calling it Feature3? #Resolved

foreach (var featureRow in featuresColumn)
{
foreach (var value in featureRow.Features.GetValues())
foreach (var value in featureRow.Features)
Console.Write($"{value} ");
Console.WriteLine("");
Copy link
Contributor

@rogancarr rogancarr Apr 9, 2019

Choose a reason for hiding this comment

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

How about Console.WriteLine(string.Join(" ", featureRow.Features));? #Resolved

// 39 6 2
// 34 4 2
// 35 3 1
// 0.1 1.1 2.1 3.1 1
Copy link
Contributor

@rogancarr rogancarr Apr 9, 2019

Choose a reason for hiding this comment

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

[](start = 14, length = 3)

two spaces #Resolved

Copy link
Contributor

@artidoro artidoro left a comment

Choose a reason for hiding this comment

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

:shipit:


// A pipeline for concatenating the Age, Parity and Induced columns together into a vector that will be the Features column.
// A pipeline for concatenating the "Feature1", "Feature2" and "Feature3" columns together into a vector that will be the Features column.
// Concatenation is necessary because learners take **feature vectors** as inputs.
Copy link
Member

@sfilipi sfilipi Apr 10, 2019

Choose a reason for hiding this comment

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

** [](start = 64, length = 2)

remove the **.

learners take vectors of floats #Resolved

Copy link
Member

Choose a reason for hiding this comment

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

also should trainers be used instead of learners?


In reply to: 273801982 [](ancestors = 273801982)

string outputColumnName = "Features";
var pipeline = mlContext.Transforms.Concatenate(outputColumnName, new[] { "Age", "Parity", "Induced" });
//
// Please note that the "Feature3" column is converted from int32 to float using the ConvertType API.
Copy link
Member

@singlis singlis Apr 10, 2019

Choose a reason for hiding this comment

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

ConvertType Transformer? #Resolved

var pipeline = mlContext.Transforms.Concatenate(outputColumnName, new[] { "Age", "Parity", "Induced" });
//
// Please note that the "Feature3" column is converted from int32 to float using the ConvertType API.
// The Concatenate API requires all columns to be of same type.
Copy link
Member

@singlis singlis Apr 10, 2019

Choose a reason for hiding this comment

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

API [](start = 31, length = 3)

The Concatenate Transformer? #Resolved

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:

@zeahmed zeahmed merged commit 6723bb6 into dotnet:master Apr 10, 2019
zeahmed added a commit to zeahmed/machinelearning that referenced this pull request Apr 11, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Mar 22, 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.

6 participants