File size: 1,350 Bytes
30ff7b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0e49dad
30ff7b3
0e49dad
 
30ff7b3
 
 
 
 
 
 
 
 
8f64240
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import pandas as pd
import numpy as np
import streamlit as st
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error, r2_score

# Load the data
data = pd.read_csv('data.csv')


# Train the linear regression model
X = data['Hours'].values.reshape(-1, 1)
y = data['Scores'].values.reshape(-1, 1)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

model = LinearRegression()
model.fit(X_train, y_train)

# Make predictions
y_pred = model.predict(X_test)

# Compute metrics
mse = mean_squared_error(y_test, y_pred)
r2 = r2_score(y_test, y_pred)

# Create the web app
st.title('Student Score Prediction')
st.write('Enter the number of study hours:')
hours = st.number_input('', min_value=0.00, max_value=24.00, step=0.1)
score = int(model.predict([[hours]]))
if score > 100.00:
    score = 100.00

st.write(f'Predicted Score: {score} Marks if he studies {hours} hours')


# Perform EDA
# st.title('Exploratory Data Analysis')
# st.write('Data Summary:')
# st.write(data.describe())

# st.write('Scatter Plot:')
# fig, ax = plt.subplots(figsize=(10, 6))
# sns.scatterplot(data=data, x='Hours', y='Scores')
# plt.xlabel('Hours')
# plt.ylabel('Scores')
# st.pyplot(fig)