The second letter in the Hebrew alphabet is the ב bet/beit. Its meaning is "house". In the ancient pictographic Hebrew it was a symbol resembling a tent on a landscape.
Note: Pre-release packages are distributed via feedz.io.
The goal of this repo is to provide with production ready extensions to ML.NET library.
It contains two major functionality:
-
ML.NET ModelBuilder Pipeline with ability to load from different sources i.e. Azure Blob Storage.
-
ML.NET Web Api hosting with caching of ML models to improve performance. This library utilizes
ObjectPool
similar to Extensions.ML
If you like or are using this project to learn or start your solution, please give it a star. Thanks!
dotnet add package Bet.Extensions.ML
For complete examples please refer to sample projects:
Bet.AspNetCore.Sample
-AspNetCore
Web App with spam prediction models.Bet.Hosting.Sample
-DotNetCore
Worker based scheduled job for generating ML.NET Models.
To include Machine Learning prediction the following can be added:
services.AddModelPredictionEngine<SpamInput, SpamPrediction>(mlOptions =>
{
mlOptions.MLContext = () =>
{
var mlContext = new MLContext();
mlContext.ComponentCatalog.RegisterAssembly(typeof(LabelTransfomer).Assembly);
mlContext.Transforms.CustomMapping<LabelInput, LabelOutput>(LabelTransfomer.Transform, nameof(LabelTransfomer.Transform));
return mlContext;
};
mlOptions.CreateModel = (mlContext) =>
{
using (var fileStream = File.OpenRead("MLContent/SpamModel.zip"))
{
return mlContext.Model.Load(fileStream);
}
};
},"SpamModel");
Then in the API Controller:
[Route("api/[controller]")]
[ApiController]
public class PredictionController : ControllerBase
{
private readonly IModelPredictionEngine<SentimentObservation, SentimentPrediction> _sentimentModel;
private readonly IModelPredictionEngine<SpamInput, SpamPrediction> _spamModel;
public PredictionController(
IModelPredictionEngine<SentimentObservation, SentimentPrediction> sentimentModel,
IModelPredictionEngine<SpamInput, SpamPrediction> spamModel)
{
_sentimentModel = sentimentModel ?? throw new ArgumentNullException(nameof(sentimentModel));
_spamModel = spamModel ?? throw new ArgumentNullException(nameof(spamModel));
}
[HttpPost()]
public ActionResult<SentimentPrediction> GetSentiment(SentimentObservation input)
{
return _sentimentModel.Predict(input);
}
// GET /api/prediction/spam?text=Hello World
[HttpGet]
[Route("spam")]
public ActionResult<SpamPrediction> PredictSpam([FromQuery]string text)
{
return _spamModel.Predict(new SpamInput { Message = text});
}
}