Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f880b7b
Added a comment.
sierralee51 Jun 26, 2019
4f06b84
reformatted ModelOperations samples to width 85
sierralee51 Jun 27, 2019
0c16632
Merge branch 'master' of https://github.com/dotnet/machinelearning in…
sierralee51 Jun 27, 2019
3ce38a3
Fixed commented-on parts of MachineOperations & reformatted DataOpera…
sierralee51 Jun 27, 2019
10f40fd
Update docs/samples/Microsoft.ML.Samples/Dynamic/DataOperations/Cache.cs
sierralee51 Jun 28, 2019
00acf2a
Update Program.cs
sierralee51 Jun 28, 2019
acdf665
Update DataViewEnumerable.tt
sierralee51 Jun 28, 2019
842765f
Update DataViewEnumerable.cs
sierralee51 Jun 28, 2019
fe9c188
Update DataViewEnumerable.tt
sierralee51 Jun 28, 2019
2f91a6d
Update FilterRowsByColumn.tt
sierralee51 Jun 28, 2019
7a27578
Update ShuffleRows.tt
sierralee51 Jun 28, 2019
cd05ce0
Update TakeRows.tt
sierralee51 Jun 28, 2019
61de1fb
Update TakeRows.cs
sierralee51 Jun 28, 2019
5d2e8af
Update SkipRows.cs
sierralee51 Jun 28, 2019
063a651
Update SkipRows.tt
sierralee51 Jun 28, 2019
958633b
Update ShuffleRows.cs
sierralee51 Jun 28, 2019
01a5390
Update ShuffleRows.cs
sierralee51 Jun 28, 2019
0eb6065
Update ShuffleRows.cs
sierralee51 Jun 28, 2019
2db2bde
Update ShuffleRows.tt
sierralee51 Jun 28, 2019
8c1989f
Update SkipRows.tt
sierralee51 Jun 28, 2019
f39823a
Update SkipRows.cs
sierralee51 Jun 28, 2019
90ed060
Update FilterRowsByColumn.cs
sierralee51 Jun 28, 2019
2a5e8c3
Update FilterRowsByColumn.cs
sierralee51 Jun 28, 2019
f9d91e6
Update DataViewEnumerable.cs
sierralee51 Jun 28, 2019
5daecb8
Update FilterRowsByColumn.cs
sierralee51 Jun 28, 2019
c436498
Update FilterRowsByColumn.tt
sierralee51 Jun 28, 2019
49d7a09
Update FilterRowsByColumn.cs
sierralee51 Jun 28, 2019
d2315f9
Update FilterRowsByColumn.tt
sierralee51 Jun 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class SaveLoadModel
{
public static void Example()
{
// 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.
// 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.
var mlContext = new MLContext();

// Generate sample data.
Expand All @@ -25,7 +25,8 @@ public static void Example()
var outputColumnName = nameof(Transformation.Key);

// Transform.
ITransformer model = mlContext.Transforms.Conversion.MapValueToKey(outputColumnName, inputColumnName).Fit(dataView);
ITransformer model = mlContext.Transforms.Conversion.MapValueToKey(
outputColumnName, inputColumnName).Fit(dataView);

// Save model.
mlContext.Model.Save(model, dataView.Schema, "model.zip");
Expand All @@ -35,11 +36,15 @@ public static void Example()
model = mlContext.Model.Load(file, out DataViewSchema schema);

// Create a prediction engine from the model for feeding new data.
var engine = mlContext.Model.CreatePredictionEngine<Data, Transformation>(model);
var engine = mlContext.Model.CreatePredictionEngine<Data,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@eerhardt Is it ok to break generics like this or should all of it be in the same line as its corresponding class?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CC: @natke

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll fix it so that I split before the "<" in a later pull request. Thanks!

Transformation>(model);

var transformation = engine.Predict(new Data() { Value = "abc" });

// Print transformation to console.
Console.WriteLine("Value: {0}\t Key:{1}", transformation.Value, transformation.Key);
Console.WriteLine("Value: {0}\t Key:{1}", transformation.Value,
transformation.Key);

// Value: abc Key:1

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class SaveLoadModelFile
{
public static void Example()
{
// 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.
// 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.
var mlContext = new MLContext();

// Generate sample data.
Expand All @@ -25,7 +25,8 @@ public static void Example()
var outputColumnName = nameof(Transformation.Key);

// Transform.
ITransformer model = mlContext.Transforms.Conversion.MapValueToKey(outputColumnName, inputColumnName).Fit(dataView);
ITransformer model = mlContext.Transforms.Conversion.MapValueToKey(
outputColumnName, inputColumnName).Fit(dataView);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For cases like this, I would rather we break per method call, than to break between a method and its parameter list.

For example:

    // If you have chained method calls, line-break each method call
    Enumerable.Range(0, numRows)
        .Select(i => i.ToString())
        .ToArray();

That is much more readable than:

object o = foo.methodCall(
    methodCallArg1, methodCallArg2).OtherMethodCall(arg3)


// Save model.
mlContext.Model.Save(model, dataView.Schema, "model.zip");
Expand All @@ -34,11 +35,15 @@ public static void Example()
model = mlContext.Model.Load("model.zip", out DataViewSchema schema);

// Create a prediction engine from the model for feeding new data.
var engine = mlContext.Model.CreatePredictionEngine<Data, Transformation>(model);
var engine = mlContext.Model.CreatePredictionEngine<Data,
Transformation>(model);

var transformation = engine.Predict(new Data() { Value = "abc" });

// Print transformation to console.
Console.WriteLine("Value: {0}\t Key:{1}", transformation.Value, transformation.Key);
Console.WriteLine("Value: {0}\t Key:{1}", transformation.Value,
transformation.Key);

// Value: abc Key:1

}
Expand Down
1 change: 1 addition & 0 deletions docs/samples/Microsoft.ML.Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static class Program

internal static void RunAll()
{
// Samples counter.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the usefulness of this comment? If those words make a better name, it would be better to rename the variable with those words, than to add a comment like this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My bad, I meant to delete that. That was for an earlier test.

int samples = 0;
foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
{
Expand Down