added model and pipeline
Browse files- iris_model.pickle +3 -0
- pipeline.py +10 -14
iris_model.pickle
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:86a913ce4c1e18ca494ec94906f5b64f00d94365c977219cd85c40bb8479a4fc
|
| 3 |
+
size 1974
|
pipeline.py
CHANGED
|
@@ -1,19 +1,14 @@
|
|
| 1 |
from typing import Dict, List, Union
|
| 2 |
import os
|
|
|
|
|
|
|
| 3 |
|
| 4 |
class PreTrainedPipeline():
|
| 5 |
def __init__(self, path=""):
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
# For instance your model, processors, tokenizer that might be needed.
|
| 9 |
-
# This function is only called once, so do all the heavy processing I/O here"""
|
| 10 |
-
raise NotImplementedError(
|
| 11 |
-
"Please implement PreTrainedPipeline __init__ function"
|
| 12 |
-
)
|
| 13 |
|
| 14 |
-
def __call__(
|
| 15 |
-
self, inputs: Dict[str, Dict[str, List[Union[str, float]]]]
|
| 16 |
-
) -> List[Union[str, float]]:
|
| 17 |
"""
|
| 18 |
Args:
|
| 19 |
inputs (:obj:`dict`):
|
|
@@ -22,7 +17,8 @@ class PreTrainedPipeline():
|
|
| 22 |
Return:
|
| 23 |
A :obj:`list` of floats or strings: The classification output for each row.
|
| 24 |
"""
|
| 25 |
-
#
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
| 1 |
from typing import Dict, List, Union
|
| 2 |
import os
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import pickle
|
| 5 |
|
| 6 |
class PreTrainedPipeline():
|
| 7 |
def __init__(self, path=""):
|
| 8 |
+
with open('iris_model.pickle', 'rb') as f:
|
| 9 |
+
self.pipeline = pickle.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
def __call__(self, inputs):
|
|
|
|
|
|
|
| 12 |
"""
|
| 13 |
Args:
|
| 14 |
inputs (:obj:`dict`):
|
|
|
|
| 17 |
Return:
|
| 18 |
A :obj:`list` of floats or strings: The classification output for each row.
|
| 19 |
"""
|
| 20 |
+
# Convert the input dictionary to a pandas DataFrame
|
| 21 |
+
data = inputs['data'] # Extracting the 'data' dictionary
|
| 22 |
+
X = pd.DataFrame(data) # Converting 'data' dictionary to DataFrame
|
| 23 |
+
|
| 24 |
+
return self.pipeline.predict(X)
|