Spaces:
Sleeping
Sleeping
File size: 2,080 Bytes
173ba95 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | import requests
import json
import pandas as pd
### Test preview endpoint
def test_preview():
print("###test_preview###")
r = requests.get("")
response = r.json()
print(pd.DataFrame(response))
test_preview()
### Test uniquevalues endpoint
def test_uniquevalues():
print("###test_uniquevalues###")
payload = {"column": "model_key"}
r = requests.get("", params=payload)
response = r.json()
print(response)
test_uniquevalues()
### Test groupby endpoint
def test_groupby():
print("###test_groupby###")
payload = {"column": "model_key", "by_method": "mean"}
r = requests.post("", json=payload)
response = r.json()
print(pd.DataFrame(response))
test_groupby()
### Test filter-by endpoint
def test_filterBy():
print("###test_filterBy###")
payload = {
"column": "paint_color",
"by_category": ["black", "grey"],
}
r = requests.post("", json=payload)
response = r.json()
print(pd.DataFrame(response))
test_filterBy()
#### Test ML Model
def test_prediction():
print("###test_prediction###")
payload = {
"model_key": "Peugeot",
"mileage": 139000,
"engine_power": 135,
"fuel": "diesel",
"paint_color": "blue",
"car_type": "convertible",
"private_parking_available": True,
"has_gps": True,
"has_air_conditioning": True,
"automatic_car": True,
"has_getaround_connect": True,
"has_speed_regulator": True,
"winter_tires": True
}
r = requests.post("", json=payload)
response = r.json()
print(round(response["prediction"], 2))
test_prediction()
#### Test batch pred
def test_batch():
print("###test_batchprediction###")
df = pd.read_csv("https://full-stack-assets.s3.eu-west-3.amazonaws.com/Deployment/get_around_pricing_project.csv", index_col=0)
df = df.iloc[:, :-1]
myfile = df.to_csv(index=False)
r = requests.post("", files={"file": myfile})
response = r.json()
print(pd.DataFrame(response))
test_batch() |