This project demonstrates the implementation of Polynomial Regression from scratch using Python, Scikit-learn, and Plotly. It explores how polynomial features can be used to fit a linear model to non-linear data. The repository includes a Jupyter Notebook (polynomial-regression.ipynb) that walks through the entire process, from data generation to model evaluation and visualization.
The project is divided into two main parts:
- Data Generation: We start by generating synthetic data that follows a quadratic equation: (y = 0.8x^2 + 0.9x + 2).
- Simple Linear Regression: A simple linear regression model is first fitted to the data to show its limitations in capturing non-linear patterns.
- Polynomial Transformation:
PolynomialFeaturesfrom Scikit-learn is used to transform the input features into polynomial features of a specified degree. - Model Fitting: A linear regression model is then trained on these transformed features.
- Evaluation: The model's performance is evaluated using the R-squared (R²) metric, showing a significant improvement over the simple linear model.
- Visualization: The results are visualized using Matplotlib, plotting the original data points and the fitted polynomial curve.
Here is a glimpse of the 3D polynomial regression plot:
- Data Generation: Synthetic 3D data is generated using the equation: (z = x^2 + y^2 + 0.2x + 0.2y + 0.1xy + 2).
- 3D Visualization: The generated data is visualized using Plotly's 3D scatter plot.
- Model Fitting: A polynomial regression model is fitted to this 3D data.
- Surface Plotting: The fitted model is visualized as a surface plot using Plotly, showing how the model captures the underlying structure of the data.
- Clone the repository:
git clone https://github.com/your-username/CurveCraft.git
- Navigate to the project directory:
cd CurveCraft - Install the required dependencies:
pip install numpy matplotlib scikit-learn pandas plotly
- Aditya Sinha
This README was generated with the help of an AI assistant.
