GenderPrediction.Turkish is a library that provides prediction of gender from Turkish names built on ML.NET Both training application and library included in source code.
- .NET 4.6.1 (Desktop / Server)
- .NET Standard 2.0
- .NET Core 2.0, 2.1, 2.2
Build server | Platform | Build status | Integration tests |
---|---|---|---|
AppVeyor | Windows | ||
Travis | Linux / MacOS |
Following commands can be used to install GenderPrediction.Turkish, run the following command in the Package Manager Console
Install-Package GenderPrediction.Turkish
Or use dotnet cli
dotnet GenderPrediction.Turkish
GenderPrediction.Turkish can be used with any DI library, or it can be used standalone.
If you do not want to use any DI framework, you have to instantiate GenderPredictionStandalone
as follows.
IGenderPredictionService genderPredictionService = GenderPredictionStandalone.Create();
First, you need to install Microsoft.Extensions.DependencyInjection
NuGet package as follows
dotnet add package Microsoft.Extensions.DependencyInjection
Register necessary dependencies to ServiceCollection
as follows
var services = new ServiceCollection();
services.AddSingleton<IGenderPredictionEngine, GenderPredictionEngine>();
services.AddTransient<IGenderPredictionService, GenderPredictionService>();
ServiceProvider buildServiceProvider = services.BuildServiceProvider();
var genderPredictionService = buildServiceProvider.GetRequiredService<IGenderPredictionService>();
The singleton registration of the GenderPredictionEngine is important for performance, since its loads and initialize the trained model. After the library is initialized, it is very easy to use.
GenderPredictionModel model = genderPredictionService.Predict("Deniz");
string name = genderPredictionModel.Name;
Gender predictedGender = genderPredictionModel.PredictedGender;
float maleProbability = genderPredictionModel.Score[Gender.Male];
float femaleProbability = genderPredictionModel.Score[Gender.Female];
float unisexProbability = genderPredictionModel.UnisexProbability
Or
string[] names = new[] {"Dilek", "Hasan", "Mehmet", "İbrahim"};
IEnumerable<GenderPredictionModel> model = genderPredictionService.Predict(names);
Licensed under MIT, see LICENSE for the full text.