kagula
Feb-28-2023
Introduction
Given a Machine Learning flow with the most straightforward example by python.
Prerequisites
- JupyterLab 3.4.4
- Python 3.9
Content
Machine Learning Flow
pic 1. Machine Learning Flow
Commonly, Machine Learning Flow has 7 steps.
Step1: Import the Data
Collect data that you need to train the Model.
Step2: Clean the Data
Organize the data and classify the data into a table sheet and remove irrelevant, duplicated, incomplete data. Converting the text-based value to numerical values, for example, we assumption gender is only having male or female we can use 0 to 1 to substitute. commonly, the table sheet is in Excel format.
The format of the sheet is usually as below pattern
X1 in col1 | ... | XN in col N | Y in col N+1 | |
The First Record | ... | ... | ... | ... |
... | ... | ... | ... | ... |
The Last Record | ... | ... | ... | ... |
As the set of Y = function (X1, ..., XN), X1 to XN are variables for input and Y is the output, where N is natural number which is equal or greater than 2.
The model is to extrapolate the relationship between input and output with limited data, that relationship is the pattern getting from training.
Step3: Split the Data into Training/Test Sets
Generally, we need more than 80% percent data for training and the rest of the data is to test the pattern which is generated by training.
Step4: Create a Model
We need a model to train. A model is the algorithm of Machine Learning for looking for pattern between input and output. Here X1 to XN is the input, Y is the output. Generally, we use Decision Tree or Neuro Network algorithm. in the next example of Python, we will use the Decision Tree algorithm.
Step5: Train the Model
Get the pattern from training the data by the selected Model.
Step6:Make Prediction
Now we can use the test data to check the accuracy of pattern.
Step7: Evaluate and Improve
We have the rest of the input and output data to check pattern accuracy. If the accuracy is not satisfying our need, we can fine-tune the parameters of model and use more abundant and accurate data to train. How to fine-tune the parameters of model reference the tutorial of scikit library.
An Example with Python
First step, prepare sample
Get the Data that you need to feed the Model of Machine Learning.
You can download the music.csv from My CSDN Resource Share, in the file is fake data only intent for illustrate the concept.
Last step, get the Machine Learning code and run it
input and run the Python snippet that I gave you.
Pic2. Hello World of Machine Learning
Now you already get the concept, the next step is to read the tutorial of the Sklearn library.
Reference
- <<Python Machine Learning Tutorial (Data Science)>> by 'Programming with Mosh'