File size: 1,247 Bytes
50f3b8d
7a2af10
50f3b8d
5aee938
50f3b8d
 
5aee938
50f3b8d
 
 
 
5aee938
 
50f3b8d
 
 
 
4277877
50f3b8d
7a2af10
4277877
 
 
 
 
 
 
 
 
 
 
7a2af10
4277877
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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):
    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

# Define the interface
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
)

# Define the callable object for inference
model = interface