Generating data for Linear Regression using NumPy

We have already seen how to generate random numbers in previous article, here we will have a look at how to generate data in specific format for linear regression.

To test data for linear regression, we will need a data which has somewhat linear relationship and one set of random data.  Please find below code to generate data having some linear relation and random data using Python and NumPy. I have provided graphs which will help you understand the data created by using these programs.

Data with Linear Trend for Linear Regression

https://gist.github.com/conquistadorjd/4b72e67fdf4a6627f422786bce2928eb#file-numpy_data_linear-py

Data without any Trend for Linear Regression

https://gist.github.com/conquistadorjd/4b72e67fdf4a6627f422786bce2928eb#file-numpy_data_random_01-py

You can use this as an input data while training your model.

CategoriesUncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *