Library built using ML .NET, Microsoft's machine learning platform
Create and your own bespoke AI model and make predictions
Hi community,
Websites usually have sections that contain information about the various products or services offered by the website.
It may contain a list of the different products or services offered, along with descriptions and more information in other pages.
This AI Assistant can help visitors narrow down which of the website's products or services suits their needs,
by classifying the visitor's natural language and/or numeric based input into one of the categories of products or services offered by the website.
You can then provide more information about that category.
The API provided by the library let you create your bespoke AI model based on your training data.
and then load your model and make predictions.
Implementation
The library is built using ML .NET, Microsoft's machine learning platform.
You can create a bespoke AI model by feeding your own training data.
The model can support classification based on
- natural language and/or
- numeric
training data and inputs to the trained AI model.
Example of natural language & numeric
Training data & input
Car categories:
public enum CarCategory
{
None = -1,
TwoDoorBasic = 0,
TwoDoorLuxury = 1,
FourDoorBasic = 2,
FourDoorLuxury = 3
}
Training data:
-1
0 2 door
0 basic
0 low price $ 20,000
0 mid price $ 25,000
0 high price $ 30,000
1 2 door
1 luxury
1 low price $ 40,000
1 mid price $ 45,000
1 high price $ 50,000
2 4 door
2 basic
2 low price $ 60,000
2 mid price $ 65,000
2 high price $ 70,000
3 4 door
3 luxury
3 low price $ 80,000
3 mid price $ 85,000
3 high price $ 90,000
The training data can be from a file or an IEnumerable list (from database for eg.).
Create your bespoke AI model using the library.
PredictionEngine.DataViewType = DataViewType.File;
PredictionEngine.DataViewFilePath = "TrainingDataset.tsv";
PredictionEngine.TextFeaturizingEstimatorOptions = new TextFeaturizingEstimatorOptions
{
CharFeatureExtractor = new WordBagEstimatorOptions
{
NgramLength = 3, // Only 3-char sequences
UseAllLengths = false, // Do not include shorter n-grams
Weighting = WordBagWeightingCriteria.TfIdf
},
WordFeatureExtractor = new WordBagEstimatorOptions
{
NgramLength = 3, // Only 3-char sequences
UseAllLengths = false, // Do not include shorter n-grams
Weighting = WordBagWeightingCriteria.TfIdf
}
};
// Path to save model
string modelPath = Path.Combine(Environment.CurrentDirectory, "Data", "SampleWebsite-AI-Model.zip");
await PredictionEngine.CreateModelAsync(modelPath);
Build the DI container to use the helper service (WebsiteAIAssistantService) provided by library.
This service is used to make predictions.
var services = new ServiceCollection();
services.AddWebsiteAIAssistantCore(settings =>
{
settings.AIModelLoadFilePath = Path.Combine(Environment.CurrentDirectory, "Data", "SampleWebsite-AI-Model.zip");
settings.NegativeConfidenceThreshold = 0.70f;
settings.NegativeLabel = -1f;
});
aiAssistantServiceProvider = services.BuildServiceProvider();
Unit tests on model:
[Theory]
[InlineData("price $ 42,000", CarCategory.TwoDoorLuxury)]
[InlineData("price $ 39,000", CarCategory.TwoDoorBasic)]
[InlineData("price $ 53,000", CarCategory.TwoDoorLuxury)]
[InlineData("4 door price $ 67,000", CarCategory.FourDoorBasic)]
[InlineData("luxury price $ 88,000", CarCategory.FourDoorLuxury)]
[InlineData("luxury price $ 62,000", CarCategory.TwoDoorLuxury)]
[InlineData("2 door price $ 29,000", CarCategory.TwoDoorBasic)]
[InlineData("low price $ 55,000", CarCategory.TwoDoorLuxury)]
[InlineData("high price $ 34,000", CarCategory.TwoDoorBasic)]
[InlineData("What is the colour of a rose?", CarCategory.None)]
public async Task Load_Predict_Service_CarCategory(string userInput, CarCategory expectedResult)
{
// Arrange
var aiAssistantService = _aiAssistantServiceProvider!.GetRequiredService<IWebsiteAIAssistantService>();
var input = new ModelInput { Feature = userInput };
// Act
var prediction = await aiAssistantService.PredictAsync(input);
// Assert
Assert.NotNull(prediction);
Assert.Equal(expectedResult, (CarCategory)prediction.PredictedLabel);
}
You can use the library in many different types of such scenarios.
Browse the library on GitHub:
VeritasSoftware
/
WebsiteAIAssistant
Library built using ML .NET. Create and your own bespoke AI model and make predictions.
Website AI Assistant
Library built using ML .NET, Microsoft's machine learning platform
Create and your own bespoke AI model and make predictions
AI Assistant helps visitors to your website, narrow down which of the offered products or services suits their needs.
Overview
Websites usually have sections that contain information about the various products or services offered by the website.
It may contain a list of the different products or services offered, along with descriptions and more information in other pages.
This AI Assistant can help visitors narrow down which of the website's products or services suits their needs,
by classifying the visitor's natural language and/or numeric based input into one of the categories of products or services offered by the website.
You can then provide more information about that category.
The API provided by the library let you create your bespoke AI model…
Top comments (0)