Spaces:
Sleeping
Sleeping
modif app.py
Browse files
app.py
CHANGED
|
@@ -108,7 +108,7 @@ async def unique_values(column: str):
|
|
| 108 |
"""
|
| 109 |
df = pd.read_csv("https://full-stack-assets.s3.eu-west-3.amazonaws.com/Deployment/get_around_pricing_project.csv", index_col=0)
|
| 110 |
unique_vals = df[column].dropna().unique().tolist()
|
| 111 |
-
|
| 112 |
return unique_vals
|
| 113 |
|
| 114 |
|
|
@@ -150,7 +150,8 @@ async def group_by(groupBy: GroupBy):
|
|
| 150 |
if method == "count":
|
| 151 |
df = df.groupby(groupBy.column)[numeric_cols].count()
|
| 152 |
|
| 153 |
-
|
|
|
|
| 154 |
|
| 155 |
|
| 156 |
@app.get("/filter-by", tags=["Categorical"])
|
|
|
|
| 108 |
"""
|
| 109 |
df = pd.read_csv("https://full-stack-assets.s3.eu-west-3.amazonaws.com/Deployment/get_around_pricing_project.csv", index_col=0)
|
| 110 |
unique_vals = df[column].dropna().unique().tolist()
|
| 111 |
+
|
| 112 |
return unique_vals
|
| 113 |
|
| 114 |
|
|
|
|
| 150 |
if method == "count":
|
| 151 |
df = df.groupby(groupBy.column)[numeric_cols].count()
|
| 152 |
|
| 153 |
+
df = df.reset_index()
|
| 154 |
+
return df.to_json(orient="records")
|
| 155 |
|
| 156 |
|
| 157 |
@app.get("/filter-by", tags=["Categorical"])
|
test.py
CHANGED
|
@@ -12,7 +12,7 @@ def test_preview():
|
|
| 12 |
response = r.json()
|
| 13 |
print(pd.DataFrame(json.loads(response)))
|
| 14 |
|
| 15 |
-
|
| 16 |
|
| 17 |
|
| 18 |
### Test uniquevalues endpoint
|
|
@@ -20,10 +20,10 @@ def test_uniquevalues():
|
|
| 20 |
print("###test_uniquevalues###")
|
| 21 |
|
| 22 |
payload = {"column": "model_key"}
|
| 23 |
-
r = requests.get("https://marjg-getaround-api.hf.space/unique-values",
|
| 24 |
|
| 25 |
response = r.json()
|
| 26 |
-
print(
|
| 27 |
|
| 28 |
test_uniquevalues()
|
| 29 |
|
|
@@ -33,12 +33,12 @@ def test_groupby():
|
|
| 33 |
print("###test_groupby###")
|
| 34 |
|
| 35 |
payload = {"column": "model_key", "by_method": "mean"}
|
| 36 |
-
r = requests.get("https://marjg-getaround-api.hf.space/groupby",
|
| 37 |
|
| 38 |
response = r.json()
|
| 39 |
-
print(response)
|
| 40 |
|
| 41 |
-
|
| 42 |
|
| 43 |
|
| 44 |
### Test filter-by endpoint
|
|
@@ -50,12 +50,12 @@ def test_filterBy():
|
|
| 50 |
"by_category": ["black", "grey"],
|
| 51 |
}
|
| 52 |
|
| 53 |
-
r = requests.get("https://marjg-getaround-api.hf.space/filter-by",
|
| 54 |
|
| 55 |
response = r.json()
|
| 56 |
print(pd.read_json(response))
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
|
| 61 |
#### Test ML Model
|
|
@@ -83,7 +83,7 @@ def test_prediction():
|
|
| 83 |
response = r.json()
|
| 84 |
print(round(response["prediction"], 2))
|
| 85 |
|
| 86 |
-
|
| 87 |
|
| 88 |
|
| 89 |
#### Test batch pred
|
|
@@ -99,4 +99,4 @@ def test_batch():
|
|
| 99 |
response = r.json()
|
| 100 |
print(pd.DataFrame(response))
|
| 101 |
|
| 102 |
-
|
|
|
|
| 12 |
response = r.json()
|
| 13 |
print(pd.DataFrame(json.loads(response)))
|
| 14 |
|
| 15 |
+
test_preview()
|
| 16 |
|
| 17 |
|
| 18 |
### Test uniquevalues endpoint
|
|
|
|
| 20 |
print("###test_uniquevalues###")
|
| 21 |
|
| 22 |
payload = {"column": "model_key"}
|
| 23 |
+
r = requests.get("https://marjg-getaround-api.hf.space/unique-values", params=payload)
|
| 24 |
|
| 25 |
response = r.json()
|
| 26 |
+
print(response)
|
| 27 |
|
| 28 |
test_uniquevalues()
|
| 29 |
|
|
|
|
| 33 |
print("###test_groupby###")
|
| 34 |
|
| 35 |
payload = {"column": "model_key", "by_method": "mean"}
|
| 36 |
+
r = requests.get("https://marjg-getaround-api.hf.space/groupby", params=payload)
|
| 37 |
|
| 38 |
response = r.json()
|
| 39 |
+
print(pd.DataFrame(response))
|
| 40 |
|
| 41 |
+
test_groupby()
|
| 42 |
|
| 43 |
|
| 44 |
### Test filter-by endpoint
|
|
|
|
| 50 |
"by_category": ["black", "grey"],
|
| 51 |
}
|
| 52 |
|
| 53 |
+
r = requests.get("https://marjg-getaround-api.hf.space/filter-by", params=payload)
|
| 54 |
|
| 55 |
response = r.json()
|
| 56 |
print(pd.read_json(response))
|
| 57 |
|
| 58 |
+
test_filterBy()
|
| 59 |
|
| 60 |
|
| 61 |
#### Test ML Model
|
|
|
|
| 83 |
response = r.json()
|
| 84 |
print(round(response["prediction"], 2))
|
| 85 |
|
| 86 |
+
test_prediction()
|
| 87 |
|
| 88 |
|
| 89 |
#### Test batch pred
|
|
|
|
| 99 |
response = r.json()
|
| 100 |
print(pd.DataFrame(response))
|
| 101 |
|
| 102 |
+
test_batch()
|