Spaces:
Running
Running
File size: 976 Bytes
b4f3263 1c1651d b4f3263 279839c b4f3263 84f0cff 279839c 1c1651d 7a92e6c 1c1651d b4f3263 469ec6b 782aa38 09418f5 469ec6b b4f3263 cacd064 |
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 |
import joblib
import numpy as np
import pandas as pd
from typing import List
class SecondaryModel:
def __init__(self):
self.scaler = joblib.load("scalers/secondary_scaler.joblib")
self.model = joblib.load("models/secondary_weights.joblib")
self.secondary_model_features = [
"machine_probability", "backspace_count_normalized",
"letter_discrepancy_normalized", "cosine_sim_gpt4o"
]
def preprocess_input(self, secondary_model_features: List[float]) -> pd.DataFrame:
features_df = pd.DataFrame(
[secondary_model_features], columns=self.secondary_model_features)
features_df[self.secondary_model_features] = self.scaler.transform(
features_df[self.secondary_model_features])
return features_df
def predict(self, secondary_model_features: List[float]) -> float:
return self.model.predict_proba(self.preprocess_input(secondary_model_features))[:, -1][0]
|