import gradio as gr import joblib import numpy as np # Load the scaler and models scaler = joblib.load('scaler.joblib') models = { "processing": joblib.load('svm_model_processing.joblib'), "perception": joblib.load('svm_model_perception.joblib'), "input": joblib.load('svm_model_input.joblib'), "understanding": joblib.load('svm_model_understanding.joblib'), } # Define the prediction function def predict(user_input): # Ensure the input is in the same order as your model expects user_input_array = np.array(user_input).reshape(1, -1) # Scale the input using the saved scaler user_input_scaled = scaler.transform(user_input_array) # Predict outcomes for all target variables predictions = {} for target, model in models.items(): prediction = model.predict(user_input_scaled) predictions[target] = prediction[0] return predictions # Define Gradio interface interface = gr.Interface(fn=predict, inputs=gr.inputs.Dataframe(type="numpy", row_count=1, col_count=12, col_labels=['course overview', 'reading file', 'abstract materiale', 'concrete material', 'visual materials', 'self-assessment', 'exercises submit', 'quiz submitted', 'playing', 'paused', 'unstarted', 'buffering']), outputs=gr.outputs.JSON(), live=True) # Launch the interface interface.launch()