Spaces:
Runtime error
Runtime error
lyangas
commited on
Commit
·
e1eb682
1
Parent(s):
21367e1
add first code-by-group model
Browse files- app.py +1 -1
- classifiers/codes_in_groups/.test +0 -0
- classifiers/codes_in_groups/L82_code_clf.pkl +3 -0
- required_classes.py +31 -1
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import pickle
|
|
| 6 |
import numpy as np
|
| 7 |
import os
|
| 8 |
|
| 9 |
-
from required_classes import
|
| 10 |
|
| 11 |
|
| 12 |
CLS_WEIGHTS = {'mlp': 0.3, 'svc': 0.4, 'xgboost': 0.3}
|
|
|
|
| 6 |
import numpy as np
|
| 7 |
import os
|
| 8 |
|
| 9 |
+
from required_classes import *
|
| 10 |
|
| 11 |
|
| 12 |
CLS_WEIGHTS = {'mlp': 0.3, 'svc': 0.4, 'xgboost': 0.3}
|
classifiers/codes_in_groups/.test
DELETED
|
File without changes
|
classifiers/codes_in_groups/L82_code_clf.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:caaa8d9aee3aa4c349740be71f44ae034c36824b6fa9a765fa06dab88af265ea
|
| 3 |
+
size 327292
|
required_classes.py
CHANGED
|
@@ -71,4 +71,34 @@ class PredictModel:
|
|
| 71 |
if log:
|
| 72 |
print('Start classifier prediction')
|
| 73 |
prediction = self.classifier.predict(embeds)
|
| 74 |
-
return prediction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
if log:
|
| 72 |
print('Start classifier prediction')
|
| 73 |
prediction = self.classifier.predict(embeds)
|
| 74 |
+
return prediction
|
| 75 |
+
|
| 76 |
+
class CustomXGBoost:
|
| 77 |
+
def __init__(self):
|
| 78 |
+
self.model = xgb.XGBClassifier()
|
| 79 |
+
self.classes_ = None
|
| 80 |
+
|
| 81 |
+
def fit(self, X, y):
|
| 82 |
+
self.classes_ = np.unique(y).tolist()
|
| 83 |
+
y = [self.classes_.index(l) for l in y]
|
| 84 |
+
self.model.fit(X, y)
|
| 85 |
+
|
| 86 |
+
def predict_proba(self, X):
|
| 87 |
+
pred = self.model.predict_proba(X)
|
| 88 |
+
return pred
|
| 89 |
+
|
| 90 |
+
def predict(self, X):
|
| 91 |
+
preds = self.model.predict_proba(X)
|
| 92 |
+
print(np.argmax(preds, axis=1), self.classes_)
|
| 93 |
+
print(preds.shape, preds[:2])
|
| 94 |
+
return self.classes_[np.argmax(preds, axis=1)]
|
| 95 |
+
|
| 96 |
+
class SimpleModel:
|
| 97 |
+
def __init__(self):
|
| 98 |
+
self.classes_ = None
|
| 99 |
+
|
| 100 |
+
def fit(self, X, y):
|
| 101 |
+
self.classes_ = [y[0]]
|
| 102 |
+
|
| 103 |
+
def predict_proba(self, X):
|
| 104 |
+
return np.array([1.0])
|