-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Restore OVA ability to preserve key names on predicted label #3101
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 1 commit
33a578e
a73b04e
fbbcfcf
d46ae57
2bb3ecc
a61b914
b68c4e5
06cce1a
10541d6
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 |
---|---|---|
|
@@ -51,6 +51,36 @@ public void OVAUncalibrated() | |
Done(); | ||
} | ||
|
||
/// <summary> | ||
/// Test what OVA preserves key values for label. | ||
/// </summary> | ||
[Fact] | ||
public void OvaKeyNames() | ||
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. Can we add this to |
||
{ | ||
var textLoaderOptions = new TextLoader.Options() | ||
{ | ||
Columns = new[] | ||
{ new TextLoader.Column("Label", DataKind.Single, 0), | ||
new TextLoader.Column("Row", DataKind.Single, 1), | ||
new TextLoader.Column("Column", DataKind.Single, 2), | ||
}, | ||
HasHeader = true, | ||
Separators = new[] { '\t' } | ||
}; | ||
var textLoader = ML.Data.CreateTextLoader(textLoaderOptions); | ||
var data = textLoader.Load(TestDatasets.trivialMatrixFactorization.trainFilename); | ||
|
||
var ap = ML.BinaryClassification.Trainers.AveragedPerceptron(); | ||
var ova = ML.MulticlassClassification.Trainers.OneVersusAll(ap); | ||
|
||
var pipeline = ML.Transforms.Conversion.MapValueToKey("Label") | ||
.Append(ML.Transforms.Concatenate("Features", "Row", "Column")) | ||
.Append(ova) | ||
.Append(ML.Transforms.Conversion.MapKeyToValue("PredictedLabel")); | ||
|
||
var model = pipeline.Fit(data); | ||
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. We should do something with the model to ensure it was created correctly. #Resolved |
||
} | ||
|
||
/// <summary> | ||
/// Pairwise Coupling trainer | ||
/// </summary> | ||
|
@@ -83,12 +113,14 @@ public void MetacomponentsFeaturesRenamed() | |
var data = loader.Load(GetDataPath(TestDatasets.irisData.trainFilename)); | ||
|
||
var sdcaTrainer = ML.BinaryClassification.Trainers.SdcaNonCalibrated( | ||
new SdcaNonCalibratedBinaryTrainer.Options { | ||
new SdcaNonCalibratedBinaryTrainer.Options | ||
{ | ||
LabelColumnName = "Label", | ||
FeatureColumnName = "Vars", | ||
MaximumNumberOfIterations = 100, | ||
Shuffle = true, | ||
NumberOfThreads = 1, }); | ||
NumberOfThreads = 1, | ||
}); | ||
|
||
var pipeline = new ColumnConcatenatingEstimator(Env, "Vars", "SepalLength", "SepalWidth", "PetalLength", "PetalWidth") | ||
.Append(new ValueToKeyMappingEstimator(Env, "Label"), TransformerScope.TrainTest) | ||
|
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.
Just curious, I heard something fairly troubling from @eerhardt, could we test this sort of scenario still works for things other than OVA? #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.
Any tests which use
TestEstimatorCore
will compare metadata from expected and resulted output schema.I've change
AnnotationsForMulticlassScoreColumn
to always have TrainingLabelValue, and slotNames if key was text type, so technically we check that everywhere where we useTestEstimatorCore
In reply to: 269746627 [](ancestors = 269746627)