Revize ce0940b5
Přidáno uživatelem Roman Kalivoda před více než 3 roky(ů)
Server/ServerApp/Predictor/NaiveBayesClassifier.cs | ||
---|---|---|
44 | 44 |
{ |
45 | 45 |
this._trainingDataView = _mlContext.Data.LoadFromEnumerable(trainInput); |
46 | 46 |
var pipeline = _mlContext.Transforms.Conversion.MapValueToKey(nameof(ModelInput.Label)) |
47 |
.Append(_mlContext.Transforms.Concatenate("Features", new[] { "Temp" })) |
|
48 |
.Append(_mlContext.Transforms.NormalizeMinMax("Features", "Features")) |
|
47 |
.Append(_mlContext.Transforms.Conversion.ConvertType(nameof(ModelInput.Hour))) |
|
48 |
.Append(_mlContext.Transforms.Concatenate("Features", |
|
49 |
new[] { nameof(ModelInput.Temp), nameof(ModelInput.Rain), nameof(ModelInput.Wind), nameof(ModelInput.Hour) })) |
|
50 |
.Append(_mlContext.Transforms.NormalizeMeanVariance("Features", useCdf:false)) |
|
49 | 51 |
.AppendCacheCheckpoint(_mlContext) |
50 | 52 |
.Append(_mlContext.MulticlassClassification.Trainers.NaiveBayes()) |
51 |
.Append(_mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel")); ;
|
|
53 |
.Append(_mlContext.Transforms.Conversion.MapKeyToValue(nameof(ModelOutput.PredictedLabel)));
|
|
52 | 54 |
|
53 | 55 |
var cvResults = _mlContext.MulticlassClassification.CrossValidate(this._trainingDataView, pipeline); |
54 | 56 |
_log.Debug("Cross-validated the trained model"); |
... | ... | |
67 | 69 |
public void Evaluate(IEnumerable<ModelInput> modelInputs) |
68 | 70 |
{ |
69 | 71 |
var testDataView = this._mlContext.Data.LoadFromEnumerable(modelInputs); |
70 |
var testMetrics = _mlContext.MulticlassClassification.Evaluate(_trainedModel.Transform(testDataView)); |
|
72 |
var data = _trainedModel.Transform(testDataView); |
|
73 |
var testMetrics = _mlContext.MulticlassClassification.Evaluate(data); |
|
71 | 74 |
|
72 | 75 |
Console.WriteLine($"*************************************************************************************************************"); |
73 | 76 |
Console.WriteLine($"* Metrics for Multi-class Classification model - Test Data "); |
... | ... | |
76 | 79 |
Console.WriteLine($"* MacroAccuracy: {testMetrics.MacroAccuracy:0.###}"); |
77 | 80 |
Console.WriteLine($"* LogLoss: {testMetrics.LogLoss:#.###}"); |
78 | 81 |
Console.WriteLine($"* LogLossReduction: {testMetrics.LogLossReduction:#.###}"); |
82 |
Console.WriteLine($"* Confusion Matrix: {testMetrics.ConfusionMatrix.GetFormattedConfusionTable()}"); |
|
79 | 83 |
Console.WriteLine($"*************************************************************************************************************"); |
80 | 84 |
} |
81 | 85 |
} |
Také k dispozici: Unified diff
Re #9034 fixing files corrupted by merge