├── .gitignore
├── LICENSE
├── MLNetExamples
├── AnomalyDetection
│ ├── AnomalyDetection.csproj
│ ├── AnomalyResult.cs
│ ├── EnergyData.cs
│ ├── EnergyPrediction.cs
│ ├── Program.cs
│ └── energy_hourly.csv
├── AutoML
│ ├── AutoML.csproj
│ ├── HousingData.cs
│ ├── Program.cs
│ └── housing.csv
├── AutoMLRanking
│ ├── AutoMLRanking.csproj
│ ├── Program.cs
│ ├── RankingData.cs
│ └── ranking.tsv
├── AzureFunction
│ ├── .gitignore
│ ├── AzureFunction.csproj
│ ├── HousingData.cs
│ ├── HousingPredict.cs
│ ├── HousingPrediction.cs
│ ├── HousingRetrain.cs
│ ├── Startup.cs
│ └── host.json
├── BagOfWords
│ ├── BagOfWords.csproj
│ ├── Input.cs
│ ├── Output.cs
│ └── Program.cs
├── BinaryClassification
│ ├── BinaryClassification.csproj
│ ├── Program.cs
│ ├── TitanicData.cs
│ ├── TitanicPrediction.cs
│ └── titanic.csv
├── BinaryData
│ ├── BinaryData.csproj
│ ├── HousingData.cs
│ ├── HousingPrediction.cs
│ ├── Program.cs
│ └── housing.csv
├── BookRecommendations
│ ├── Book.cs
│ ├── BookRating.cs
│ ├── BookRatingPrediction.cs
│ ├── BookRecommendations.csproj
│ ├── Data
│ │ ├── bookfeatures.csv
│ │ └── ratings.csv
│ └── Program.cs
├── CustomTransform
│ ├── CustomTransform.csproj
│ ├── InputData.cs
│ ├── NewData.cs
│ ├── OutputData.cs
│ └── Program.cs
├── CustomVisionOnnx
│ ├── BoundingBox.cs
│ ├── CustomVisionOnnx.csproj
│ ├── Model
│ │ ├── labels.txt
│ │ └── model.onnx
│ ├── Program.cs
│ ├── WineInput.cs
│ ├── WineModel.cs
│ ├── WinePredictions.cs
│ └── test
│ │ ├── red-test.jpg
│ │ └── white.jpg
├── DataPrepRowsColumns
│ ├── DataPrepRowsColumns.csproj
│ ├── HousingData.cs
│ ├── HousingPrediction.cs
│ ├── Program.cs
│ └── housing.csv
├── DatabaseData
│ ├── DatabaseData.csproj
│ ├── Program.cs
│ ├── SalaryData.cs
│ ├── SalaryData.csv
│ ├── SalaryPrediction.cs
│ └── config.json
├── DatabaseLoader
│ ├── DatabaseLoader.csproj
│ ├── HousingData.cs
│ ├── HousingPrediction.cs
│ ├── Program.cs
│ └── config.json
├── DeepNeuralNetwork
│ ├── DeepNeuralNetwork.csproj
│ ├── ImageData.cs
│ ├── ImagePrediction.cs
│ └── Program.cs
├── DeepNeuralNetworkUpdate
│ ├── DeepNeuralNetworkUpdate.csproj
│ ├── ImageData.cs
│ ├── ImageModelInput.cs
│ ├── ImagePrediction.cs
│ └── Program.cs
├── EntityFrameworkData
│ ├── EntityFrameworkData.csproj
│ ├── MLNetExampleContext.cs
│ ├── Program.cs
│ ├── SalaryData.cs
│ ├── SalaryData.csv
│ └── SalaryPrediction.cs
├── EventHubPredict
│ ├── EventHubPredict.csproj
│ ├── HousingData.cs
│ ├── HousingPrediction.cs
│ ├── Model
│ │ └── housing-model.zip
│ └── Program.cs
├── ExpressionTransform
│ ├── ExpressionOutput.cs
│ ├── ExpressionTransform.csproj
│ ├── Program.cs
│ └── SalaryInput.cs
├── FSharpRegression
│ ├── FSharpRegression.fsproj
│ ├── Program.fs
│ ├── SalaryTest.csv
│ └── SalaryTrain.csv
├── FeatureImportance
│ ├── FeatureImportance.csproj
│ ├── HousingData.cs
│ ├── HousingPrediction.cs
│ ├── Program.cs
│ └── housing.csv
├── InferColumns
│ ├── InferColumns.csproj
│ ├── Program.cs
│ └── housing.csv
├── LargeFeatures
│ ├── LargeFeatures.csproj
│ ├── Program.cs
│ ├── SensorData.cs
│ ├── SensorPrediction.cs
│ └── features.csv
├── MLNetExamples.sln
├── ModelExplainability
│ ├── HousingData.cs
│ ├── HousingPrediction.cs
│ ├── ModelExplainability.csproj
│ ├── Program.cs
│ └── housing.csv
├── NGrams
│ ├── Input.cs
│ ├── NGrams.csproj
│ ├── Output.cs
│ └── Program.cs
├── NormalizeText
│ ├── Input.cs
│ ├── NormalizeText.csproj
│ ├── Output.cs
│ └── Program.cs
├── Notebooks
│ ├── Bank Analysis and ML.NET Classifier.ipynb
│ ├── Dataframe with AutoML.ipynb
│ ├── Intro to DataFrame.ipynb
│ ├── ML.NET Event Hub Producer.ipynb
│ ├── ML.NET Filter Transforms.ipynb
│ ├── NimbusML
│ │ ├── Regression.ipynb
│ │ └── housing.csv
│ ├── Plotting in C# with XPlot.ipynb
│ └── housing.csv
├── NullValues
│ ├── HousingData.cs
│ ├── MissingData.cs
│ ├── NullValues.csproj
│ ├── Program.cs
│ ├── ReplacedValues.cs
│ └── housing.csv
├── Onnx
│ ├── Onnx.csproj
│ ├── Program.cs
│ ├── SalaryData.cs
│ ├── SalaryData.csv
│ └── SalaryPrediction.cs
├── PredictDNN
│ ├── ImageData.cs
│ ├── ImagePrediction.cs
│ ├── PredictDNN.csproj
│ └── Program.cs
├── PredictionBot
│ ├── AdapterWithErrorHandler.cs
│ ├── Bots
│ │ └── HousingBot.cs
│ ├── Controllers
│ │ └── BotController.cs
│ ├── DeploymentTemplates
│ │ ├── new-rg-parameters.json
│ │ ├── preexisting-rg-parameters.json
│ │ ├── template-with-new-rg.json
│ │ └── template-with-preexisting-rg.json
│ ├── Dialogs
│ │ └── HousingPredictionDialog.cs
│ ├── MLModel
│ │ └── housing-model.zip
│ ├── Models
│ │ ├── HousingData.cs
│ │ └── HousingPrediction.cs
│ ├── PredictionBot.csproj
│ ├── Program.cs
│ ├── README.md
│ ├── Startup.cs
│ ├── appsettings.Development.json
│ ├── appsettings.json
│ └── wwwroot
│ │ └── default.htm
├── Ranking
│ ├── Program.cs
│ ├── Ranking.csproj
│ ├── RankingData.cs
│ ├── RankingPrediction.cs
│ └── ranking.tsv
├── RetrainModel
│ ├── HousingData.cs
│ ├── Program.cs
│ ├── RetrainModel.csproj
│ └── retrain_housing_data.csv
├── ScaleData
│ ├── HousingData.cs
│ ├── HousingPrediction.cs
│ ├── Program.cs
│ ├── ScaleData.csproj
│ └── housing.csv
├── SeedClustering
│ ├── Program.cs
│ ├── SeedClustering.csproj
│ ├── SeedData.cs
│ ├── SeedPrediction.cs
│ └── Seed_Data.csv
├── SelectAndShuffle
│ ├── HousingData.cs
│ ├── HousingPrediction.cs
│ ├── Program.cs
│ ├── SelectAndShuffle.csproj
│ └── housing.csv
├── SentimentAnalysis
│ ├── Program.cs
│ ├── SentimentAnalysis.csproj
│ ├── SentimentData.cs
│ ├── SentimentPrediction.cs
│ └── stock_data.csv
├── SimpleRegression
│ ├── Program.cs
│ ├── README.md
│ ├── SalaryData.cs
│ ├── SalaryData.csv
│ ├── SalaryPrediction.cs
│ └── SimpleRegression.csproj
├── SimpleRegressionUpdate
│ ├── Program.cs
│ ├── SalaryData.cs
│ ├── SalaryData.csv
│ ├── SalaryPrediction.cs
│ └── SimpleRegressionUpdate.csproj
├── StopWords
│ ├── Program.cs
│ ├── StopWords.csproj
│ ├── TextData.cs
│ └── TextTokens.cs
├── TextTransferLearning
│ ├── DataStructures
│ │ ├── FixedLengthVector.cs
│ │ ├── MovieReview.cs
│ │ ├── MovieReviewSentiment.cs
│ │ └── VariableLengthVector.cs
│ ├── Program.cs
│ └── TextTransferLearning.csproj
├── TimeSeriesForecast
│ ├── EnergyData.cs
│ ├── EnergyForecast.cs
│ ├── Program.cs
│ ├── TimeSeriesForecast.csproj
│ └── energy_hourly.csv
├── Tokenization
│ ├── Program.cs
│ ├── SentimentData.cs
│ ├── SentimentTokens.cs
│ └── Tokenization.csproj
├── TransferLearning
│ ├── ImageData.cs
│ ├── ImagePrediction.cs
│ ├── InceptionSettings.cs
│ ├── Program.cs
│ ├── TransferLearning.csproj
│ ├── images
│ │ ├── book.jpg
│ │ ├── cup.jpg
│ │ ├── cup2.jpg
│ │ └── sunflower.jpg
│ └── labels.csv
└── WordEmbeddings
│ ├── Program.cs
│ ├── TextFeatures.cs
│ ├── TextInput.cs
│ └── WordEmbeddings.csproj
└── README.md
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Jon Wood
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MLNetExamples/AnomalyDetection/AnomalyDetection.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | PreserveNewest
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/MLNetExamples/AnomalyDetection/AnomalyResult.cs:
--------------------------------------------------------------------------------
1 | namespace AnomalyDetection
2 | {
3 | public class AnomalyResult
4 | {
5 | public bool PredictedLabel { get; set; }
6 | public float Score { get; set; }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/MLNetExamples/AnomalyDetection/EnergyData.cs:
--------------------------------------------------------------------------------
1 |
2 | using Microsoft.ML.Data;
3 | using System;
4 |
5 | namespace AnomalyDetection
6 | {
7 | public class EnergyData
8 | {
9 | [LoadColumn(0)]
10 | public DateTime Date { get; set; }
11 |
12 | [LoadColumn(1)]
13 | public float Energy { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/MLNetExamples/AnomalyDetection/EnergyPrediction.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.ML.Data;
2 |
3 | namespace AnomalyDetection
4 | {
5 | public class EnergyPrediction
6 | {
7 | [VectorType(2)]
8 | public double[] Prediction { get; set; }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/MLNetExamples/AnomalyDetection/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.ML;
2 | using Microsoft.ML.Data;
3 | using System;
4 | using System.Linq;
5 |
6 | namespace AnomalyDetection
7 | {
8 | class Program
9 | {
10 | static void Main(string[] args)
11 | {
12 | var context = new MLContext();
13 |
14 | var data = context.Data.LoadFromTextFile("./energy_hourly.csv",
15 | hasHeader: true,
16 | separatorChar: ',');
17 |
18 | var pipeline = context.Transforms.DetectSpikeBySsa(nameof(EnergyPrediction.Prediction), nameof(EnergyData.Energy),
19 | confidence: 98, trainingWindowSize: 90, seasonalityWindowSize: 30, pvalueHistoryLength: 30);
20 |
21 | var transformedData = pipeline.Fit(data).Transform(data);
22 |
23 | var predictions = context.Data.CreateEnumerable(transformedData, reuseRowObject: false).ToList();
24 |
25 | var energy = data.GetColumn("Energy").ToArray();
26 | var date = data.GetColumn("Date").ToArray();
27 |
28 | Console.WriteLine("Anomalies:");
29 | for (int i = 0; i < predictions.Count(); i++)
30 | {
31 | if (predictions[i].Prediction[0] == 1)
32 | {
33 | Console.WriteLine("{0}\t{1:0.0000}\t{2:0.00}\t{3:0.00}\t{4:0.00}",
34 | date[i], energy[i], predictions[i].Prediction[0], predictions[i].Prediction[1], predictions[i].Prediction[2]);
35 | }
36 | }
37 |
38 | Console.ReadLine();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/MLNetExamples/AutoML/AutoML.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | PreserveNewest
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/MLNetExamples/AutoML/HousingData.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.ML.Data;
2 |
3 | namespace AutoML
4 | {
5 | public class HousingData
6 | {
7 | [LoadColumn(0)]
8 | public float Longitude { get; set; }
9 |
10 | [LoadColumn(1)]
11 | public float Latitude { get; set; }
12 |
13 | [LoadColumn(2)]
14 | public float HousingMedianAge { get; set; }
15 |
16 | [LoadColumn(3)]
17 | public float TotalRooms { get; set; }
18 |
19 | [LoadColumn(4)]
20 | public float TotalBedrooms { get; set; }
21 |
22 | [LoadColumn(5)]
23 | public float Population { get; set; }
24 |
25 | [LoadColumn(6)]
26 | public float Households { get; set; }
27 |
28 | [LoadColumn(7)]
29 | public float MedianIncome { get; set; }
30 |
31 | [LoadColumn(8), ColumnName("Label")]
32 | public float MedianHouseValue { get; set; }
33 |
34 | [LoadColumn(9)]
35 | public string OceanProximity{ get; set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/MLNetExamples/AutoML/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.ML;
2 | using Microsoft.ML.AutoML;
3 | using Microsoft.ML.Data;
4 | using System;
5 |
6 | namespace AutoML
7 | {
8 | class Program
9 | {
10 | static void Main(string[] args)
11 | {
12 | var context = new MLContext();
13 |
14 | var trainData = context.Data.LoadFromTextFile("./housing.csv", hasHeader: true, separatorChar: ',');
15 |
16 | var settings = new RegressionExperimentSettings
17 | {
18 | MaxExperimentTimeInSeconds = 20,
19 | OptimizingMetric = RegressionMetric.MeanAbsoluteError
20 | };
21 |
22 | var labelColumnInfo = new ColumnInformation()
23 | {
24 | LabelColumnName = "Label"
25 | };
26 |
27 | var progress = new Progress>(p =>
28 | {
29 | if (p.ValidationMetrics != null)
30 | {
31 | Console.WriteLine($"Current Result - {p.TrainerName}, {p.ValidationMetrics.RSquared}, {p.ValidationMetrics.MeanAbsoluteError}");
32 | }
33 | });
34 |
35 | var experiment = context.Auto().CreateRegressionExperiment(settings);
36 |
37 | var result = experiment.Execute(trainData, labelColumnInfo, progressHandler: progress);
38 |
39 | Console.WriteLine(Environment.NewLine);
40 | Console.WriteLine("Best run:");
41 | Console.WriteLine($"Trainer name - {result.BestRun.TrainerName}");
42 | Console.WriteLine($"RSquared - {result.BestRun.ValidationMetrics.RSquared}");
43 | Console.WriteLine($"MAE - {result.BestRun.ValidationMetrics.MeanAbsoluteError}");
44 |
45 | Console.ReadLine();
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/MLNetExamples/AutoMLRanking/AutoMLRanking.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.1
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | PreserveNewest
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/MLNetExamples/AutoMLRanking/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using Microsoft.ML;
4 | using Microsoft.ML.AutoML;
5 | using Microsoft.ML.Data;
6 |
7 | namespace AutoMLRanking
8 | {
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | var context = new MLContext();
14 |
15 | var data = context.Data.LoadFromTextFile("./ranking.tsv", separatorChar: '\t');
16 |
17 | var trainTestSplit = context.Data.TrainTestSplit(data, testFraction: 0.2);
18 |
19 | var settings = new RankingExperimentSettings
20 | {
21 | MaxExperimentTimeInSeconds = 300,
22 | OptimizingMetric = RankingMetric.Ndcg,
23 | };
24 |
25 | var experiment = context.Auto().CreateRankingExperiment(settings);
26 |
27 | var progressHandler = new Progress>(ph =>
28 | {
29 | if (ph.ValidationMetrics != null)
30 | {
31 | Console.WriteLine($"Current trainer - {ph.TrainerName} with nDCG {ph.ValidationMetrics.NormalizedDiscountedCumulativeGains.Average()}");
32 | }
33 | });
34 |
35 | var results = experiment.Execute(trainTestSplit.TrainSet, validationData: trainTestSplit.TestSet,
36 | progressHandler: progressHandler);
37 |
38 | var bestRun = results.BestRun;
39 |
40 | var metrics = bestRun.ValidationMetrics.NormalizedDiscountedCumulativeGains;
41 |
42 | Console.WriteLine(Environment.NewLine);
43 | Console.WriteLine($"Best model {bestRun.TrainerName} - with nDCG {metrics.Average()}");
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/MLNetExamples/AutoMLRanking/RankingData.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.ML.Data;
2 |
3 | namespace AutoMLRanking
4 | {
5 | public class RankingData
6 | {
7 | [LoadColumn(0)]
8 | public float Label { get; set; }
9 |
10 | [LoadColumn(1)]
11 | public float GroupId { get; set; }
12 |
13 | [LoadColumn(2, 133)]
14 | [VectorType(133)]
15 | public float[] Features { get; set; }
16 | }
17 | }
--------------------------------------------------------------------------------
/MLNetExamples/AzureFunction/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # Azure Functions localsettings file
5 | local.settings.json
6 |
7 | # User-specific files
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | bld/
24 | [Bb]in/
25 | [Oo]bj/
26 | [Ll]og/
27 |
28 | # Visual Studio 2015 cache/options directory
29 | .vs/
30 | # Uncomment if you have tasks that create the project's static files in wwwroot
31 | #wwwroot/
32 |
33 | # MSTest test Results
34 | [Tt]est[Rr]esult*/
35 | [Bb]uild[Ll]og.*
36 |
37 | # NUNIT
38 | *.VisualState.xml
39 | TestResult.xml
40 |
41 | # Build Results of an ATL Project
42 | [Dd]ebugPS/
43 | [Rr]eleasePS/
44 | dlldata.c
45 |
46 | # DNX
47 | project.lock.json
48 | project.fragment.lock.json
49 | artifacts/
50 |
51 | *_i.c
52 | *_p.c
53 | *_i.h
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.tmp_proj
68 | *.log
69 | *.vspscc
70 | *.vssscc
71 | .builds
72 | *.pidb
73 | *.svclog
74 | *.scc
75 |
76 | # Chutzpah Test files
77 | _Chutzpah*
78 |
79 | # Visual C++ cache files
80 | ipch/
81 | *.aps
82 | *.ncb
83 | *.opendb
84 | *.opensdf
85 | *.sdf
86 | *.cachefile
87 | *.VC.db
88 | *.VC.VC.opendb
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 | *.sap
95 |
96 | # TFS 2012 Local Workspace
97 | $tf/
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 | *.DotSettings.user
106 |
107 | # JustCode is a .NET coding add-in
108 | .JustCode
109 |
110 | # TeamCity is a build add-in
111 | _TeamCity*
112 |
113 | # DotCover is a Code Coverage Tool
114 | *.dotCover
115 |
116 | # NCrunch
117 | _NCrunch_*
118 | .*crunch*.local.xml
119 | nCrunchTemp_*
120 |
121 | # MightyMoose
122 | *.mm.*
123 | AutoTest.Net/
124 |
125 | # Web workbench (sass)
126 | .sass-cache/
127 |
128 | # Installshield output folder
129 | [Ee]xpress/
130 |
131 | # DocProject is a documentation generator add-in
132 | DocProject/buildhelp/
133 | DocProject/Help/*.HxT
134 | DocProject/Help/*.HxC
135 | DocProject/Help/*.hhc
136 | DocProject/Help/*.hhk
137 | DocProject/Help/*.hhp
138 | DocProject/Help/Html2
139 | DocProject/Help/html
140 |
141 | # Click-Once directory
142 | publish/
143 |
144 | # Publish Web Output
145 | *.[Pp]ublish.xml
146 | *.azurePubxml
147 | # TODO: Comment the next line if you want to checkin your web deploy settings
148 | # but database connection strings (with potential passwords) will be unencrypted
149 | #*.pubxml
150 | *.publishproj
151 |
152 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
153 | # checkin your Azure Web App publish settings, but sensitive information contained
154 | # in these scripts will be unencrypted
155 | PublishScripts/
156 |
157 | # NuGet Packages
158 | *.nupkg
159 | # The packages folder can be ignored because of Package Restore
160 | **/packages/*
161 | # except build/, which is used as an MSBuild target.
162 | !**/packages/build/
163 | # Uncomment if necessary however generally it will be regenerated when needed
164 | #!**/packages/repositories.config
165 | # NuGet v3's project.json files produces more ignoreable files
166 | *.nuget.props
167 | *.nuget.targets
168 |
169 | # Microsoft Azure Build Output
170 | csx/
171 | *.build.csdef
172 |
173 | # Microsoft Azure Emulator
174 | ecf/
175 | rcf/
176 |
177 | # Windows Store app package directories and files
178 | AppPackages/
179 | BundleArtifacts/
180 | Package.StoreAssociation.xml
181 | _pkginfo.txt
182 |
183 | # Visual Studio cache files
184 | # files ending in .cache can be ignored
185 | *.[Cc]ache
186 | # but keep track of directories ending in .cache
187 | !*.[Cc]ache/
188 |
189 | # Others
190 | ClientBin/
191 | ~$*
192 | *~
193 | *.dbmdl
194 | *.dbproj.schemaview
195 | *.jfm
196 | *.pfx
197 | *.publishsettings
198 | node_modules/
199 | orleans.codegen.cs
200 |
201 | # Since there are multiple workflows, uncomment next line to ignore bower_components
202 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
203 | #bower_components/
204 |
205 | # RIA/Silverlight projects
206 | Generated_Code/
207 |
208 | # Backup & report files from converting an old project file
209 | # to a newer Visual Studio version. Backup files are not needed,
210 | # because we have git ;-)
211 | _UpgradeReport_Files/
212 | Backup*/
213 | UpgradeLog*.XML
214 | UpgradeLog*.htm
215 |
216 | # SQL Server files
217 | *.mdf
218 | *.ldf
219 |
220 | # Business Intelligence projects
221 | *.rdl.data
222 | *.bim.layout
223 | *.bim_*.settings
224 |
225 | # Microsoft Fakes
226 | FakesAssemblies/
227 |
228 | # GhostDoc plugin setting file
229 | *.GhostDoc.xml
230 |
231 | # Node.js Tools for Visual Studio
232 | .ntvs_analysis.dat
233 |
234 | # Visual Studio 6 build log
235 | *.plg
236 |
237 | # Visual Studio 6 workspace options file
238 | *.opt
239 |
240 | # Visual Studio LightSwitch build output
241 | **/*.HTMLClient/GeneratedArtifacts
242 | **/*.DesktopClient/GeneratedArtifacts
243 | **/*.DesktopClient/ModelManifest.xml
244 | **/*.Server/GeneratedArtifacts
245 | **/*.Server/ModelManifest.xml
246 | _Pvt_Extensions
247 |
248 | # Paket dependency manager
249 | .paket/paket.exe
250 | paket-files/
251 |
252 | # FAKE - F# Make
253 | .fake/
254 |
255 | # JetBrains Rider
256 | .idea/
257 | *.sln.iml
258 |
259 | # CodeRush
260 | .cr/
261 |
262 | # Python Tools for Visual Studio (PTVS)
263 | __pycache__/
264 | *.pyc
--------------------------------------------------------------------------------
/MLNetExamples/AzureFunction/AzureFunction.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netcoreapp2.1
4 | v2
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | PreserveNewest
17 |
18 |
19 | PreserveNewest
20 | Never
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/MLNetExamples/AzureFunction/HousingData.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.ML.Data;
2 |
3 | namespace AzureFunction
4 | {
5 | public class HousingData
6 | {
7 | [LoadColumn(0)]
8 | public float Longitude { get; set; }
9 |
10 | [LoadColumn(1)]
11 | public float Latitude { get; set; }
12 |
13 | [LoadColumn(2)]
14 | public float HousingMedianAge { get; set; }
15 |
16 | [LoadColumn(3)]
17 | public float TotalRooms { get; set; }
18 |
19 | [LoadColumn(4)]
20 | public float TotalBedrooms { get; set; }
21 |
22 | [LoadColumn(5)]
23 | public float Population { get; set; }
24 |
25 | [LoadColumn(6)]
26 | public float Households { get; set; }
27 |
28 | [LoadColumn(7)]
29 | public float MedianIncome { get; set; }
30 |
31 | [LoadColumn(8), ColumnName("Label")]
32 | public float MedianHouseValue { get; set; }
33 |
34 | [LoadColumn(9)]
35 | public string OceanProximity{ get; set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/MLNetExamples/AzureFunction/HousingPredict.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading.Tasks;
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.Azure.WebJobs;
6 | using Microsoft.Azure.WebJobs.Extensions.Http;
7 | using Microsoft.AspNetCore.Http;
8 | using Microsoft.Extensions.Logging;
9 | using Newtonsoft.Json;
10 | using Microsoft.Extensions.ML;
11 |
12 | namespace AzureFunction
13 | {
14 | public class HousingPredict
15 | {
16 | private readonly PredictionEnginePool _predictionEnginePool;
17 |
18 | public HousingPredict(PredictionEnginePool predictionEnginePool)
19 | {
20 | _predictionEnginePool = predictionEnginePool;
21 | }
22 |
23 | [FunctionName("HousingPredict")]
24 | public async Task Run(
25 | [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
26 | ILogger log)
27 | {
28 | log.LogInformation("C# HTTP trigger function processed a request.");
29 |
30 | string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
31 | var housingData = JsonConvert.DeserializeObject(requestBody);
32 |
33 | var prediction = _predictionEnginePool.Predict(housingData);
34 |
35 | return new OkObjectResult(prediction);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/MLNetExamples/AzureFunction/HousingPrediction.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.ML.Data;
2 |
3 | namespace AzureFunction
4 | {
5 | public class HousingPrediction
6 | {
7 | [ColumnName("Score")]
8 | public float PredictedPrice { get; set; }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/MLNetExamples/AzureFunction/HousingRetrain.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.Azure.WebJobs;
6 | using Microsoft.Azure.WebJobs.Host;
7 | using Microsoft.Extensions.Logging;
8 | using Microsoft.ML;
9 | using Microsoft.ML.Trainers;
10 | using Microsoft.WindowsAzure.Storage;
11 |
12 | namespace AzureFunction
13 | {
14 | public class HousingRetrain
15 | {
16 | [FunctionName("HousingRetrain")]
17 | public async Task Run([BlobTrigger("input/{name}", Connection = "AzureWebJobsStorage")]Stream myBlob, string name, ILogger log)
18 | {
19 | log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
20 | string blobData;
21 |
22 | // Download model files from Blob Storage, if needed
23 | string trainerFilePath = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "models/housing-trainer.zip");
24 | string pipelineFilePath = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "models/housing-data-prep.zip");
25 |
26 | var connectionString = Environment.GetEnvironmentVariable("AzureWebJobsStorage", EnvironmentVariableTarget.Process);
27 |
28 | var storageAccount = CloudStorageAccount.Parse(connectionString);
29 |
30 | var client = storageAccount.CreateCloudBlobClient();
31 |
32 | var container = client.GetContainerReference("models");
33 |
34 | var dataModel = container.GetBlockBlobReference("housing-data-prep.zip");
35 | var trainingModel = container.GetBlockBlobReference("housing-trainer.zip");
36 |
37 | if (!File.Exists(pipelineFilePath))
38 | {
39 | await dataModel.DownloadToFileAsync(pipelineFilePath, FileMode.Create);
40 | }
41 |
42 | if (!File.Exists(trainerFilePath))
43 | {
44 | await trainingModel.DownloadToFileAsync(trainerFilePath, FileMode.Create);
45 | }
46 |
47 | // Load models into ML Context
48 | var context = new MLContext();
49 |
50 | DataViewSchema modelSchema, pipelineSchema;
51 |
52 | var trainerModel = context.Model.Load(trainerFilePath, out modelSchema);
53 | var dataPrepModel = context.Model.Load(pipelineFilePath, out pipelineSchema);
54 |
55 | var originalModelParams =
56 | ((ISingleFeaturePredictionTransformer