import pickle from sklearn.linear_model import LogisticRegression import gradio as gr import numpy as np with open('logreg_model.pkl', "rb") as file: loaded_model = pickle.load(file) with open('scaler.pkl', 'rb') as file2: loaded_scaler = pickle.load(file2) def predict_admission(gre_score, toefl_score, university_rating, sop, lor, cgpa, research, threshold=0.5): # Convert 'Yes'/'No' to 1/0 for the 'Research' field research = 1 if research == "Yes" else 0 # Scale the new input data: input_data = loaded_scaler.transform([[gre_score, toefl_score, university_rating, sop, lor, cgpa]]) # Create an input array from the provided values input_data = [np.append(np.append(np.array([[1.]]),input_data),research)] # Added a 1 for the intercept and research # Make a prediction prediction_probability = loaded_model.predict(input_data)[0] prediction = 'Admit' if prediction_probability >= threshold else 'No Admit' # Custom formatting for output prediction_color = "green" if prediction == 'Admit' else "red" result = f"