File size: 1,256 Bytes
82af12a 5aee938 7a2af10 5aee938 82af12a 5aee938 82af12a 5aee938 7a2af10 82af12a 7a2af10 82af12a 7a2af10 |
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 36 37 |
from typing import List, Dict
import pandas as pd
import numpy as np
import joblib
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"),
}
class Model:
def __init__(self):
self.scaler = scaler
self.models = models
def __call__(self, inputs: List[List[float]]) -> List[Dict[str, float]]:
feature_names = [
"course overview", "reading file", "abstract materiale",
"concrete material", "visual materials", "self-assessment",
"exercises submit", "quiz submitted", "playing", "paused",
"unstarted", "buffering"
]
outputs = []
for features in inputs:
input_df = pd.DataFrame([features], columns=feature_names)
scaled_input = self.scaler.transform(input_df)
predictions = {}
for target, model in self.models.items():
predictions[target] = model.predict(scaled_input)[0]
outputs.append(predictions)
return outputs
model = Model()
|