This project demonstrates how to implement Linear Regression manually using Python and deploy it as an interactive web app using Streamlit.
The model predicts a person's salary based on their years of experience.
Build a salary prediction model from scratch using gradient descent and deploy it using Streamlit to make real-time predictions based on user input.
- LinearRegressionFromScratch.ipynb # Jupyter notebook for training the model
- app.py # Streamlit app for interactive predictions
- Salary_Data.csv # Dataset
- README.md # Project documentation
The dataset includes:
YearsExperience: Number of years in the workforceSalary: Annual salary in USD
It's a dataset used to illustrate linear regression.
- Equation used:
y = m * x + b - Parameters
m(slope) andb(intercept) are learned using Gradient Descent - Mean Squared Error (MSE) is used as the loss function
- Outputs a trained model with optimized weights
- Users enter Years of Experience
- Model predicts and displays the Estimated Salary
- Uses the trained values of
mandbdirectly
-
Install dependencies:
pip install streamlit numpy pandas matplotlib
-
Start the app:
streamlit run app.py
-
Install packages:
!pip install streamlit pyngrok
-
Run and expose Streamlit app:
from pyngrok import ngrok # Kill existing sessions !pkill streamlit # Start app get_ipython().system_raw('streamlit run app.py &') # Create public URL public_url = ngrok.connect("http://localhost:8501") public_url
Click the Predict Salaries to access your deployed app online.
| Years of Experience | Predicted Salary |
|---|---|
| 1.5 | $39,967.14 |
| 5.0 | $73,041.00 |
| 7.3 | $95,868.00 |
- Display evaluation metrics (RMSE, R²)
- Support multiple predictions from a CSV
streamlit
numpy
pandas
matplotlib
pyngrok
Install with:
pip install -r requirements.txtMade with ❤️ by Poojitha Ganta