File size: 2,358 Bytes
012c745
 
 
 
 
3a272d0
 
 
 
 
 
 
ec67395
3a272d0
446a0a3
3a272d0
 
 
 
 
 
 
446a0a3
3a272d0
 
446a0a3
3a272d0
 
 
 
012c745
891a6cc
 
012c745
891a6cc
496787b
012c745
 
446a0a3
012c745
446a0a3
6fe55b9
 
012c745
 
891a6cc
012c745
 
891a6cc
6fe55b9
012c745
 
496787b
012c745
 
86b347f
ec67395
446a0a3
012c745
 
 
 
891a6cc
012c745
6fe55b9
891a6cc
 
 
 
 
 
e5bb869
 
 
 
 
 
 
6fe55b9
 
 
012c745
e5bb869
b1accee
 
446a0a3
012c745
 
 
 
b1accee
012c745
6fe55b9
b1accee
 
 
6fe55b9
012c745
e5bb869
3a272d0
012c745
446a0a3
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("https://marjg-getaround-api.hf.space/preview")

    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("https://marjg-getaround-api.hf.space/unique-values", 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("https://marjg-getaround-api.hf.space/groupby", 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("https://marjg-getaround-api.hf.space/filter-by", 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("https://marjg-getaround-api.hf.space/predict", 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("https://marjg-getaround-api.hf.space/batch-predict", files={"file": myfile})

    response = r.json()
    print(pd.DataFrame(response))

test_batch()