- Hands-On Machine Learning with ML.NET
- Jarred Capellman
- 131字
- 2021-06-24 16:43:35
The Trainer class
In the Trainer class, we will build a new pipeline to train our model. The FeaturizeText transform builds NGrams from the strings data we previously extracted from the files. NGrams are a popular method to create vectors from a string to, in turn, feed the model. You can think of NGrams as breaking a longer string into ranges of characters based on the value of the NGram parameter. A bi-gram, for instance, would take the following sentence, ML.NET is great and convert it into ML-.N-ET-is-gr-ea-t. Lastly, we build the SdcaLogisticRegression trainer object:
var dataProcessPipeline = MlContext.Transforms.CopyColumns("Label", nameof(FileInput.Label))
.Append(MlContext.Transforms.Text.FeaturizeText("NGrams", nameof(FileInput.Strings)))
.Append(MlContext.Transforms.Concatenate("Features", "NGrams"));
var trainer = MlContext.BinaryClassification.Trainers.SdcaLogisticRegression(labelColumnName: "Label", featureColumnName: "Features");
For those looking to deep dive further into the Transforms Catalog API, check out the documentation from Microsoft here: https://docs.microsoft.com/en-us/dotnet/api/microsoft.ml.transformscatalog?view=ml-dotnet.
推薦閱讀
- 黑客攻防從入門到精通(實戰秘笈版)
- 微服務設計(第2版)
- Testing with JUnit
- Power Up Your PowToon Studio Project
- 跟“龍哥”學C語言編程
- Windows系統管理與服務配置
- Python程序設計案例教程
- Full-Stack React Projects
- Securing WebLogic Server 12c
- Hands-On Enterprise Automation with Python.
- Learning OpenCV 3 Computer Vision with Python(Second Edition)
- C#應用程序設計教程
- Java Web開發詳解
- SQL 經典實例
- WordPress Search Engine Optimization(Second Edition)