rustat-python-api 0.3.4__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rustat-python-api-0.3.4/rustat_python_api.egg-info → rustat-python-api-0.4.1}/PKG-INFO +1 -1
- rustat-python-api-0.4.1/rustat_python_api/__init__.py +4 -0
- rustat-python-api-0.4.1/rustat_python_api/models_api.py +58 -0
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1/rustat_python_api.egg-info}/PKG-INFO +1 -1
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/rustat_python_api.egg-info/SOURCES.txt +1 -0
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/setup.py +1 -1
- rustat-python-api-0.3.4/rustat_python_api/__init__.py +0 -3
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/LICENSE +0 -0
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/README.md +0 -0
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/pyproject.toml +0 -0
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/rustat_python_api/config.py +0 -0
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/rustat_python_api/parser.py +0 -0
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/rustat_python_api/processing.py +0 -0
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/rustat_python_api/urls.py +0 -0
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/rustat_python_api.egg-info/dependency_links.txt +0 -0
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/rustat_python_api.egg-info/requires.txt +0 -0
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/rustat_python_api.egg-info/top_level.txt +0 -0
- {rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/setup.cfg +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import numpy as np
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DynamoLab:
|
|
7
|
+
def __init__(self, host: str = "http://localhost:8000/"):
|
|
8
|
+
self.host = host
|
|
9
|
+
|
|
10
|
+
def get_active_models(self):
|
|
11
|
+
url = self.host + "models"
|
|
12
|
+
response = requests.get(url)
|
|
13
|
+
return response.json()
|
|
14
|
+
|
|
15
|
+
def run_model(
|
|
16
|
+
self,
|
|
17
|
+
model: str,
|
|
18
|
+
data: pd.DataFrame,
|
|
19
|
+
return_type: str = "json",
|
|
20
|
+
inplace: bool = False,
|
|
21
|
+
return_df: bool = False,
|
|
22
|
+
inplace_column: str = None
|
|
23
|
+
):
|
|
24
|
+
"""
|
|
25
|
+
model: str
|
|
26
|
+
The name of the model to run
|
|
27
|
+
return_type: str
|
|
28
|
+
One of: "json", "list", "numpy"
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
url = self.host + "predict"
|
|
32
|
+
csv_string = data.to_csv(index=False)
|
|
33
|
+
|
|
34
|
+
body = {
|
|
35
|
+
"model": model,
|
|
36
|
+
"data": csv_string,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
response = requests.post(url, json=body)
|
|
40
|
+
|
|
41
|
+
if return_df or inplace:
|
|
42
|
+
if inplace_column is None:
|
|
43
|
+
raise ValueError("inplace_column must be specified if inplace is True")
|
|
44
|
+
if inplace:
|
|
45
|
+
data[inplace_column] = response.json()["prediction"]
|
|
46
|
+
if df:
|
|
47
|
+
df = data.copy()
|
|
48
|
+
df[inplace_column] = response.json()["prediction"]
|
|
49
|
+
return df
|
|
50
|
+
|
|
51
|
+
if return_type == "json":
|
|
52
|
+
return response.json()
|
|
53
|
+
elif return_type == "list":
|
|
54
|
+
return response.json()["prediction"]
|
|
55
|
+
elif return_type == "numpy":
|
|
56
|
+
return np.array(response.json()["prediction"])
|
|
57
|
+
else:
|
|
58
|
+
raise ValueError("return_type must be one of: json, list, numpy")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/rustat_python_api.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{rustat-python-api-0.3.4 → rustat-python-api-0.4.1}/rustat_python_api.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|