-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Sample for ReplaceMissingValues. #2773
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
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.ML.Data; | ||
using Microsoft.ML.SamplesUtils; | ||
|
||
namespace Microsoft.ML.Samples.Dynamic | ||
{ | ||
public static class ReplaceMissingValues | ||
{ | ||
public static void Example() | ||
{ | ||
// Creating the ML.Net IHostEnvironment object, needed for the pipeline. | ||
var mlContext = new MLContext(); | ||
|
||
// Download the training and validation files. | ||
string dataFile = DatasetUtils.DownloadMslrWeb10k(); | ||
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.
You can use the 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. My feeling is that we should use in-memory data when possible. In, #2726, we discuss some of in-memory data's advantages. #Resolved |
||
|
||
// Create the loader to load the data. | ||
var loader = mlContext.Data.CreateTextLoader( | ||
columns: new[] | ||
{ | ||
new TextLoader.Column("Label", DataKind.Single, 0), | ||
new TextLoader.Column("GroupId", DataKind.String, 1), | ||
new TextLoader.Column("Features", DataKind.Single, new[] { new TextLoader.Range(2, 138) }) | ||
} | ||
); | ||
|
||
// Load the raw dataset. | ||
var data = loader.Load(dataFile); | ||
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.
show a preview of before the transformation too. |
||
|
||
// Create the featurization pipeline. First, hash the GroupId column. | ||
var pipeline = mlContext.Transforms.Conversion.Hash("GroupId") | ||
// Replace missing values in Features column with the default replacement value for its type. | ||
.Append(mlContext.Transforms.ReplaceMissingValues("Features")); | ||
|
||
// Fit the pipeline and transform the dataset. | ||
var transformedData = pipeline.Fit(data).Transform(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.
Can you show some output after this line? e.g. the data preview or any metrics etc. 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. +1. Please also show how to inspect the prediction result example-by-example. |
||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
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.
Following is the standard comments for the
MLContext
in the samples.// Create a new ML context, for ML.NET operations. It can be used for exception tracking and logging, // as well as the source of randomness.
Please see other samples in the folder.
#Resolved