-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Introduce examples for pipeline api. #677
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
Introduce examples for pipeline api. #677
Conversation
var testDataPath = GetDataPath(SentimentDataPath); | ||
var pipeline = new LearningPipeline(); | ||
|
||
pipeline.Add(MakeSentimentTextLoader(dataPath)); |
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.
MakeSentimentTextLoader [](start = 25, length = 23)
can you not use TextLoader somehow? #Closed
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.
void CrossValidation() | ||
{ | ||
var dataPath = GetDataPath(SentimentDataPath); | ||
var testDataPath = GetDataPath(SentimentDataPath); |
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.
testDataPath [](start = 16, length = 12)
remove line #Closed
var testDataPath = GetDataPath(SentimentDataPath); | ||
var pipeline = new LearningPipeline(); | ||
|
||
pipeline.Add(MakeSentimentTextLoader(dataPath)); |
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.
Add [](start = 21, length = 3)
TextLoader ? #Closed
pipeline.Add(new ColumnConcatenator(outputColumn: "Features", | ||
"SepalLength", "SepalWidth", "PetalLength", "PetalWidth")); | ||
|
||
pipeline.Add(OneVersusAll.With(new StochasticDualCoordinateAscentBinaryClassifier())); |
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.
With [](start = 38, length = 4)
does it accept multiclass? #Closed
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.
write a comment that this is checked at Train time, so technically this example is not possible with LP
In reply to: 210040514 [](ancestors = 210040514)
/// <summary> | ||
/// This is a trivial implementation of a thread-safe prediction engine is just guarded by a lock. | ||
/// </summary> | ||
private sealed class LockBasedPredictionEngine |
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.
class [](start = 23, length = 5)
remove custom classes #Closed
var model = pipeline.Train<SentimentData, SentimentPrediction>(); | ||
var modelName = "multithreadModel.zip"; | ||
DeleteOutputPath(modelName); | ||
model.WriteAsync(modelName); |
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.
model [](start = 12, length = 5)
await? #Closed
|
||
pipeline.Add(new PredictedLabelColumnOriginalValueConverter() { PredictedLabelColumn = "PredictedLabel" }); | ||
var model = pipeline.Train<SentimentData, SentimentPrediction>(); | ||
var testData = MakeSentimentTextLoader(testDataPath); |
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.
MakeSentimentTextLoader [](start = 27, length = 23)
yuck #Closed
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.
rename testData to testHandle?.. testSomething. It's not data
In reply to: 210042025 [](ancestors = 210042025)
var loadedModel = await PredictionModel.ReadAsync<SentimentData, SentimentPrediction>(modelName); | ||
var testData = MakeSentimentTextLoader(testDataPath); | ||
var evaluator = new BinaryClassificationEvaluator(); | ||
var metrics = evaluator.Evaluate(loadedModel, testData); |
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.
remove from this test #Closed
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 testData = MakeSentimentTextLoader(testDataPath); | ||
var evaluator = new BinaryClassificationEvaluator(); | ||
var metrics = evaluator.Evaluate(loadedModel, testData); | ||
var singlePrediction = loadedModel.Predict(new SentimentData() { SentimentText = "Not big fan of this." }); |
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.
SentimentData [](start = 59, length = 13)
try to do the same with Iris, and check if loading a model with IrisDataNoLabel
works, but Predict
fails. If that's the case, then there's no decomposable piope. #ByDesign
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 metrics = evaluator.Evaluate(model, testLearningPipelineItem); | ||
|
||
var singlePrediction = model.Predict(new SentimentData() { SentimentText = "Not big fan of this." }); | ||
Assert.True(singlePrediction.Sentiment); |
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.
remove #Resolved
pipeline.Add(new ColumnConcatenator(outputColumn: "Features", | ||
"SepalLength", "SepalWidth", "PetalLength", "PetalWidth")); | ||
|
||
// this will throw exception during training time if you specify any other than binary classifier. |
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.
t [](start = 15, length = 1)
T #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.
@codemzs @eerhardt I'm trying to introduce examples for #584, and right now I have Can you confirm or tell me I'm wrong for some cases. |
I can only answer a few. Maybe @codemzs can answer the others.
I don't see any Entry Point for these scenarios, let alone a LearningPipeline API...
Isn't this |
In reply to: 413201180 [](ancestors = 413201180) |
|
||
Parallel.ForEach(collection, (input) => | ||
{ | ||
lock (model) |
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 a comment here why we would need to lock.
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.
Thank you @Ivanidzo4ka
examples for #584