-
Notifications
You must be signed in to change notification settings - Fork 0
/
tester.py
48 lines (41 loc) · 998 Bytes
/
tester.py
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
import pandas as pd
import requests
import time
import random
import sys
import json
df = pd.read_csv(
"./jupyter/notebooks/test.csv",
header=0
)
# Iterate over every row and send request to model
percentage_chance = 0.25
for _, row in df.iterrows():
payload = {
"feature_vector": row.values.tolist(),
"score": False
}
if random.random() < percentage_chance:
payload["score"] = True
print(payload)
try:
response = requests.post(
"http://localhost:8000/prediction",
json=payload
)
response.raise_for_status()
except Exception as err:
print(f"An error has occurred: {err}")
else:
print("Success!")
time.sleep(0.05)
# Get the model hyperparameters
try:
response = requests.get(
"http://localhost:8000/model_information"
)
response.raise_for_status()
except Exception as err:
print(f"An error has occurred: {err}")
else:
print("Success!")