Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Study Hours Score Predictor

A simple machine learning web app built with Streamlit that predicts a student's exam score based on the number of hours they studied — powered by Linear Regression.


Demo

Enter the number of hours you studied (0–9), hit Submit, and the model will predict your exam score.


How It Works

  1. Loads a CSV dataset (Hours_and_Scores.csv) containing study hours and corresponding exam scores.
  2. Trains a Linear Regression model on 75% of the data.
  3. Uses the trained model to predict a score from user input.
  4. Clamps the output between 0 and 100 to keep it realistic.

Project Structure

project/
│
├── data/
│   └── Hours_and_Scores.csv   # Dataset with Hours and Scores columns
│
├── app.py                     # Main Streamlit application
└── README.md

Requirements

Install the dependencies with:

pip install pandas numpy streamlit plotly scikit-learn

Or if you have a requirements.txt:

pip install -r requirements.txt

requirements.txt

pandas
numpy
streamlit
plotly
scikit-learn

Running the App

streamlit run app.py

Then open your browser at http://localhost:8501.


Dataset

The dataset (Hours_and_Scores.csv) should have the following structure:

Hours Scores
2.5 21
5.1 47
3.2 27
... ...
  • Hours — Number of hours studied
  • Scores — Exam score achieved (0–100)

The dataset contains 25 samples and is split 75/25 for training and testing.


Model Details

Property Value
Algorithm Linear Regression
Library scikit-learn
Train/Test Split 75% / 25%
Feature Scaling Not applied*
Input Range 0 – 9 hours
Output Range 0 – 100 (clamped)

*Feature scaling (StandardScaler) is not needed for Linear Regression and has been intentionally left out.


Built With


Notes

  • The model is retrained every time the app starts (no model persistence).
  • Since train_test_split uses a random seed by default, results may vary slightly between runs. Add random_state=42 for reproducibility:
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)

🙋 Author

NFlux

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages