An Introduction to Machine Learning

anitakivindyo
4 min readJul 26, 2022

--

So what exactly is Machine learning? Well, before we get into the scientific terms and definitions, the name “Machine learning” can give us an idea of what it entails. In simpler terms, computers or ‘machines’ learn how to solve problems and improve from experience automatically. Cool, right?

A more scientific definition of Machine learning Machine Learning is a branch of artificial intelligence that allow software applications to predict outcomes more accurately without being explicitly programmed to do so.

How the computers/software/machine learns can be categorized into 3 main ways.

Supervised learning: here the training dataset has a corresponding label(output) associated with it, the algorithm therfore learns to predict the label (output)values

Unsupervised learning: here there are no labels for training data, therefore the algorithm tries to learn underlying patterns in the given data

Reinforcement learning: here the algorithm figures out which actions taken that maximize a reward on the way to achieving a specific goal.

There are 5 major steps that have simplified the Machine learning process, and these are.

Step1:Problem definition

Step 2:Building the dataset

Step 3:Training the Model

Step 4:Evaluating the model

Step 5:Using the model/model Inference

1.Problem Definition

This step involves specifically defining the machine learning task by understanding the problem. Is it going to be a supervised learning task? Is the data categorical or continuous? Is it going to be an unsupervised learning task? or do we implement reinforcement learning?

For example

An e-commerce company wants to know whether it should focus more on website development or on mobile application development since it launched both applications 5 years ago.

How do we define the problem statement? This problem is quite vague, we need to get more specific and ask very specific questions.

A better example could be:How does the time users spend on the mobile application compare to the time users spend on the website application?

This can help us come up with the ML task to proceede with. In this case, it is a supervised learning task since the data we will use, will probably have the solution (a label), and we will implement continous regression since we will be using numeric data.

2. Build the Dataset

Now we collect the data that matches the Machine learning Task defined. This can be achieved by performing direct SQL queries to a database, Web Scrapping or even running a model over data to generate needed labels.

After collecting data, we inspect the quality of the data. This is a very important step. Here we remove outliers, check for incomplete values and transform and preprocess data. Keep in mind, we need our data to be consistent because poor quality of data can affect the performance of our model.

We then perform some summary statistics to check if the data is consistent to the assumptions made. This involves calculating mean, Inter-Quartile range, standard deviation. This gives us insight of the scope, shape and scale of the dataset.

We can then visualize the data, to have a better understanding of the dataset. Especially if you are trying to show the existing trends in the data to company stakeholders, graphs are your friends . It makes everyone’s work easier, trust me.

3. Model Training

So now our dataset is all clean, preprocessed ,and we have a better understanding of the data. Its now time to train our model. Yay!

To feed our data to the model we need to split the dataset into the training dataset and testing dataset. Most of the time this is done 80% ,20% respectively. So we train our model using the training dataset first, then we test our trained model using the test dataset.

The training process involves, feeding training data into the model, computing the loss function of the result and updating the model parameters(weights) to reduce the loss. The loss function measures how far or close our model’s values are from the actual values. During training we try to minimize this loss without underfitting or overfitting our model.

This step can be iterative as we try to compare different model training algorithms and how good they perform in a specific use case.

Some model examples include : linear models,tree-based models, deep learning models.

4.Model Evaluation

After we’ve collected data and trained our model we have to now evaluate how well our model is performing.

We can use different statistical Metrics to evaluate our model.

Some statistical metrics include; accuracy (the most common),log loss,Mean Absolute Error, precision, adjusted square ,R-squared (R²), Mean Square Error, Root Mean Square Error among others.

However, note that the metrics used for evaluation are specific to the problem defined and the training algorithm used.

For example.

For a linear regression model,accuracy is harder to illustrate because it is quite impossible to predict the exact value, but rather how close your prediction is against the real value. The metrics for model evaluation in linear regression can be R-square/adjusted r-square (note that these 2 are performed differently), Mean square error or Root mean square error and mean absolute error.

5 Inference/ Use the model

After evaluating our model and are satisfied by the results. We can now use our model to generate predictions on real-world problems using ‘unseen data’ in the field. This is called Inferencing.

Note that the machine learning process is very iterative, so dont loose heart. You will need to monitor the model and its results during inferencing. You might even need to re-investigate the data, modify some parameters in the training algorithm or even change the model type for the training.

However the case, the Machine learning process can be a very interactive and iterative process. It can be fun and quite eye-opening. You can kickstart your journey by using existing frameworks that have working implementations of models and training algorithms.

Let’s get modelling :) https://www.kaggle.com/

--

--

anitakivindyo

My personal blog aiming to explain concepts in Machine Learning, Artificial Intelligence and Data science