Sitemap

Getting Started with Machine Learning

5 min readApr 22, 2022

--

Press enter or click to view image in full size
source

Machine Learning is the science (and art) of programming computers so they can learn from data. (Aurélien Géron)

Variable Types

  • Numeric Variables (float, string)

Such as age, square meter, price, length, etc.

  • Categorical Variables (nominal, ordinal)

We can see it either ordered or unordered, such as survival, classes, gender

  • Dependent variable (target, dependent, output, response)

The target variable in the problem we are dealing with is called the dependent variable. Since we usually know the target of the problem we are working on, we do not try to find our dependent variable separately, we know it.

  • Independent variable (feature, independent, input, column, predictor, explanatory)

These are the variables that we assume to have an effect on the formation of the target.

Learning Types

  • Supervised Learning

If there are labels in the dataset, it is called supervised learning. It is mainly used for classification problems. It is the learning type where the dependent variable/target variable exists. The relationship between dependent and independent variables is learned.

  • Unsupervised Learning

It is a learning method where there are no labels/targets in the dataset. It is a learning method in which there is no dependent variable and the features are classified within themselves.

  • Reinforcement Learning

To understand this, we can think of any machine trying to achieve a goal by trial and error. For example, a robot trying to hold a glass, a drone learning what to do in the face of an obstacle by trial and error is called reinforcement learning.

Types of Problems

  • Regression Problems

The problem where the dependent variable is numeric.

  • Classification Problems

Problems where the dependent variable is categorical.

Model Success Evaluation Problems

In Regression Models

In regression models, measurement problems based on the basic logic of measuring the distance of the predicted values ​​from the actual values ​​are used. In this sense, the most commonly used formulas can be counted as Mean Squared Error, Root Mean Squared Error, and Mean Absolute Error.

  • Mean Squared Error (MSE)
  • Root Mean Squared Error (RMSE)
  • Mean Absolute Error (MAE)

The smaller these values, the better the prediction success.

In Classification Models

In classification problems, the predicted classes are compared with the actual classes. In its simplest form, the accuracy score is obtained by dividing the correctly predicted classes by the number of classifications in the accuracy score method.

  • Accuracy Score = number of correct classification/total number of classified observations

Model Validation

Model validation is the method applied to reduce the margin of error of the success evaluation measurements, which we have seen in the example above.

Get Mehmet Ali Akkın’s stories in your inbox

Join Medium for free to get updates from this writer.

While performing machine learning on any data, the basic criterion here is to distinguish on which part of the dataset the learning will be made and on which part this learning will be tested.

The main mistake to be made here would be to make the learning set and the train set over the original dataset, which we did not apply division. In such an application, since the dataset learned by the model and the dataset, it is tested with will be the same, the validity of the test will raise question marks. There are two methods used to prevent this.

Holdout Method

Holdout Method

The original dataset is split into train and test. The learning process is done on the train set and the created model is tested on the test set. The holdout method can be easily used in datasets of sufficient size. In datasets with a low number of observations, biases may occur.

Since we randomly divide the train and test set, an undesired bias may occur in the test set and our model may not work properly. To prevent this, the cross-validation method is used.

k-Fold Cross-Validation Method

In order to prevent biases that may arise in insufficient data, cross-validation can be applied. Cross-validation appears in two different ways.

In the first use, the train set is divided into five as seen below. Of the five parts here, four are modeled and tested on one. By changing the test set, all parts are used as a test set once. After the cross-validation with the parts created on the train set, we test the model with the original test set and measure our model accuracy.

k-Fold Cross-Validation on train set

In this method, bias may not have been avoided since our final test was performed on the test data in the first section. For this reason, when the size of our dataset is small, it can be considered safer to perform cross-validation on the whole data.

k-Fold Cross-Validation on the full dataset

Overfitting and Underfitting the Training Data

There are two other challenges of training a model; overfitting, and underfitting.

Press enter or click to view image in full size
source

We can think of overfitting like we met someone from a country and then generalize his/her features to all of the people from that country. In other words, it can be assumed as our model performs well on the train set but it cannot generalize well.

Underfitting is the opposite of overfitting. Overfitting emerges when our model is too simple to learn the structure of the data.

In this writing, I tried to summarize what I learned from the DS&ML Bootcamp of Miuul. I hope it was useful.

Do not hesitate to write if you have questions to ask or criticisms you want to add… 🤙🏻

References

Géron, Aurélien. 2019. “Hands-on Machine Learning with Scikit-Learn, Keras, and TensorFlow,” 851.

--

--