Train your data model using Azure AI model and predict results using C#
Hi friends, would like to talk today about the immense capabilities of Azure AI models, over the years how has it evolved and how could you leverage the same with C#, without writing much of a code (and of course very little understanding of AI).
Before we begin, let us consider some basics:
What is meant by REGRESSION in AI?
Regression is a machine learning algorithm technique that uses input features to predict continuous numerical outputs. It's a type of supervised learning, meaning it's trained on a labeled dataset with known output values.
Let me give you an example:
Suppose I have data about your company, as to how has it been performing w.r.t. the profit it has been making over years.
Here is the data:
When plotted it gives a scatter like this:
From here we can trace out a line that can cover the most of the points, and based on that we can easily find out the profit value, in another 10 years down the line.
Such a plot is typically marked with the equation: y=mx+c, where y is the outcome, x is the input data, m is the gradient and C is the initial value.
This is a typical concept of regression, which we would cover in most of our model training algos, by 'labelling' data, and feeding datasets into models, over and over again, and thereby making the program understand the trend and 'predict' the future.
A slightly different algorithm is what we know as 'Classification', whereby depending on the incoming data, we can class or 'brand' an outcome:
Here is a typical example of training your model to predict if an incoming mail is 'Spam' or 'HAM' message, by training the model with the mail attributes types: sender, subject, embdeded URL, photos, etc. All this could be done by machine learning techniques like Deep forest and Random forest algorithms.
Now guess what: all these is done by Azure model studio, without you to need a single line of code and predicting the models precisely.
And yes: it is free. Test your data, locally -- absolutely free, before you promote it to higher levels of testing and deployments.
So here you go:
I downloaded the following data file from imdb site: https://www.kaggle.com/datasets, that gives me viewers' reactions to various movies and rating (1 or 0, with 1 meaning a postive review, 0 meaning a bad review). It contains the reactions from the input data. We would be using the same data in our Azure model training and would predict an input data.
We are assuming for now that we are going to use Visual Studio 2022, although we can use Visual Studio Code as well.
Step 1:
In your Visual Studio installer, make sure that you have already installed the following component:
In your Visual Studio 2022, begin with creating a new project area, and manage nugget packages:
Search for the above package and install the same.
Once done, in your project area, right click and you would see the following extension appearing:
Step-2
Choose the above and create model file with a suitable name. I created the same:
Uh, oh -- don't worry about the name (it was just a exampleπ π )
The following prompt opens:
This will load with a first few lines of records and allows you to select the input and output columns:
The above example shows, we have selected Column-0 as the column to be predicted, and column 1 as the input column (it contains the sentiment inputs).
Step-3
How to leverage the above through code:
Indicating that it's a pretty positive input from me, with a high score of 0.998 (nearer to 1, more is the accuracy).
Comments
Post a Comment