Spaces:
Running
Running
Commit
·
67bae95
1
Parent(s):
d5114e6
feat: add scalers and model weights
Browse files- hypothesis.py +2 -2
- main_model.py +1 -1
- models/albert_model.pth +3 -0
- models/random_forest.joblib +0 -0
- random_forest_model.py +2 -2
- requirements.txt +2 -1
- scalers/rf_scaler.joblib +0 -0
- scalers/scaler-normalized-text-length.joblib +0 -0
- scalers/scaler-not-normalized.joblib +0 -0
hypothesis.py
CHANGED
@@ -23,9 +23,9 @@ class BaseModelHypothesis:
|
|
23 |
self.features_not_normalized = []
|
24 |
|
25 |
self.scaler_normalized_text_length = joblib.load(
|
26 |
-
"scaler-normalized-text-length.joblib")
|
27 |
self.scaler_not_normalized = joblib.load(
|
28 |
-
"scaler-not-normalized.joblib")
|
29 |
|
30 |
def process_emotion_lexicon(self):
|
31 |
emotion_lexicon = {}
|
|
|
23 |
self.features_not_normalized = []
|
24 |
|
25 |
self.scaler_normalized_text_length = joblib.load(
|
26 |
+
"scalers/scaler-normalized-text-length.joblib")
|
27 |
self.scaler_not_normalized = joblib.load(
|
28 |
+
"scalers/scaler-not-normalized.joblib")
|
29 |
|
30 |
def process_emotion_lexicon(self):
|
31 |
emotion_lexicon = {}
|
main_model.py
CHANGED
@@ -50,7 +50,7 @@ class PredictMainModel:
|
|
50 |
self.model = AlbertCustomClassificationHead(
|
51 |
self.albert_model).to(self.device)
|
52 |
# TODO : CHANGE MODEL STATE DICT PATH
|
53 |
-
self.model.load_state_dict(torch.load("
|
54 |
|
55 |
def preprocess_input(self, text: str, additional_features: np.ndarray):
|
56 |
encoding = self.tokenizer.encode_plus(
|
|
|
50 |
self.model = AlbertCustomClassificationHead(
|
51 |
self.albert_model).to(self.device)
|
52 |
# TODO : CHANGE MODEL STATE DICT PATH
|
53 |
+
self.model.load_state_dict(torch.load("models/albert_model.pth"))
|
54 |
|
55 |
def preprocess_input(self, text: str, additional_features: np.ndarray):
|
56 |
encoding = self.tokenizer.encode_plus(
|
models/albert_model.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6b203b54caba10e290830cf720c8cd35093a358792e996ee04ee7d8e5e341651
|
3 |
+
size 70752187
|
models/random_forest.joblib
ADDED
Binary file (228 kB). View file
|
|
random_forest_model.py
CHANGED
@@ -5,8 +5,8 @@ from typing import List
|
|
5 |
|
6 |
class RandomForestModel:
|
7 |
def __init__(self):
|
8 |
-
self.scaler = joblib.load("rf_scaler.joblib")
|
9 |
-
self.model = joblib.load("random_forest.joblib")
|
10 |
|
11 |
def preprocess_input(self, secondary_model_features: List[float]) -> np.ndarray:
|
12 |
return self.scaler.transform(np.array(secondary_model_features).astype(np.float32).reshape(1, -1))
|
|
|
5 |
|
6 |
class RandomForestModel:
|
7 |
def __init__(self):
|
8 |
+
self.scaler = joblib.load("scalers/rf_scaler.joblib")
|
9 |
+
self.model = joblib.load("models/random_forest.joblib")
|
10 |
|
11 |
def preprocess_input(self, secondary_model_features: List[float]) -> np.ndarray:
|
12 |
return self.scaler.transform(np.array(secondary_model_features).astype(np.float32).reshape(1, -1))
|
requirements.txt
CHANGED
@@ -5,4 +5,5 @@ pandas
|
|
5 |
textstat
|
6 |
scikit-learn==1.4.1.post1
|
7 |
transformers
|
8 |
-
fastapi
|
|
|
|
5 |
textstat
|
6 |
scikit-learn==1.4.1.post1
|
7 |
transformers
|
8 |
+
fastapi
|
9 |
+
uvicorn
|
scalers/rf_scaler.joblib
ADDED
Binary file (1.17 kB). View file
|
|
scalers/scaler-normalized-text-length.joblib
ADDED
Binary file (1.85 kB). View file
|
|
scalers/scaler-not-normalized.joblib
ADDED
Binary file (1.17 kB). View file
|
|