Kickstart Machine learning
By: Mohit Bhat
Tags: Data Preprocessing, Regression, Ensemble Learning, Understanding Ai, Machine Learning

Hey, Welcome to the world of Machine learning where we predict things based on some input, Confused? This Blog will give you an overall idea of concepts used in machine learning to let you get started with predicting things…..!

First of all, let's understand where does machine learning stand and what is then artificial intelligence and Deep Learning?

Fig- Parts of AI

In the above image, you can see Machine Learning comes under Artificial intelligence and Deep Learning is a part of machine learning and Data science comes under all. I think the above image is self-explanatory and I will not waste time explaining the difference, so let jump straight to the concepts.

What actually is Machine Learning and what actually we do init??

So, Normally when we code something we have a set of inputs and we know what formula or data structure we have to use so we can get the desired output, but in machine learning we have output and we have input but we don't have the function that we have to use to get the desired output.

Also taking it further machine learning also solves the problem for this question- Can we generate output for inputs that we don't have or will come in the future?

How it is done??

So basically in machine learning, we use mathematical functions and some logic to train our model, and with hit&try we find the function that gives output mostly similar to what we want!

Some key Concepts Terms in Machine learning

Preprocessing

Regression Problems

Classification Problems

Metrics (Regression Metrics and Classification Metrics)

Underfitting and Overfitting

Parametric and Nonparametric Learning models(Type of Learning Algorithm)

Feature Engineering/Extraction

Models

Let's Understand Each of the above one by one

1. Preprocessing

Preprocessing is a very important part of machine learning. Whenever we get data either it has a lot of columns in which some are just useless like Sno, Roll no, etc. Also, it may contain null values, extremely small or large values in some rows which may affect the prediction.

Dataset

Columns are termed as features , why we call them features is because they describe properties about that entity or observation and we assign weight to each column to predict things.

are termed as , why we call them features is because they describe properties about that entity or observation and we assign weight to each column to predict things. Rows are termed as instance or tuples as a row describes a single entity or observation, they contain values of features and are the input to the model.

Now how to do preprocessing in python, we have some amazing python Libraries to help us with that

Numpy — So basically in python we have a list but those might not be ideal in machine learning due to computational constraints. we need arrays to deal with large datasets.

NumPy arrays are faster and more compact than Python lists. An array consumes less memory and is convenient to use. NumPy uses much less memory to store data and it provides a mechanism of specifying the data types

Pandas — So datasets are mostly CSV/excel files which we need to open in our python notebook. To open such large datasets and to perform operations on it the panda's library plays a vital role. In pandas datasets when open are usually called data frame. It has some amazing functions that help in preprocessing like drooping columns, filling null values, finding null values, etc.

Matplotlib — So this library helps us to visualize data, ie, With this library we can plot graphs, histograms, plot images, etc. Preprocessing also comprises understanding your data and then applying the required preprocessing methods. As datasets are mostly huge so in order to better understand things we can print them in form of graphs to get a better understanding.

One of the main parts of Preprocessing is dividing Dataset into train, test, and validation data

What the hell is Train, Test & validation data

So if you have the same doubt let's clear it out. Basically, Let's take the example of a car Prediction Dataset and you need to train the model. You have 10,000 rows of data. To train your model and also predict its output you need to break it. Let's take 60% as training data, 20 % as Testing, and 20% as validation. Testing and validation data doesn’t differ much but you can assume as you keep on correcting your model by seeing accuracy on test data and then when you are sure enough you are model is trained successfully you validate it on the validating dataset.

Please Keep a note, we should provide a good percentage as train data otherwise your model may underfit.

2. Regression Problems

When we start machine learning the first concept we encounter is Linear Regression. Regression Problems are those problems in which we have to predict some value. For example, we need to predict the price of a car based on some inputs. Linear regression is one of the models which helps us to predict the output. Basically, it is, Y=mx+c. There are other ways also to find values but for now, we will focus on this only.

3. Classification Problems

The next set of problems we encounter are Classification Problems. so Basically as the name suggests these problems comprise of yes/ no type output. You are classifying things, not only limited to yes/no but also like whether the election will be won by BJP or Congress or AAP. Whether the person has diabetes or not. Whether this diabetes is A, B, or C type.

For such Problems, we have Logistic Regression, Decision trees, etc models for prediction. will Cover models later on !!

4. Metrics

So when we train a model in machine learning on a training dataset then we have to find error or accuracy of our model Prediction. This is called Metrics. Evaluating our model's accuracy or loss is what we call metrics. Now there two types of metrics Regression and Classification metrics as we mostly have problems based on these two.

Regression Metrics —

Mean Absolute Error (MAE)

Mean Squared Error(MSE)

Median Absolute Error(MAE)

Mean Squared Logarithmic Error(MSLE)

Max Error(ME)

Root Mean Squared Error(RMSE)

Explained Variance Score(EV)

R² Score

Classification Metrics —

Accuracy

Recall

Precision

False Positive Rate

True Negative Rate

Misclassification Rate

F1 Score

F-Beta Score

ROC curve/Roc Score

Average Precision

5. Underfitting and Overfitting

This is a very important concept that everyone should know and keep track of while making models. When we train a model-

We might get good accuracy or less error on training data but when we try our trained model to predict on the testing dataset we get bad accuracy or high error. This is called Overfitting.

Or We Might get very high error/Low accuracy on training data itself, this is called Underfiiting.

A good Model should be free from both Underfitting and Overfitting. You might be having a question about what does high error on training data means. So you train your model using training data and when your model is trained we first check whether our model is able to give exact output for the data which we feed it for the training, if not then means we have high error on training data itself. How it will give good results on testing data which is totally new. Such a model is of no use!

6. Type of Learning Algorithms

So Next comes another important concept that is what type of Learning Algorithm we are using. There are two types of Algorithms

Parametric Learning Learning Algorithm: In this algorithm, e need training Data only one time, once the l is trained we don't need it while predicting. In such types of models, earning is slow, but prediction is fast.

Non-Parametric Algorithm: In this Algorithm, e rely on Training data all the time. When we have to make a prediction we need training data again. In such models Learning is fast but Prediction is slow.

7. Feature Engineering/Extraction

Another main part of machine learning is feature extraction. When we get a dataset we might have a lot of columns and some columns/Features may be of no use. Such features can act as noise and may hamper model training and ultimately resulting in bad accuracy or high error. Feature Engineering provides us with some techniques to find the right set of features on which our model will give high accuracy. Some of the methods are:

Principle Components Analysis (PCA)

Independent Component Analysis (ICA)

Linear Discriminant Analysis (LDA)

Wrapper Method

Filter Methods

8. Models

Now, let's understand what are models. So basically models as I told earlier are some kind of mathematical functions. Y=mx+c is a model called Linear Regression. Same way we have many mathematical functions or models to help us predict things. Our aim is we need to understand which model to use where and how we can improve that. You might be thinking whether we have to write those functions again and again when we have train things. You can but it is not necessary. Python has a great Library called scikit-learn which contains almost all kinds of models. You just need to import those and you are good to go.

Models in Machine Learning:

Linear Regression Model

Logistic Regression Model

Decision Trees

KNN

Random Forest

AdaBoost

GradientBoost

SVM

This was a quick overview of machine learning that will help you kickstart the Learning Journey. The Detailed blog on Each topic will be out soon!!!