|
import gradio as gr |
|
import joblib |
|
import numpy as np |
|
|
|
|
|
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'), |
|
} |
|
|
|
|
|
def predict(user_input): |
|
user_input_array = np.array(user_input).reshape(1, -1) |
|
user_input_scaled = scaler.transform(user_input_array) |
|
predictions = {target: model.predict(user_input_scaled)[0] for target, model in models.items()} |
|
return predictions |
|
|
|
|
|
interface = gr.Interface( |
|
fn=predict, |
|
inputs=gr.Dataframe(type="numpy", row_count=1, col_count=12, |
|
headers=["course overview", "reading file", "abstract materiale", |
|
"concrete material", "visual materials", "self-assessment", |
|
"exercises submit", "quiz submitted", "playing", "paused", |
|
"unstarted", "buffering"]), |
|
outputs=gr.JSON(), |
|
live=True |
|
) |
|
|
|
|
|
model = interface |
|
|