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
Data without any Trend for Linear Regression
You can use this as an input data while training your model.