# Baseline : Random Prediction Algorithm

//Baseline : Random Prediction Algorithm

## Baseline : Random Prediction Algorithm

It is important to establish baseline performance on a predictive modeling problem. A baseline provides a point of comparison for the more advanced methods that you evaluate later.

In this tutorial, you will discover how to implement baseline machine learning algorithms from scratch in Python.

After completing this tutorial, you will know:

• How to implement the random prediction algorithm.
• How to implement the zero rule prediction algorithm.

The random prediction algorithm predicts a random outcome as observed in the training data. It is perhaps the simplest algorithm to implement.

It requires that you store all of the distinct outcome values in the training data, which could be large on regression problems with lots of distinct values.

Because random numbers are used to make decisions, it is a good idea to fix the random number seed prior to using the algorithm. This is to ensure that we get the same set of random numbers, and in turn the same decisions each time the algorithm is run.

Below is an implementation of the Random Prediction Algorithm in a function named random_algorithm().

The function takes both a training dataset that includes output values and a test dataset for which output values must be predicted.

The function will work for both classification and regression problems. It assumes that the output value in the training data is the final column for each row.

First, the set of unique output values is collected from the training data. Then a randomly selected output value from the set is selected for each row in the test set.

We can test this function with a small dataset that only contains the output column for simplicity.

The output values in the training dataset are either “0” or “1”, meaning that the set of predictions the algorithm will choose from is {0, 1}. The test set also contains a single column, with no data as the predictions are not known.

Running the example calculates random predictions for the test dataset and prints those predictions.

The random prediction algorithm is easy to implement and fast to run, but we could do better as a baseline.

Reference: www.machinelearningmastery.com

By |2020-12-06T10:04:48+03:306th December, 2020|Categories: ML knowledge|0 Comments

### About the Author: Masoomeh Gh-Farahani An interested and active person in the field of data science and molecular dynamics simulation
Hi, welcome to Simulatoran
Send via WhatsApp