受欢迎的博客标签

Part 2- ML.NET

Published

ML.NET for Beginners

Fisrt ML.Net ConsoleApp

<ItemGroup>
  <PackageReference Include="Microsoft.ML" Version="4.0.2" />
</ItemGroup>

 

using Microsoft.ML;
using Microsoft.ML.Data;


namespace FisrtML.netConsoleApp
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World!");
        }
    }
}

 

//Step 1. Create an ML Context
var ctx = new MLContext();

//Step 2. Read in the input data from a text file for model training
IDataView trainingData = ctx.Data
    .LoadFromTextFile<ModelInput>(dataPath, hasHeader: true);

//Step 3. Build your data processing and training pipeline
var pipeline = ctx.Transforms.Text
    .FeaturizeText("Features", nameof(SentimentIssue.Text))
    .Append(ctx.BinaryClassification.Trainers
        .LbfgsLogisticRegression("Label", "Features"));

//Step 4. Train your model
ITransformer trainedModel = pipeline.Fit(trainingData);

//Step 5. Make predictions using your trained model
var predictionEngine = ctx.Model
    .CreatePredictionEngine<ModelInput, ModelOutput>(trainedModel);

var sampleStatement = new ModelInput() { Text = "This is a horrible movie" };

var prediction = predictionEngine.Predict(sampleStatement);

 

https://dotnet.microsoft.com/zh-cn/apps/ai/ml-dotnet

 

出租车

https://www.cnblogs.com/kenwoo/p/10171481.html

 

为了理解ML.NET的使用,我们通过一个具体的分类任务——预测客户是否会购买某产品,来演示如何构建和训练一个ML模型。这个任务贴近实际业务需求,掌握机器学习的基本流程。

https://www.cnblogs.com/code-daily/p/18749505