Update app.py
Browse files12341234510116137891017181112132214151610 unmodified lines2728293930313233344435464736373849505139# Import librariespip install pandas numpy scikit-learn gradio!pip install gradio scikit-learn pandas numpy
import pandas as pdimport numpy as npimport gradio as grfrom sklearn.preprocessing import LabelEncoderfrom sklearn.ensemble import RandomForestClassifierfrom sklearn.compose import ColumnTransformerfrom sklearn.pipeline import Pipeline
# Your existing data loading and preprocessing code# Load your model and data preprocessing code here# ...
def predict_program(*args): """Function to process inputs and return prediction""" # Create dictionary from inputs input_dict = {col: [val] for col, val in zip(X.columns, args)} input_df = pd.DataFrame(input_dict) # Predict try: prediction_encoded = model.predict(input_df) prediction = label_encoder.inverse_transform(prediction_encoded)10 unmodified lines inputs.append(gr.Textbox(label=feature))
# Launch interfaceinterface = gr.Interface(gr.Interface( fn=predict_program, inputs=inputs, outputs="text", title="MHIS Student Program Predictor", description="Enter student details to predict their academic program", examples=[ [80083, 3.8, "10", "35", "Perennialism"], # Example 1 [20229, 4.2, "2", "95", "Progressivism"] # Example 2 [80083, 3.8, "10", "35", "Perennialism"], [20229, 4.2, "2", "95", "Progressivism"] ])
interface.launch()).launch()app.py+5-17