-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Expand file tree
/
Copy pathMLpython.py
More file actions
38 lines (30 loc) · 945 Bytes
/
MLpython.py
File metadata and controls
38 lines (30 loc) · 945 Bytes
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
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
# Load dataset
data = pd.read_csv("dataset.csv")
X = data[['hours_study','sleep_hours','attendance']]
y = data['marks']
# Train model
model = LinearRegression()
model.fit(X, y)
print("=== AI Study Companion ===")
hours = float(input("Enter study hours: "))
sleep = float(input("Enter sleep hours: "))
attendance = float(input("Enter attendance %: "))
# Prediction
prediction = model.predict([[hours, sleep, attendance]])[0]
print(f"\n Predicted Marks: {prediction:.2f}")
# Smart Suggestions
if prediction < 50:
print("You need serious improvement. Increase study hours!")
elif prediction < 75:
print("You're doing okay. Stay consistent!")
else:
print("Excellent! Keep it up!")
# Graph
plt.scatter(data['hours_study'], data['marks'])
plt.xlabel("Study Hours")
plt.ylabel("Marks")
plt.title("Study Hours vs Marks")
plt.show()