Search Results For : C#

ML.NET PART 4 – MACHINE LEARNING

2 weeks ago, in my part 3 post of my ML.NET adventure, i wrote about AutoML through Command Line Interface CLI and how i generated and i wish to expand more on them

What AutoML does and its coverage

As of time of writing, there are 3 that has incorporated into AutoML,

  1. binary-classification
  2. multiclass-classification
  3. regression

I also understand from Microsoft Docs that there will be future machine learning tasks that can be incorporated.

ML.NET CLI input and output
ML.NET CLI input and ouput

Image copied from https://docs.microsoft.com/en-us/dotnet/machine-learning/automate-training-with-cli

The various commands possible

> mlnet auto-train --task binary-classification --dataset "customer-feedback.tsv" --label-column-name Sentiment
> mlnet auto-train --task regression --dataset "cars.csv" --label-column-name Price
> mlnet auto-train --task multiclass-classification --dataset "Training.csv" --label-column-name "Risk" --max-exploration-time 600

Source – https://docs.microsoft.com/en-us/dotnet/machine-learning/reference/ml-net-cli-reference

Output from ML.NET

After running the respective commands for ML.NET, you will noticed 1 folder that will consists of

  1. logs folder
  2. ConsoleApp folder
  3. Model folder
  4. sln file (solution)

Logs – The logs file consists of a full logs with information on all the iterations that have happened while evaluating the algorithms.

ConsoleApp – This application, in C#, allows you to run and make predictions like an end-user applicaiton

Model –
it consists of MLModel.zip which is a serialized model that is ready to use for running predictions
it also consists of the code that was used to generate the model which we can use for retraining purposes.

Quality of the generated model

Understanding more on the quality of the model that was generated.

You will notice –
with Binary Classification – comes
1. Accuracy
2. AUC
3. AUPRC
4. F1-Score

with Multiclass Classification – comes
1. MicroAccuracy
2. MacroAccuracy

with Regression – comes
1. RSquared
2. Absolute-loss
3. Squared-loss
4. RMS-loss

You will be able to see how to understand the metrics via this link – https://docs.microsoft.com/en-us/dotnet/machine-learning/resources/metrics

ML.NET Part 2 – Machine Learning

Last week, i did the first post on ML.NET covering the basics and its various steps required to get a model up and use it – I will cover how to go about preparing, coding and using them in the later posts.

Two of the key steps involved are
1. Loading the data
2. Transforming the data
3. Training and Generating the model
4. Using the trained model

In this tutorial, we will focus on getting the environment in your computer correct so that we can prepare and start doing ML.NET. Kindly note that this tutorial is written for Windows Environment. As of time of writing, i am on Windows 10 with Visual Studio 2017 Enterprise.

Installing MLNET

I attempted to start by calling the command (You can start by going to Command Prompt and type straight away)

mlnet

but i was thrown with the error –

'mlnet' is not recognized as an internal or external command, operable program or batch file. 
'mlnet' is not recognized as an internal or external command, operable program or batch file.
‘mlnet’ is not recognized as an internal or external command, operable program or batch file.

I recognized that i do not have mlnet installed. I then run

dotnet tool install -g mlnet

and what? –

No executable found matching command "dotnet-tool"

Based on some search, concluded it is due to the fact that dotnet tool is only available in .NET CORE 2.1.3 onwards and I am running – 2.1.2

dotnet version
dotnet version

Went on to https://dotnet.microsoft.com/download/dotnet-core/2.2 and downloaded dotnet core 2.2 (as of time of writing .net 3 is in preview and hence I did not use yet). Do note that the release was not compatible with VS 2017 and if you are using VS 17, there is another version for you to download.

After installing, restart your computer and let it install again by running the command.

dotnet tool install -g mlnet

Note that you have to wait. Nothing will happen for some time and it will just magically works after that!

mlnet installed!
mlnet installed!

Posts-
ML.NET Introduction – Introduction
ML.NET Part 2 – Machine Learning – Environment setup

Azure Site Under Construction

Despite my deployment has been a success and active, when i navigate to the online link, it presents me with a blank page with a “Site Under Construction” error in the title.

Azure - Site Under Construction

Azure – Site Under Construction

It was due to the deployment process may have some malfunctioned and app_offline.htm is still there.

app_offline.htm present

app_offline.htm present

The solution is simple, go into App Service > Console and type in the command

rm app_offline.htm

Azure App Service Deployment Center git failure

My configuration was BitBucket and linked to Azure App Service via the Deployment Center and it auto pulls from my Master branch.

One fine day, the deployment failed and threw me this error.

I am not sure what caused the locked but here’s the solution but upon inspection of the logs, i received this.

Fatal: Unable to create ‘D:/home/site/repository/.git/index.lock’: File exists.Another git process seems to be running in this repository, e.g. an editor opened by ‘git commit’. Please make sure all processes are terminated then try again. If it still fails, a git processmay have crashed in this repository earlier: remove the file manually to continue. D:\Program Files\Git\cmd\git.exe checkout master –force

Go into your App Service > Console > Navigate to the folder and use rm command to remove it.

cd D:\home\site\repository\.git
rm index.lock

Thereafter, go back to your deployment center and click on Sync and it will work magically.

Quick note on Web.config file

A quick note on Web.config file in the ASP.NET project. It is worth noting that the file is a XML File (read this for more info – https://msdn.microsoft.com/en-us/library/ff400235.aspx )

One issue that hindered my process earlier was that the content in the value has special character it in, particularly, one of my SQL server’s password has a special character in it.

I would have to go and replace them accordingly. For instance, my password is <Password1& (note that < and ” is inclusive), i would have to change it to
&lt;Password1&amp;

You can refer to the list here – https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references