mlnet-predict 1.0.7

dotnet tool install --global mlnet-predict --version 1.0.7                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local mlnet-predict --version 1.0.7                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=mlnet-predict&version=1.0.7                
nuke :add-package mlnet-predict --version 1.0.7                

MLNetPredict (mlnet-predict)

MLNetPredict is a .NET tool for predicting various machine learning tasks using ML.NET. It supports multiple scenarios including classification, regression, forecasting, recommendation, image/text classification, and object detection.

Purpose

The mlnet-cli or mlnet model builder tools are designed to output strongly-typed model files and project files, which require the project to be built in order to be used. The purpose of this library is to execute predictions based on ML.NET models and output files without needing to modify the project. It allows for predictions to be made directly from input files.

Features

  • Classification: Predict categories for given inputs.
  • Regression: Predict continuous values.
  • Forecasting: Predict future values based on historical data.
  • Recommendation: Provide recommendations based on user/item interactions.
  • Image Classification: Classify images into predefined categories.
  • Text Classification: Classify text data into predefined categories.
  • Object Detection: Detect objects within images.

Installation

To install the MLNetPredict tool, use the following command:

dotnet tool install --global mlnet-predict

Usage

Basic Usage

mlnet-predict <model-path> <input-path> [options]
  • model-path: Path to the directory containing the .mlnet model file.
  • input-path: Path to the input file or directory.

Options

  • -o, --output-path: Path to the output directory (optional).
  • --has-header: Specify [true|false] if the dataset file(s) have a header row.
  • --separator: Specify the separator character used in the dataset file(s).

Example Commands

Classification
mlnet-predict <model-path> <input-path> [options]
mlnet-predict models/GithubIssues files/github-issue/input.csv --has-header true
Regression
mlnet-predict <model-path> <input-path> [options]
mlnet-predict models/TaxiFarePrediction files/taxi-fare/input.csv
Forecasting
mlnet-predict <model-path> <input-path> [options]
mlnet-predict models/HourlyEnergyConsumption files/hourly_energy_consumption/input.json
Recommendation
mlnet-predict <model-path> <input-path> [options]
mlnet-predict models/MovieRecommendation files/movie-recommendation/input.csv
Image Classification
mlnet-predict <model-path> <input-path> [options]
mlnet-predict models/ImageClassification files/images/
Text Classification
mlnet-predict <model-path> <input-path> [options]
mlnet-predict models/TextClassification files/texts/input.csv --has-header true
Object Detection
mlnet-predict <model-path> <input-path> [options]
mlnet-predict models/ObjectDetection files/images/

Prerequisites

Before running predictions, ensure that your ML.NET model and consumption code are properly generated. Use the following commands to create your models:

Example for Classification

mlnet classification --dataset "files/github-issue/issues.tsv" --label-col "Area" --train-time 120 --output "models" --name "GithubIssues" --log-file-path "./models/GithubIssues/logs.txt"

Example for Regression

mlnet regression --dataset "files/taxi-fare/taxi-fare-train.csv" --label-col "fare_amount" --validation-dataset "files/taxi-fare/taxi-fare-test.csv" --has-header true --name "TaxiFarePrediction" --train-time 120 --output "models" --log-file-path "./models/Sales/logs.txt"

Data Samples

Taxi Fare Prediction (Regression)

Sample Training Data (taxi-fare-train.csv)
vendor_id,rate_code,passenger_count,trip_time_in_secs,trip_distance,payment_type,fare_amount
CMT,1,1,1271,3.8,CRD,17.5
CMT,1,1,474,1.5,CRD,8
CMT,1,1,637,1.4,CRD,8.5
CMT,1,1,181,0.6,CSH,4.5
Creating the Model with mlnet
mlnet regression --dataset "files/taxi-fare/taxi-fare-train.csv" --label-col "fare_amount" --validation-dataset "files/taxi-fare/taxi-fare-test.csv" --has-header true --name "TaxiFarePrediction" --train-time 120 --output "models" --log-file-path "./models/TaxiFarePrediction/logs.txt"
Sample Input Data (input.csv)
vendor_id,rate_code,passenger_count,trip_time_in_secs,trip_distance,payment_type,fare_amount
CMT,1,1,584,2.3,CSH,
CMT,1,1,955,3.1,CRD,
Predicting with mlnet-predict
mlnet-predict models/TaxiFarePrediction files/taxi-fare/input.csv --output-path files/taxi-fare/predicted/
Sample Predicted Output Data (input-predicted.csv)
Score
9.724622
13.320532
11.618114
7.158864

Testing

Unit tests for the tool are available in the MLNetPredict.Tests namespace. Use the following command to run the tests:

dotnet test
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
1.0.7 493 5/24/2024
1.0.6 427 5/23/2024
1.0.5 402 5/23/2024
1.0.4 487 5/23/2024
1.0.2 384 5/23/2024
1.0.1 395 5/23/2024
1.0.0 432 5/23/2024