import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, confusion_matrix
# 1. Load Data
data = pd.read_csv("tiu_data.csv") # your file
# 2. Features and Target
X = data[['study_hours']] # input
y = data['passed'] # output
# 3. Train-Test Split
# Assuming random_state=42 for reproducibility since it was cut off
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
# 4. Model Training
model = LogisticRegression()
model.fit(X_train, y_train)
# 5. Make Predictions
y_pred = model.predict(X_test)
# 6. Evaluate Model
accuracy = accuracy_score(y_test, y_pred)
# One new study hour value
new_study_hour = [[4.5]]
# Predit pass/fall (0 or 1)
prediction = model.predict(new_study_hour)
# Print prediction
print(f"Accuracy: {accuracy * 100:.2f}%")
print("Prediction for 4.5 study hours:", prediction)1 views