Machine Learning courses with 110+ Real-time projects Start Now!!
Program 1
# College Admission Eligibility Predictor Using Decision Tree
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score
# Data Set Load
df=pd.read_csv('admission_data1.csv')
# print(df.head())
# print(df.isnull().sum())
# Depended and Independed variables
X = df[['GPA', 'EntranceExamScore', 'Extracurriculars', 'VolunteerHours']]
y = df['Eligible']
# Split Dataset
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1)
# print(len(X_train))
# print(len(y_train))
# print(len(X_test))
# print(len(y_test))
# Model
model = DecisionTreeClassifier()
model.fit(X_train,y_train)
print(model)
# Accurracy
y_pred=model.predict(X_test)
print("Accuracy:", accuracy_score(y_test, y_pred))
# Predict new case
sample = [[3.6, 87, 1, 10]]
prediction = model.predict(sample)
print("\nPrediction for new student:", "Eligible" if prediction[0] == 1 else "Not Eligible")
Program 2
import tkinter as tk
from tkinter import messagebox
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
# Load and train
df = pd.read_csv("admission_data1.csv")
X = df[['GPA', 'EntranceExamScore', 'Extracurriculars', 'VolunteerHours']]
y = df['Eligible']
model = DecisionTreeClassifier()
model.fit(X, y)
# GUI App
def predict():
try:
gpa = float(entry_gpa.get())
score = int(entry_score.get())
extra = int(entry_extra.get())
hours = int(entry_hours.get())
result = model.predict([[gpa, score, extra, hours]])[0]
msg = "Eligible for Admission" if result == 1 else "Not Eligible"
messagebox.showinfo("Prediction", msg)
except:
messagebox.showerror("Error", "Please enter valid input values.")
app = tk.Tk()
app.title("College Admission Predictor")
app.geometry("350x300")
tk.Label(app, text="GPA (0.0 - 4.0)").pack()
entry_gpa = tk.Entry(app)
entry_gpa.pack()
tk.Label(app, text="Entrance Exam Score (0 - 100)").pack()
entry_score = tk.Entry(app)
entry_score.pack()
tk.Label(app, text="Extracurriculars (1=Yes, 0=No)").pack()
entry_extra = tk.Entry(app)
entry_extra.pack()
tk.Label(app, text="Volunteer Hours").pack()
entry_hours = tk.Entry(app)
entry_hours.pack()
tk.Button(app, text="Predict Eligibility", command=predict).pack(pady=10)
app.mainloop()