#MLNET – API improvements in the new 0.6.0 version

Hi!

A few days ago, the ML.Net team released the 0.6.0 version of Machine Learning.Net and one of the most important changes it’s on the way we use ML.Net API.

In my MLNet sessions I usually comment on a prediction scenario based on the Label of a person to see if it is a child, baby or teenager. All of this using a small set of data with information like name, age and gender.

01 mlnet age range data

As you can see from the previous image, my training data set has the columns Name, Age, Gender And Label. well, One important detail is that I also need 2 .Net classes with fields to represent the rows of My trainings Datasets and the expected Prediction.

In the 0.5.0 version of ML.Net the way of working was based on creating a pipeline with the following steps

  • Define the data model and load training data
  • Define the features and labels
  • Select a Trainer and train the model

The generated model allowed to make Predictions. The following example explains it in 20 Lines of code

With the 0.6.0 version, the way the API is used has changed a lot. The best thing at this point is to read the original post of Cesar De la Torre where he explains the novelties of this version (see references). However, I think leaving an example of the same code, adapted to version 0.6.0, will be good enough to share an idea of how flexible is the new API

The main changes

  • Lines 5 to 9, loading the initial data file for training
  • Lines 11 to 18, Defining Features and Label for training
  • Line 20, training and model creation
  • Line 22, Creating a function to make predictions
  • Lines 24 to 32, example of a prediction

The complete example available in https://github.com/elbruno/Blog/tree/master/20181011%20MLNET%200.6%20NewAPI

Happy coding!

Greetings @ Toronto

El Bruno

References

My Posts

Advertisements

2 thoughts on “#MLNET – API improvements in the new 0.6.0 version

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s