-
Notifications
You must be signed in to change notification settings - Fork 1
/
Snippets.txt
66 lines (52 loc) · 2.06 KB
/
Snippets.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
1 Create Pipeline
var pipeline = new LearningPipeline();
2 Load Data
pipeline.Add(new TextLoader<NotePredictionInput>(
dataPath,
useHeader: true,
separator: ","));
3 Calculate Label
pipeline.Add(new ColumnCopier(("NoteNumber", "Label")));
pipeline.Add(new Dictionarizer("Label"));
4 Calculate Features
pipeline.Add(new ColumnConcatenator("Features",
"KeySignature",
"Note0_Present",
"Note1_Present",
"Note2_Present",
"Note3_Present",
"Note4_Present",
"Note5_Present",
"Note6_Present",
"Note7_Present",
"Note8_Present",
"Note9_Present",
"Note10_Present",
"Note11_Present"));
5 Add Trainer
pipeline.Add(new StochasticDualCoordinateAscentClassifier());
6 Prediction Output
pipeline.Add(new PredictedLabelColumnOriginalValueConverter()
{
PredictedLabelColumn = "PredictedLabel"
});
7 Create Model
var model = pipeline.Train<NotePredictionInput, PredictedNote>();
await model.WriteAsync(modelPath);
-------------------------------------------------------------------------------------------
1 Load Model
var model = await PredictionModel
.ReadAsync<NotePredictionInput, PredictedNote>(modelPath);
2 Test
var result = model.Predict(input);
Console.WriteLine($"Predicted {result.NoteNumber}");
----------------------------------------
1 Load Model
var model = await PredictionModel
.ReadAsync<NotePredictionInput, PredictedNote>(_modelPath);
2 Predict
var feature = BuildFeature(knownNotes);
var result = model.Predict(feature);
3 Update Note
var newNote = AdjustToMeasureOctave(result.NoteNumber, knownNotes);
note.Note = newNote;