Skip to content
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

Merged
merged 5 commits into from Aug 20, 2018

Conversation

Ivanidzo4ka
Copy link
Contributor

examples for #584

var testDataPath = GetDataPath(SentimentDataPath);
var pipeline = new LearningPipeline();

pipeline.Add(MakeSentimentTextLoader(dataPath));
Copy link
Contributor

@Zruty0 Zruty0 Aug 13, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You want text loader with arguments? Or what?


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

void CrossValidation()
{
var dataPath = GetDataPath(SentimentDataPath);
var testDataPath = GetDataPath(SentimentDataPath);
Copy link
Contributor

@Zruty0 Zruty0 Aug 14, 2018

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));
Copy link
Contributor

@Zruty0 Zruty0 Aug 14, 2018

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()));
Copy link
Contributor

@Zruty0 Zruty0 Aug 14, 2018

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

Copy link
Contributor

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

@Zruty0 Zruty0 Aug 14, 2018

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);
Copy link
Contributor

@Zruty0 Zruty0 Aug 14, 2018

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);
Copy link
Contributor

@Zruty0 Zruty0 Aug 14, 2018

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

Copy link
Contributor

@Zruty0 Zruty0 Aug 14, 2018

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);
Copy link
Contributor

@Zruty0 Zruty0 Aug 14, 2018

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Move to evaluation


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

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." });
Copy link
Contributor

@Zruty0 Zruty0 Aug 14, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'Source column 'Label' is required but not found'


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

var metrics = evaluator.Evaluate(model, testLearningPipelineItem);

var singlePrediction = model.Predict(new SentimentData() { SentimentText = "Not big fan of this." });
Assert.True(singlePrediction.Sentiment);
Copy link
Contributor

@Zruty0 Zruty0 Aug 14, 2018

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

@Zruty0 Zruty0 Aug 14, 2018

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

Copy link
Contributor

@Zruty0 Zruty0 left a comment

Choose a reason for hiding this comment

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

:shipit:

@Ivanidzo4ka
Copy link
Contributor Author

@codemzs @eerhardt I'm trying to introduce examples for #584, and right now I have
Simple train and predict
Multi-threaded prediction
Train, save/load model, predict
Evaluation
Cross-validation
Meta-components
and I think it's impossible to implement in LearningPipeline following ones:
Train with validation set
Train with initial predictor
Auto-normalization and caching
File-based saving of data
Decomposable train and predict
Reconfigurable predictions
Introspective training
Exporting models
Visibility
Extensibility

Can you confirm or tell me I'm wrong for some cases.

@eerhardt
Copy link
Member

I can only answer a few. Maybe @codemzs can answer the others.

Train with validation set
Train with initial predictor

I don't see any Entry Point for these scenarios, let alone a LearningPipeline API...

Exporting models

Isn't this PredictionModel.WriteAsync?

@Ivanidzo4ka
Copy link
Contributor Author

Isn't this PredictionModel.WriteAsync?
No, it's more about export to other formats like ONNX, or something alike.
WriteAsync is part of TrainSaveModelAndPredict.


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


Parallel.ForEach(collection, (input) =>
{
lock (model)
Copy link
Member

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.

Copy link
Contributor

@TomFinley TomFinley left a comment

Choose a reason for hiding this comment

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

Thank you @Ivanidzo4ka

@Ivanidzo4ka Ivanidzo4ka merged commit 0cf0f45 into dotnet:master Aug 20, 2018
@dotnet dotnet locked as resolved and limited conversation to collaborators Mar 29, 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.

None yet

4 participants