This repository contains a Python script that demonstrates how to fit a polynomial model to a given dataset and use it for predicting test scores based on the number of hours spent studying.
The following Python packages are required:
- NumPy
- Matplotlib
- scikit-learn
To install the required packages, run:
pip install numpy matplotlib scikit-learn
or
pip install -r requirements.txt
- Clone this repository
git clone https://github.com/codecaine-zz/polynomial_fit.git
- navigate project folder
cd polynomial_fit
- run script
python polynomial_fit.py
The script will output an R2 score and a predicted test score for a given number of hours spent studying. It will also generate a plot showing the original data and the fitted polynomial curve.
In this example, we have a dataset of hours spent studying and the corresponding test scores:
- x: Hours spent studying
- y: Test scores
The script fits a polynomial model to the data, plots the data with the fitted line, and predicts the test score for a given number of hours spent studying. The R2 score is calculated to evaluate the model's performance.