MyML.NetApp is a sample ML.NET application that demonstrates how to train, evaluate, and consume a machine learning model using .NET 9.0.
This project shows how to use ML.NET to build, train, evaluate, and consume a machine learning model. It uses a sample dataset (wikipedia-detox-250-line-data.tsv) for demonstration purposes. All model-building and utility logic is centralized in a shared library for maintainability and testability.
MyML.NetApp/- Main application for consuming the trained modelMyML.NetAppML.ConsoleApp/- Console app for making predictions using the trained modelMyML.NetAppML.Model/- Model input/output classes and model consumption logicMyML.NetAppML.Lib/- Shared library containing all model-building, training, and utility logicMyML.NetAppML.Tests/- xUnit test project for all core logicData/- Sample data files
- .NET 9.0 SDK
- Visual Studio or VS Code
dotnet build MyML.NetApp.sln- Clone this repository:
git clone https://github.com/yourusername/MyML.NetApp.git cd MyML.NetApp - Restore dependencies:
dotnet restore
- Build the solution:
dotnet build MyML.NetApp.sln
- (Optional) Train a new model by calling
ModelBuilder.CreateModel()from your own script or app. - Ensure
MLModel.zipexists inMyML.NetAppML.Model(retrain if needed).
- See the shared library's
ModelBuilder.CreateModel()for training logic. - The trained model is saved as
MLModel.zipin theMyML.NetAppML.Modeldirectory.
- Run the console app to make predictions using the trained model:
dotnet run --project MyML.NetAppML.ConsoleApp
- Or run the main application:
dotnet run --project MyML.NetApp
Run all unit tests with:
dotnet test MyML.NetAppML.Tests/MyML.NetAppML.Tests.csprojAll core logic is covered by xUnit tests, including model input/output, prediction, and utility methods.
All user-facing strings are managed via .resx resource files for easy localization and code quality compliance.
- Model file not found: Ensure
MLModel.zipexists in theMyML.NetAppML.Modeldirectory. Retrain if needed. - ML.NET version issues: All projects target .NET 9.0 and use ML.NET 1.5.0. Ensure your environment matches.
- Test failures or hangs: Ensure your test data includes at least two distinct class labels for multiclass classification.
See CHANGELOG.md for a detailed list of changes and release history.
We welcome contributions from the community! To get started:
- Fork this repository and clone your fork locally.
- Create a new branch for your feature or bugfix:
git checkout -b my-feature-branch
- Make your changes and add tests as appropriate.
- Run the test suite to ensure nothing is broken:
dotnet test MyML.NetAppML.Tests/MyML.NetAppML.Tests.csproj - Commit and push your changes to your fork.
- Open a Pull Request (PR) against the
masterbranch with a clear description of your changes.
- If you find a bug or have a feature request, please open an issue with as much detail as possible.
- Include steps to reproduce, expected behavior, and screenshots/logs if relevant.
- Follow the existing code style and conventions enforced by
.editorconfigand analyzers. - Write clear, concise commit messages and PR descriptions.
This project is licensed under the MIT License.
For questions or feedback, please contact the project maintainer: