Spaces:
Build error
Build error
Upload 4 files
Browse files- app.py +50 -0
- data.csv +26 -0
- eda_plot.png +0 -0
- requirements.txt +6 -0
app.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import numpy as np
|
| 3 |
+
import streamlit as st
|
| 4 |
+
import seaborn as sns
|
| 5 |
+
import matplotlib.pyplot as plt
|
| 6 |
+
from sklearn.linear_model import LinearRegression
|
| 7 |
+
from sklearn.model_selection import train_test_split
|
| 8 |
+
from sklearn.metrics import mean_squared_error, r2_score
|
| 9 |
+
|
| 10 |
+
# Load the data
|
| 11 |
+
data = pd.read_csv('data.csv')
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# Train the linear regression model
|
| 15 |
+
X = data['Hours'].values.reshape(-1, 1)
|
| 16 |
+
y = data['Scores'].values.reshape(-1, 1)
|
| 17 |
+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
| 18 |
+
|
| 19 |
+
model = LinearRegression()
|
| 20 |
+
model.fit(X_train, y_train)
|
| 21 |
+
|
| 22 |
+
# Make predictions
|
| 23 |
+
y_pred = model.predict(X_test)
|
| 24 |
+
|
| 25 |
+
# Compute metrics
|
| 26 |
+
mse = mean_squared_error(y_test, y_pred)
|
| 27 |
+
r2 = r2_score(y_test, y_pred)
|
| 28 |
+
|
| 29 |
+
# Create the web app
|
| 30 |
+
st.title('Student Score Prediction')
|
| 31 |
+
st.write('Enter the number of study hours:')
|
| 32 |
+
hours = st.number_input('', min_value=0, max_value=24, step=1)
|
| 33 |
+
score = int(model.predict([[hours]]))
|
| 34 |
+
if score > 100:
|
| 35 |
+
score = 100
|
| 36 |
+
|
| 37 |
+
st.write(f'Predicted Score: {score} Marks if he studies {hours} hours')
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
# Perform EDA
|
| 41 |
+
# st.title('Exploratory Data Analysis')
|
| 42 |
+
# st.write('Data Summary:')
|
| 43 |
+
# st.write(data.describe())
|
| 44 |
+
|
| 45 |
+
st.write('Scatter Plot:')
|
| 46 |
+
fig, ax = plt.subplots(figsize=(10, 6))
|
| 47 |
+
sns.scatterplot(data=data, x='Hours', y='Scores')
|
| 48 |
+
plt.xlabel('Hours')
|
| 49 |
+
plt.ylabel('Scores')
|
| 50 |
+
st.pyplot(fig)
|
data.csv
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Hours,Scores
|
| 2 |
+
2.5,21
|
| 3 |
+
5.1,47
|
| 4 |
+
3.2,27
|
| 5 |
+
8.5,75
|
| 6 |
+
3.5,30
|
| 7 |
+
1.5,20
|
| 8 |
+
9.2,88
|
| 9 |
+
5.5,60
|
| 10 |
+
8.3,81
|
| 11 |
+
2.7,25
|
| 12 |
+
7.7,85
|
| 13 |
+
5.9,62
|
| 14 |
+
4.5,41
|
| 15 |
+
3.3,42
|
| 16 |
+
1.1,17
|
| 17 |
+
8.9,95
|
| 18 |
+
2.5,30
|
| 19 |
+
1.9,24
|
| 20 |
+
6.1,67
|
| 21 |
+
7.4,69
|
| 22 |
+
2.7,30
|
| 23 |
+
4.8,54
|
| 24 |
+
3.8,35
|
| 25 |
+
6.9,76
|
| 26 |
+
7.8,86
|
eda_plot.png
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
pandas
|
| 3 |
+
numpy
|
| 4 |
+
seaborn
|
| 5 |
+
matplotlib
|
| 6 |
+
scikit-learn
|