Revize ebe96ca4
Přidáno uživatelem Roman Kalivoda před téměř 4 roky(ů)
Server/ServerApp/Predictor/NaiveBayesClassifier.cs | ||
---|---|---|
2 | 2 |
// Author: Roman Kalivoda |
3 | 3 |
// |
4 | 4 | |
5 |
using System; |
|
6 | 5 |
using System.Collections.Generic; |
7 | 6 |
using System.Linq; |
8 |
using System.Text; |
|
9 |
using System.Threading.Tasks; |
|
10 | 7 |
using Microsoft.ML; |
11 |
using Microsoft.ML.Data; |
|
12 | 8 |
using ServerApp.Parser.OutputInfo; |
13 | 9 | |
14 | 10 |
namespace ServerApp.Predictor |
... | ... | |
34 | 30 |
public NaiveBayesClassifier() |
35 | 31 |
{ |
36 | 32 |
mlContext = new MLContext(); |
37 | ||
38 |
} |
|
39 | ||
40 |
/// <summary> |
|
41 |
/// Extracts list of feature vectors from parsed info objects. |
|
42 |
/// </summary> |
|
43 |
/// <param name="weatherInfos">List of weather info objects.</param> |
|
44 |
/// <param name="activityInfos">List of info objects about activities at the site.</param> |
|
45 |
/// <returns>A list of feature vectors for model training.</returns> |
|
46 |
public IEnumerable<ModelInput> ExtractModelInput(List<WeatherInfo> weatherInfos, List<ActivityInfo> activityInfos) |
|
47 |
{ |
|
48 |
return weatherInfos.Select(e => new ModelInput(){ |
|
49 |
Temp = (float)e.temp, |
|
50 |
Label = e.temp > 15.0 ? "Full" : "Empty", |
|
51 |
}).ToList(); |
|
52 | 33 |
} |
53 | 34 | |
54 | 35 |
public void Fit(IEnumerable<ModelInput> trainInput) |
Také k dispozici: Unified diff
Re #8832 PredictionController implementation