# make_regression() function in sklearn with Python

In this tutorial, we will learn about make_regression() function in sklearn with Python. So, before starting let us see what we are going to do exactly.

There are many datasets available such as for classification and regression problems. Here our task is to generate one of such dataset i.e. linear regression dataset. Before jumping to the main topic let us have a brief introduction to basic terminologies.

**Scikit learn**

It is one of the most popular Machine learning library. Using it we can write any Machine learning code in a couple of lines. You can learn more about it hereĀ How to Make Predictions with scikit-learn in Python

## make_regression() function in scikit learn

It is a function in *sklearn_datasetsĀ *which is used to generate our dataset for the regression problem. It is described in the code in python below.

**Code in Python programming language**

We will write this code in google colab.

from sklearn.datasets import make_regression from matplotlib import pyplot X_test, y_test = make_regression(n_samples=150, n_features=1, noise=0.2) pyplot.scatter(X_test,y_test) pyplot.show()

#### Output:

Initially, we imported the required library. After that, we made a dataset using *make_regression().* Then using *matplotlib* we plotted our plot as you can see in the above figure. Further, one thing to notice here is that we have made a dataset of **150 entries** and with **noise 0.** However, we can change these values as I have demonstrated below.

For example, In the above two figures, you can observe that as the noise increased from 10 to 50 our dataset become more scattered. That’s it! We have successfully generated our dataset.

## Leave a Reply