This program implements linear regression with polynomial features using the sklearn library in Python. The program uses a training set of data and plots a prediction using the Linear Regression model.
The following libraries are required to run the program:
- Python
- numpy
- matplotlib
- sklearn
The program uses two sets of data for bluegill fish - training set and testing set.
- The training set consists of 10 data points with age of bluegill in years and its corresponding length in millimeters.
- The testing set consists of 10 data points with age of bluegill in years and its corresponding length in millimeters.
The program performs the following operations:
- Trains a Linear Regression model using the training set data.
- Sets the degree of the polynomial regression model.
- Transforms the input data matrix into a new data matrix of a given degree using the PolynomialFeatures preprocessor.
- Trains and tests the polynomial regression model.
- Plots a graph of the training data and the prediction using the linear and polynomial regression models.
This program demonstrates the use of polynomial features in linear regression using the sklearn library. The program trains and tests the polynomial regression model and plots a graph to visualize the results.