-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
Codecov Report
@@ 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
|
private class InputData | ||
{ | ||
public float Feature1; | ||
public float[] Feature2; |
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 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"); |
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.
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) |
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.
"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(""); |
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.
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 |
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.
[](start = 14, length = 3)
two spaces #Resolved
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.
|
||
// 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. |
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.
** [](start = 64, length = 2)
remove the **.
learners take vectors of floats #Resolved
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.
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. |
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.
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. |
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.
API [](start = 31, length = 3)
The Concatenate Transformer? #Resolved
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.
Related to #1209.