Here are the steps for performing Student Pass or Fail Prediction Experiment on Azure Machine Learning
- First you need to get / create database file ( .csv ).
- Enter in Microsoft Azure Portal,
Click on New -> Data Services -> Machine Learning -> Quick Create, than enter Workspace Name, Select Location, Create a new storage account, Give name of New storage account and Click Correct Sign.
- Workspace will be created,
Workspace will be created and show online then Click below Open In Studio button after selection of your workspace Name ( if more than one workspace ). Then a separate (https://studio.azureml.net) Online Studio will be loaded in new browser tab.
- Machine Learning Studio will open in separate browser Tab.
Left side Menu Experiments, Web Services, Datasets, Trained Models, Settings.
- Now if you want to create a new experiment with your own dataset (.CSV) file,
Click on DATASETS (Left Menu). In Datasets two tabs are there MY DATASETS and SAMPLES, where MY DATASETS means your used or uploaded datasets are listed below and SAMPLES means you can see Samples of already available Datasets of studio. If you want to upload your ( .csv ) file than click below button NEW.
- Than again Click DATASETS -> FROM LOCAL FILE,
- Browse your .csv file, Enter a name for the Dataset than Click Right Button below. Your Dataset File (.CSV) will be uploaded. You can see uploaded dataset in MY DATASETS.
- Now we will make Experiment,
Click on EXPERIMENTS in Left Main Menu, you will find MY EXPERIMENRS (Already created Experiments by User) and SAMPLES (Already readymade available Experiments to study). We want to create our own then select below NEW button.
- New Experiment
Select EXPERIMENT and Blank Experiment button ( + Logo ).
- Your New Experiment will be loaded.
You can click on Experiment created on 5/6/2015 and Rename your Experiment (Give your experiment Name).
- Write dataset name which you have uploaded recently in the search bar's left side, and that dataset will be loaded below in My Datasets, you simply Drag that Dataset from left side menu and Drop it in Experiment Space.
- Likewise you search Split, Train Model, Score Model and evaluate model and Drag and Drop all item in Experiment space one by one like shown in above snapshot.
Split – Split we use for Data Transformation, we will give 70% Data of CSV file to train the Model and remaining 30% Data to test the train model.
Train Model – Train Model has two inputs; one input is of ML Algorithm and second input is for 70% Data from Split.
Score Model – This model also has two inputs one from Train model and second input from 30% Data from Split to taste the Train Model.
Evaluate Model – This model evaluates the score results and calculates the ML parameters like True Positive, True Negative, False Positive, False Negative, ROC, Precision, Recall, Accuracy of Experiment, F1 Score, AUC etc. for classification algorithm.
- Now Split the Data
Give connection of .CSV file to Split, Select Split and click Properties in Right side Menu where you can divide database for train model and score model (e.g. 80% - 20%, 75 % - 25 %, 70% - 30 %) ideally 70% for Train model and remaining 30% for Score Model, So in Property enter 0.7 (means 70 % for Train Model 30 % data for Score Model) value in Fraction of Rows.
- Now do the connections like shown in snapshot, first output of split to train model and second output to score model, output of train model to first input of score model, output of score model to evaluate model.
- Now apply Classification Algorithm to Train the Model,
Type Classification in search bar left side; it will load 14 Classification Algorithms, Drag Two-Class Decision Jungle Algorithm from Left side and Drop above Train Model. Give output of that Algorithm to First input of Train Model.
- Now we want to Train the Model on Result field of .csv file.
Select Train Model Right Side click on Property, Select Launch Column Selector.
- Wherein Select Include -> Column Names -> Result field and Click right mark button.
- Now Give Name to Experiment and Save. Give Name to Experiment (Student Pass Fail Prediction) than Click on SAVE Button in below tile menu.
- Run the Experiment. Click on RUN button in below tiled menu,
- After Running the Experiment,
You will find Green Right Mark on each Model that means you have no errors in each model.
- See output of Score Model,
Right Click on output point of score model and press Visualize.
- Output of Score Model,
Two extra fields will be added after Result field, which is Scored Labels and Scored Probabilities. Scored Labels means Train Model has predicted the Result of that 30% Data which we have passed in Score Model.
- See ML Parameters of Algorithm in Evaluate Model,
Right Click on output point of Evaluate Model and Press Visualization.
- ROC Graph of Score Dataset,
- Parameters
Above Result shows Accuracy almost 68% of Experiment.
- A = True Positive B = False Negative C = False Positive D = True Negative
- Accuracy = (A+D) / (A+B+C+D)
- Precision = A / (A+C)
- Recall = A / (A+B)
- Make Score Experiment to publish as Web Service.
Once again Save the experiment and Run the Experiment then Create Scoring, Experiment button will be activated then Click Create Scoring Experiment.
- Scoring Experiment Created
Now your experiment is converted into two Tabs Training Experiment and Scoring Experiment, In Scoring Experiment your Split, Two Class Decision Jungle Algorithm will be merged in Student Pass Fail Prediction Model, and score model will have Web service input and Web service output and .CSV Dataset will be disabled.
Now Press Save Button and Press Run Button of Scoring Experiment.
- Convert Score Experiment to Web Service view and apply output filter
After Running the Score Experiment your score model has green right mark that means you've successfully run the experiment after that you need to convert the score experiment to Web service view by Click the Switch to Web Service View button below.
- Web Service view enabled
Now we want score Label (Result) as a web service output from values which we will insert in web service input so we need to set web service output as score label.
- Add Project Column to set output field as Score Label of web service
Search Project Column in search bar and Drag and Drop Project Column between Score model and Web service output.
- Apply Score model output to Project Column and output of Project Column to Web Service output. Than Select Project Column -> Click Property Right Side -> Select Launch Column Selector.
- Select No Column -> Include -> Column Names -> Select Scored Labels from Dropdown (Do not type). Click Right Mark.
- Save the Experiment, Run the Experiment. Find Green Right Mark in Score Model and Project Column that means runs successfully.
- Now Experiment ready to publish as Web Service.
For that click on PUBLISH WEB SERVICE button below tiled Menu.
- Dashboard of Web Service.
- Web Service API Key, Press TEST Button to test the web service and get output. Whether Student will Pass or Fail this web service will predict the Result.
- Enter Data to see the Predicted result of Student whether he will Pass or Fail
Enter Data one by one and press Right Mark Button.
- Processing
- Web Service Predicted Result PASS ( >=40 ) Highlighted,
- Request Response
- When you click on Request Response. You will find API documentation.
Sample Code in 3 Languages c#, python and R language.
- C# Code of Web Service to apply this web service in Visual Studio.
-
-
-
-
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Net.Http;
- using System.Net.Http.Formatting;
- using System.Net.Http.Headers;
- using System.Text;
- using System.Threading.Tasks;
- namespace CallRequestResponseService
- {
- public class StringTable
- {
- public string[] ColumnNames
- {
- get;
- set;
- }
- public string[, ] Values
- {
- get;
- set;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- InvokeRequestResponseService().Wait();
- }
- static async Task InvokeRequestResponseService()
- {
- using(var client = new HttpClient())
- {
- var scoreRequest = new
- {
- Inputs = new Dictionary < string, StringTable > ()
- {
- {
- "input1",
- new StringTable()
- {
- ColumnNames = new string[]
- {
- "Full name","Illness (in %) per semester","Attendance (in %) per semester","SSC result (in %)","HSC result (in %)","Father Education","Mother Education",
- "Hostel","Study hours (per day)","Sports","Disability","Medium","Result"
- },
- Values = new string[, ] {
- {
- "value","0","0", "0","0","0","0","value","0","value","value", "value","value"
- },
- {
- "value","0","0","0","0","0","0","value","0","value","value", "value","value"
-
- },
- }
- }
- },
- },
- GlobalParameters = new Dictionary < string, string > () {}
- };
- const string apiKey = "abc123";
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
- client.BaseAddress = new Uri("https://ussouthcentral.services.azureml.net/workspaces/7c38001675154abdaf92f8ce0b9f9e27/services/9cfb7036562044b78a724398339fb12a/execute?api-version=2.0&details=true");
-
-
-
-
-
-
- HttpResponseMessage response = await client.PostAsJsonAsync("", scoreRequest);
- if (response.IsSuccessStatusCode)
- {
- string result = await response.Content.ReadAsStringAsync();
- Console.WriteLine("Result: {0}", result);
- } else
- {
- Console.WriteLine(string.Format("The request failed with status code: {0}", response.StatusCode));
-
- Console.WriteLine(response.Headers.ToString());
- string responseContent = await response.Content.ReadAsStringAsync();
- Console.WriteLine(responseContent);
- }
- }
- }
- }
- }