ML.NET机器学习、API容器化与Azure DevOps实践(二):案例

【自取】最近整理的,有需要可以领取学习:

public IEnumerable<keyvaluepair<< code><code class="csharp keyword">string</code><code class="csharp plain">, RegressionMetrics>> TrainAndEvaluate(IDataView trainingDataView, IDataView testDataView)</code></keyvaluepair<<>
var metrics = new Dictionary< string , RegressionMetrics>();
foreach ( var trainer in this .trainers)
{
var pipeline = mlContext.Transforms.CopyColumns(inputColumnName: "G3" , outputColumnName: "Label" )
.Append(mlContext.Transforms.Categorical.OneHotEncoding( "School" ))
.Append(mlContext.Transforms.Categorical.OneHotEncoding( "Sex" ))
.Append(mlContext.Transforms.Categorical.OneHotEncoding( "Age" ))
.Append(mlContext.Transforms.Categorical.OneHotEncoding( "Famsize" ))
.Append(mlContext.Transforms.Categorical.OneHotEncoding( "Traveltime" ))
.Append(mlContext.Transforms.Categorical.OneHotEncoding( "Studytime" ))
.Append(mlContext.Transforms.Categorical.OneHotEncoding( "Paid" ))
.Append(mlContext.Transforms.Categorical.OneHotEncoding( "Higher" ))
.Append(mlContext.Transforms.Categorical.OneHotEncoding( "Famrel" ))
.Append(mlContext.Transforms.Concatenate( "Features" ,
"School" ,
"Sex" ,
"Age" ,
"Famsize" ,
"Guardian" ,
"Traveltime" ,
"Studytime" ,
"Failures" ,
"Paid" ,
"Higher" ,
"Famrel" ,
"Absences" ))
.AppendCacheCheckpoint(mlContext)
.Append(trainer);
var trainedModel = pipeline.Fit(trainingDataView);
trainedModels.Add(trainer.GetType().Name, trainedModel);
var predictionModel = trainedModel.Transform(testDataView);
var regMetrics = mlContext.Regression.Evaluate(predictionModel);
metrics.Add(trainer.GetType().Name, regMetrics);
}
return metrics;

Original: https://www.cnblogs.com/daxnet/p/12941764.html
Author: dax.net
Title: ML.NET机器学习、API容器化与Azure DevOps实践(二):案例

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/9633/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

发表回复

登录后才能评论
免费咨询
免费咨询
扫码关注
扫码关注
联系站长

站长Johngo!

大数据和算法重度研究者!

持续产出大数据、算法、LeetCode干货,以及业界好资源!

2022012703491714

微信来撩,免费咨询:xiaozhu_tec

分享本页
返回顶部