Skip to content

Commit 109be9e

Browse files
prathyusha12345CESARDELATORRE
authored andcommitted
Migrate remaining inprogress samples to v1.0.0-preview (dotnet#360)
* Minor changes in ReadMe.md Changed the scenarios wording from real time to cross cutting * Casing changes in Readme File * Migrating BikeSharingDemand sample to ML.Net v1.0.0-preview. -added new solution file with v1.0.0 -Changed common Directory.Build.props file to v1.0.0-preview * Changed ReadMe file of BikeSharing Demand sample. Added build.Props file in remaining samples to fix build errors * Minor change: BikesharingDemand sample -Removed unnecessary nuget package * Migrated Credit Card Fraud Detection Sample. * Migrated sample Customer segmentation * Commiting model file of migrated sample Customer Segmentation * Migrated Heart Disease Console APP. * WIP: Migrating IRIS Classification sample * Migrated IRIS Clustering sample to v1.0.0-preview * Migrated Movie Recommender Sample to v1.0.0-preview. * Migrated Movie Recommender E2e Sample to v1.0.0-preview * Migrated Timeseries -PowerAnomalyDetection sample to ML.Net v1.0.0-preview * Migrated Product Recommendation sample to v1.0.0-preview * Power Anomaly Detection sample: some minor changes and updated ReadMe file to ML.Net 1.0.0-preview * Migrated Sentiment Anlysis Sample to ML.Net v1.0.0-preview. Commented Previewing of features column as it displays a number of 0's which is difficult to read. * Migrated ShampooSales Spike Detection sample to v1.0.0-preview * Migrated TaxiFare Prediction sample to ML.net v1.0.0-preview * Migrated TensorFlow scorer-Image Classification Sample * Migrated Sales Forecast sample to v1.0.0-preview * changes in common files. * Changed the solution file name * Removed the unnecessary solution files. * Migrated MNIST sample to ML.Net 1.0.0-preview. Changed the trainer name to sdcaMaximumEntropy. * ReadMe file of MNIST sample. * Updated version number in Readme file of MNIST sample. * Migrated MultiClass Classification_Iris sample to ML.Net 1.0.0-preview * Migrated Github labeler sample to Ml.Net 1.0.0-preview. * updated solution file * migrated Scalable WEBAPI sample to v1.0.0-preview * Minor changes in GITHUB labeler sample * Minor changes in Sentiment Anlaysis sample. Using the model path directly intead of filestream. * WIP: migrating TensorFlow Estimator sample. * For TesnorFlow Estiamtor sample, the model got updated. storing the updated model in Predict project. * Minor change * Migrated Spam Detection Sample to Ml.Net 1.0.0-preview * Updated sln file. * Refactored Bike Sharing sample code to directly pass the filepath instead of file stream * Refactored CreditCard Fraus Detection sample to use filepath instead of filestream * Minor changes in Customer Segmenation sample * no need to use filestream * Removed old build.props file. * Heart Disease Sample: Replaced file stream with filepath * Iris Clustering Sample: Replaced file stream with filepath * IRIS Classification sample: Replaced file stream with filepath * Movei Recommender E2E sample: Refactored code to replace filestream with fielpath * Minor changes * Sales Forecast sample: Refactored code to replace filestream with file path * Migrated shampoosales spike detection sample to Ml.Net 1.0.0-preview * Migrated ReadMe file for Shampoo sales E2E sample. * ReadMe file of TensorFlow Estimator is migrated to 1.0.0-preview * Refactored TaxiFare sample to replace filestream with filepath * Refactored Powet Anomaly detection sample to repalce filestream with filepath * Changed the training algorithm to use linear classification * Refactored SpamDetection Sample and ReadMe file. * Updated ReadMe of Github Labeler sample * minor change * Changed the name of sample in ReadME file * Minor changes * Minor changes * updated build file. Changed solution file. Added new solution to include only cosnole proj to make the build successful
1 parent 13178fe commit 109be9e

File tree

89 files changed

+443
-1004
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+443
-1004
lines changed

.vsts-dotnet-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ phases:
142142
- task: DotNetCoreCLI@2
143143
displayName: Build Shampoo Sales spike and change Detection E2E(Time Series)
144144
inputs:
145-
projects: '.\samples\csharp\csharp\end-to-end-apps\AnomalyDetection-ShampooSales-WinForms\AnomalyDetectionConsoleApp\AnomalyDetectionConsoleApp.csproj'
145+
projects: '.\samples\csharp\end-to-end-apps\SpikeDetection-ShampooSales-WinForms\ShampooSalesSpikeDetectionConsole.sln'

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ The official ML.NET samples are divided in multiple categories depending on the
120120
<td>
121121
<h4>Spike Detection-Shampoo Sales &nbsp;&nbsp;&nbsp;
122122
<a href="samples/csharp/getting-started/SpikeDetection_ShampooSales">C#</a> &nbsp; &nbsp; <img src="images/app-type-getting-started.png" alt="Getting started icon">
123-
<a href="samples/csharp/end-to-end-apps/AnomalyDetection-ShampooSales-WinForms">C#</a> &nbsp;&nbsp;&nbsp;<img src="images/app-type-e2e.png" alt="End-to-end app icon"></h4>
123+
<a href="samples/csharp/end-to-end-apps/SpikeDetection-ShampooSales-WinForms">C#</a> &nbsp;&nbsp;&nbsp;<img src="images/app-type-e2e.png" alt="End-to-end app icon"></h4>
124124
<h4>Spike Detection-PowerMeter Readings &nbsp;&nbsp;&nbsp;
125125
<a href="samples/csharp/getting-started/TimeSeries_PowerAnomalyDetection">C#</a> &nbsp; &nbsp; <img src="images/app-type-getting-started.png" alt="Getting started icon"></h4>
126126
</td>

samples/csharp/common/ConsoleHelper.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static void PrintRegressionFoldsAverageMetrics(string algorithmName, IRea
9090

9191
public static void PrintMulticlassClassificationFoldsAverageMetrics(
9292
string algorithmName,
93-
CrossValidationResult<MulticlassClassificationMetrics>[] crossValResults
93+
IReadOnlyList<CrossValidationResult<MulticlassClassificationMetrics>> crossValResults
9494
)
9595
{
9696
var metricsInMultipleFolds = crossValResults.Select(r => r.Metrics);

samples/csharp/end-to-end-apps/MulticlassClassification-GitHubLabeler/Directory.Build.props

-7
This file was deleted.

samples/csharp/end-to-end-apps/MulticlassClassification-GitHubLabeler/GitHubLabeler/GitHubLabelerConsoleApp/Common/ConsoleHelper.cs

-291
This file was deleted.

samples/csharp/end-to-end-apps/MulticlassClassification-GitHubLabeler/GitHubLabeler/GitHubLabelerConsoleApp/GitHubLabeler.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
<None Remove="datasets\**" />
1414
</ItemGroup>
1515

16+
<ItemGroup>
17+
<Compile Include="..\..\..\..\common\ConsoleHelper.cs" Link="Common\ConsoleHelper.cs" />
18+
</ItemGroup>
19+
1620
<ItemGroup>
1721
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
1822
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
@@ -27,6 +31,7 @@
2731
</ItemGroup>
2832

2933
<ItemGroup>
34+
<Folder Include="Common\" />
3035
<Folder Include="Data\" />
3136
</ItemGroup>
3237

samples/csharp/end-to-end-apps/MulticlassClassification-GitHubLabeler/GitHubLabeler/GitHubLabelerConsoleApp/Labeler.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,10 @@ public Labeler(string modelPath, string repoOwner = "", string repoName = "", st
3333
_mlContext = new MLContext();
3434

3535
//Load model from file
36-
37-
using (var stream = new FileStream(_modelPath, System.IO.FileMode.Open, FileAccess.Read, FileShare.Read))
38-
{
39-
_trainedModel = _mlContext.Model.Load(stream);
40-
}
36+
_trainedModel = _mlContext.Model.Load(_modelPath, out var modelInputSchema);
4137

4238
// Create prediction engine related to the loaded trained model
43-
_predEngine = _trainedModel.CreatePredictionEngine<GitHubIssue, GitHubIssuePrediction>(_mlContext);
39+
_predEngine = _mlContext.Model.CreatePredictionEngine<GitHubIssue, GitHubIssuePrediction>(_trainedModel);
4440

4541
//Configure Client to access a GitHub repo
4642
if (accessToken != string.Empty)

samples/csharp/end-to-end-apps/MulticlassClassification-GitHubLabeler/GitHubLabeler/GitHubLabelerConsoleApp/Program.cs

+9-13
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private static async Task Main(string[] args)
3434
SetupAppConfiguration();
3535

3636
//1. ChainedBuilderExtensions and Train the model
37-
BuildAndTrainModel(DataSetLocation, ModelPath, MyTrainerStrategy.SdcaMultiClassTrainer);
37+
BuildAndTrainModel(DataSetLocation, ModelPath, MyTrainerStrategy.OVAAveragedPerceptronTrainer);
3838

3939
//2. Try/test to predict a label for a single hard-coded Issue
4040
TestSingleLabelPrediction(ModelPath);
@@ -56,10 +56,10 @@ public static void BuildAndTrainModel(string DataSetLocation, string ModelPath,
5656
var trainingDataView = mlContext.Data.LoadFromTextFile<GitHubIssue>(DataSetLocation, hasHeader: true, separatorChar:'\t', allowSparse: false);
5757

5858
// STEP 2: Common data process configuration with pipeline data transformations
59-
var dataProcessPipeline = mlContext.Transforms.Conversion.MapValueToKey(outputColumnName: DefaultColumnNames.Label,inputColumnName:nameof(GitHubIssue.Area))
59+
var dataProcessPipeline = mlContext.Transforms.Conversion.MapValueToKey(outputColumnName: "Label",inputColumnName:nameof(GitHubIssue.Area))
6060
.Append(mlContext.Transforms.Text.FeaturizeText(outputColumnName: "TitleFeaturized",inputColumnName:nameof(GitHubIssue.Title)))
6161
.Append(mlContext.Transforms.Text.FeaturizeText(outputColumnName: "DescriptionFeaturized", inputColumnName: nameof(GitHubIssue.Description)))
62-
.Append(mlContext.Transforms.Concatenate(outputColumnName:DefaultColumnNames.Features, "TitleFeaturized", "DescriptionFeaturized"))
62+
.Append(mlContext.Transforms.Concatenate(outputColumnName:"Features", "TitleFeaturized", "DescriptionFeaturized"))
6363
.AppendCacheCheckpoint(mlContext);
6464
// Use in-memory cache for small/medium datasets to lower training time.
6565
// Do NOT use it (remove .AppendCacheCheckpoint()) when handling very large datasets.
@@ -72,15 +72,12 @@ public static void BuildAndTrainModel(string DataSetLocation, string ModelPath,
7272
switch(selectedStrategy)
7373
{
7474
case MyTrainerStrategy.SdcaMultiClassTrainer:
75-
trainer = mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent(DefaultColumnNames.Label,
76-
DefaultColumnNames.Features);
75+
trainer = mlContext.MulticlassClassification.Trainers.SdcaMaximumEntropy("Label", "Features");
7776
break;
7877
case MyTrainerStrategy.OVAAveragedPerceptronTrainer:
7978
{
8079
// Create a binary classification trainer.
81-
var averagedPerceptronBinaryTrainer = mlContext.BinaryClassification.Trainers.AveragedPerceptron(DefaultColumnNames.Label,
82-
DefaultColumnNames.Features,
83-
numIterations: 10);
80+
var averagedPerceptronBinaryTrainer = mlContext.BinaryClassification.Trainers.AveragedPerceptron("Label", "Features",numberOfIterations: 10);
8481
// Compose an OVA (One-Versus-All) trainer with the BinaryTrainer.
8582
// In this strategy, a binary classification algorithm is used to train one classifier for each class, "
8683
// which distinguishes that class from all other classes. Prediction is then performed by running these binary classifiers, "
@@ -95,7 +92,7 @@ public static void BuildAndTrainModel(string DataSetLocation, string ModelPath,
9592

9693
//Set the trainer/algorithm and map label to value (original readable state)
9794
var trainingPipeline = dataProcessPipeline.Append(trainer)
98-
.Append(mlContext.Transforms.Conversion.MapKeyToValue(DefaultColumnNames.PredictedLabel));
95+
.Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel"));
9996

10097
// STEP 4: Cross-Validate with single dataset (since we don't have two datasets, one for training and for evaluate)
10198
// in order to evaluate and get the model's accuracy metrics
@@ -105,7 +102,7 @@ public static void BuildAndTrainModel(string DataSetLocation, string ModelPath,
105102
//Measure cross-validation time
106103
var watchCrossValTime = System.Diagnostics.Stopwatch.StartNew();
107104

108-
CrossValidationResult<MultiClassClassifierMetrics>[] crossValidationResults = mlContext.MulticlassClassification.CrossValidate(data:trainingDataView, estimator:trainingPipeline, numFolds: 6, labelColumn:DefaultColumnNames.Label);
105+
var crossValidationResults= mlContext.MulticlassClassification.CrossValidate(data:trainingDataView, estimator:trainingPipeline, numberOfFolds: 6, labelColumnName:"Label");
109106

110107
//Stop measuring time
111108
watchCrossValTime.Stop();
@@ -131,16 +128,15 @@ public static void BuildAndTrainModel(string DataSetLocation, string ModelPath,
131128
// (OPTIONAL) Try/test a single prediction with the "just-trained model" (Before saving the model)
132129
GitHubIssue issue = new GitHubIssue() { ID = "Any-ID", Title = "WebSockets communication is slow in my machine", Description = "The WebSockets communication used under the covers by SignalR looks like is going slow in my development machine.." };
133130
// Create prediction engine related to the loaded trained model
134-
var predEngine = trainedModel.CreatePredictionEngine<GitHubIssue, GitHubIssuePrediction>(mlContext);
131+
var predEngine = mlContext.Model.CreatePredictionEngine<GitHubIssue, GitHubIssuePrediction>(trainedModel);
135132
//Score
136133
var prediction = predEngine.Predict(issue);
137134
Console.WriteLine($"=============== Single Prediction just-trained-model - Result: {prediction.Area} ===============");
138135
//
139136

140137
// STEP 6: Save/persist the trained model to a .ZIP file
141138
Console.WriteLine("=============== Saving the model to a file ===============");
142-
using (var fs = new FileStream(ModelPath, FileMode.Create, FileAccess.Write, FileShare.Write))
143-
mlContext.Model.Save(trainedModel, fs);
139+
mlContext.Model.Save(trainedModel, trainingDataView.Schema, ModelPath);
144140

145141
Common.ConsoleHelper.ConsoleWriteHeader("Training process finalized");
146142
}

samples/csharp/end-to-end-apps/MulticlassClassification-GitHubLabeler/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
| ML.NET version | API type | Status | App Type | Data sources | Scenario | ML Task | Algorithms |
44
|----------------|-------------------|-------------------------------|-------------|-----------|---------------------|---------------------------|-----------------------------|
5-
| v0.11 | Dynamic API | Up-to-date | Console app | .csv file and GitHub issues | Issues classification | Multi-class classification | SDCA multi-class classifier |
5+
| v1.0.0-preview | Dynamic API | Up-to-date | Console app | .csv file and GitHub issues | Issues classification | Multi-class classification | SDCA multi-class classifier, AveragedPerceptronTrainer |
66

77

88
This is a simple prototype application to demonstrate how to use [ML.NET](https://www.nuget.org/packages/Microsoft.ML/) APIs. The main focus is on creating, training, and using ML (Machine Learning) model that is implemented in Predictor.cs class.

samples/csharp/end-to-end-apps/Recommendation-MovieRecommender/MovieRecommender/movierecommender/Controllers/MoviesController.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@ public ActionResult Recommend(int id)
4444
// 1. Create the ML.NET environment and load the already trained model
4545
MLContext mlContext = new MLContext();
4646

47-
ITransformer trainedModel;
48-
using (FileStream stream = new FileStream(_movieService.GetModelPath(), FileMode.Open, FileAccess.Read, FileShare.Read))
49-
{
50-
trainedModel = mlContext.Model.Load(stream, out var modelInputSchema);
51-
}
52-
47+
ITransformer trainedModel = mlContext.Model.Load(_movieService.GetModelPath(), out var modelInputSchema);
48+
5349
//2. Create a prediction function
5450
var predictionEngine = mlContext.Model.CreatePredictionEngine<MovieRating, MovieRatingPrediction>(trainedModel);
5551

samples/csharp/end-to-end-apps/Recommendation-MovieRecommender/MovieRecommender/movierecommender/MovieRecommender.csproj

+6-10
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
55
<LangVersion>latest</LangVersion>
66
</PropertyGroup>
77

8-
<ItemGroup>
9-
<None Remove="Models\model.zip" />
10-
</ItemGroup>
11-
12-
<ItemGroup>
13-
<Content Include="Models\model.zip">
14-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
15-
</Content>
16-
</ItemGroup>
17-
188
<ItemGroup>
199
<PackageReference Include="CsvHelper" Version="12.1.1" />
2010
<PackageReference Include="Microsoft.AspNetCore.App" />
@@ -34,5 +24,11 @@
3424
</Content>
3525
</ItemGroup>
3626

27+
<ItemGroup>
28+
<None Update="Models\model.zip">
29+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
30+
</None>
31+
</ItemGroup>
32+
3733
</Project>
3834

samples/csharp/end-to-end-apps/Recommendation-MovieRecommender/MovieRecommender_Model/Program.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,7 @@ static void Main(string[] args)
8686

8787
//STEP 8: Save model to disk
8888
Console.WriteLine("=============== Writing model to the disk ===============", color);
89-
Console.WriteLine();
90-
91-
using (FileStream fs = new FileStream(ModelPath, FileMode.Create, FileAccess.Write, FileShare.Write))
92-
{
93-
mlContext.Model.Save(model, trainingDataView.Schema, fs);
94-
}
89+
Console.WriteLine();mlContext.Model.Save(model, trainingDataView.Schema, ModelPath);
9590

9691
Console.WriteLine("=============== Re-Loading model from the disk ===============", color);
9792
Console.WriteLine();

samples/csharp/end-to-end-apps/Regression-SalesForecast/src/eShopForecastModelsTrainer/CountryModelHelper.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ private static void CreateCountryModel(MLContext mlContext, string dataPath, str
5555

5656
// Create and Train the model
5757
var model = trainingPipeline.Fit(trainingDataView);
58-
59-
using (var file = File.OpenWrite(outputModelPath))
60-
mlContext.Model.Save(model, trainingDataView.Schema, file);
58+
//Save model
59+
mlContext.Model.Save(model, trainingDataView.Schema, outputModelPath);
6160
}
6261

6362
/// <summary>

samples/csharp/end-to-end-apps/Regression-SalesForecast/src/eShopForecastModelsTrainer/ProductModelHelper.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ private static void CreateProductModelUsingPipeline(MLContext mlContext, string
5656
var model = trainingPipeline.Fit(trainingDataView);
5757

5858
// Save the model for later comsumption from end-user apps
59-
using (var file = File.OpenWrite(outputModelPath))
60-
mlContext.Model.Save(model, trainingDataView.Schema, file);
59+
mlContext.Model.Save(model, trainingDataView.Schema, outputModelPath);
6160
}
6261

6362
/// <summary>

samples/csharp/end-to-end-apps/ScalableMLModelOnWebAPI/Directory.Build.props

-7
This file was deleted.

samples/csharp/end-to-end-apps/ScalableMLModelOnWebAPI/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
| ML.NET version | Status | App Type | Data type | Scenario | ML Task | Algorithms |
77
|----------------|-------------------------------|-------------|-----------|---------------------|---------------------------|-----------------------------|
8-
| v0.11 | Up-to-date | ASP.NET Core 2.2 WebAPI | Single data sample | Sentiment Analysis | Binary classification | Linear Classification |
8+
| v1.0.0-preview | Up-to-date | ASP.NET Core 2.2 WebAPI | Single data sample | Sentiment Analysis | Binary classification | Linear Classification |
99

1010

1111
**This posts explains how to optimize your code when running an ML.NET model on an ASP.NET Core WebAPI service.** The code would be very similar when running it on an ASP.NET Core MVC or Razor web app, too.

samples/csharp/end-to-end-apps/ScalableMLModelOnWebAPI/src/Scalable.Model/Engine/MLModelEngine.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using Microsoft.ML;
22
using Microsoft.Extensions.ObjectPool;
33
using System.IO;
4-
using Microsoft.Data.DataView;
54

65
namespace Scalable.Model.Engine
7-
{
6+
{
87
public class MLModelEngine<TData, TPrediction>
98
where TData : class
109
where TPrediction : class, new()
@@ -33,7 +32,7 @@ public MLModelEngine(string modelFilePathName, int maxObjectsRetained = -1)
3332
//Load the ProductSalesForecast model from the .ZIP file
3433
using (var fileStream = File.OpenRead(modelFilePathName))
3534
{
36-
_mlModel = _mlContext.Model.Load(fileStream);
35+
_mlModel = _mlContext.Model.Load(fileStream, out var modelInputSchema);
3736
}
3837

3938
_maxObjectsRetained = maxObjectsRetained;

samples/csharp/end-to-end-apps/ScalableMLModelOnWebAPI/src/Scalable.Model/Engine/PooledPredictionEnginePolicy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public PredictionEngine<TData, TPrediction> Create()
2020
// Measuring CreatePredictionengine() time
2121
var watch = System.Diagnostics.Stopwatch.StartNew();
2222

23-
var predictionEngine = _model.CreatePredictionEngine<TData, TPrediction>(_mlContext);
23+
var predictionEngine = _mlContext.Model.CreatePredictionEngine<TData, TPrediction>(_model);
2424

2525
watch.Stop();
2626
long elapsedMs = watch.ElapsedMilliseconds;

samples/csharp/end-to-end-apps/ScalableMLModelOnWebAPI/src/Scalable.Model/Scalable.Model.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<ItemGroup>
88
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="2.2.0" />
9-
<PackageReference Include="Microsoft.ML" Version="0.11.0" />
9+
<PackageReference Include="Microsoft.ML" Version="$(MicrosoftMLVersion)" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

samples/csharp/end-to-end-apps/ScalableMLModelOnWebAPI/src/Scalable.WebAPI/Scalable.WebAPI.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.ML" Version="0.11.0" />
9+
<PackageReference Include="Microsoft.ML" Version="1.0.0-preview" />
1010
<PackageReference Include="Microsoft.AspNetCore.App" />
1111
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
12+
<PackageReference Include="Microsoft.ML.FastTree" Version="1.0.0-preview" />
1213
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
1314
</ItemGroup>
1415

samples/csharp/end-to-end-apps/AnomalyDetection-ShampooSales-WinForms/README.md renamed to samples/csharp/end-to-end-apps/SpikeDetection-ShampooSales-WinForms/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
| ML.NET version | API type | Status | App Type | Data type | Scenario | ML Task | Algorithms |
44
|----------------|-------------------|-------------------------------|-------------|-----------|---------------------|---------------------------|-----------------------------|
5-
| v0.11 | Dynamic API | Up-to-date | WinForms app | .csv files | Spike and Change Point Detection of Shampoo Sales | Anomaly Detection | IID Spike Detection and IID Change point Detection |
5+
| v1.0.0-preview | Dynamic API | Up-to-date | WinForms app | .csv files | Spike and Change Point Detection of Shampoo Sales | Anomaly Detection | IID Spike Detection and IID Change point Detection |
66

77
![Alt Text](./ShampooSalesAnomalyDetection/images/shampoosales.gif)
88

@@ -77,7 +77,7 @@ IDataView dataView = mlcontext.Data.LoadFromTextFile<AnomalyExample>(path: fileP
7777
string outputColumnName = nameof(AnomalyPrediction.Prediction);
7878
string inputColumnName = nameof(AnomalyExample.numReported);
7979

80-
var trainingPipeline = mlcontext.Transforms.IidSpikeEstimator(outputColumnName, inputColumnName, confidenceLevel, pValue);
80+
var trainingPipeLine = mlcontext.Transforms.DetectIidSpike(outputColumnName: nameof(ShampooSalesPrediction.Prediction), inputColumnName: nameof(ShampooSalesData.numSales),confidence: 95, pvalueHistoryLength: size / 4);
8181
```
8282

8383
### 2. Train model
@@ -100,7 +100,7 @@ ITransformer trainedModel;
100100
// Load model
101101
using (FileStream stream = new FileStream(modelPath, FileMode.Open, FileAccess.Read, FileShare.Read))
102102
{
103-
trainedModel = mlcontext.Model.Load(stream);
103+
trainedModel = mlcontext.Model.Load(stream,out var modelInputSchema);
104104
}
105105

106106
// Apply data transformation to create predictions

0 commit comments

Comments
 (0)