-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_prediction_api.py
More file actions
88 lines (83 loc) · 3 KB
/
test_prediction_api.py
File metadata and controls
88 lines (83 loc) · 3 KB
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
import requests
import json
def test_prediction():
url = "http://localhost:8000/api/model/predict-with-composite"
# Healthy case features from our CSV
payload = {
"features": {
"total_assets": 10000000,
"net_worth": 6000000,
"total_liabilities": 4000000,
"reserves_and_funds": 2000000,
"borrowings": 1000000,
"current_liabilities": 2000000,
"deferred_tax_liability": 100000,
"shareholders_funds": 5000000,
"cumulative_retained_profits": 3000000,
"total_capital": 5000000,
"capital_employed": 8000000,
"contingent_liabilities": 500000,
"net_fixed_assets": 4000000,
"investments": 1000000,
"current_assets": 5000000,
"net_working_capital": 3000000,
"log_total_assets": 16.11,
"total_income": 20000000,
"sales": 18000000,
"income_financial_services": 500000,
"other_income": 1500000,
"change_in_stock": 0,
"total_expenses": 15000000,
"profit_after_tax": 3500000,
"pbdita": 5000000,
"pbt": 4500000,
"cash_profit": 4000000,
"pbdita_pct_income": 25.0,
"pbt_pct_income": 22.5,
"pat_pct_income": 17.5,
"cash_profit_pct_income": 20.0,
"pat_pct_networth": 58.33,
"pat_to_assets": 0.35,
"pbdita_to_assets": 0.5,
"pat_to_sales": 0.19,
"pbdita_to_sales": 0.27,
"debt_to_equity": 0.16,
"tol_to_tnw": 0.66,
"term_liabilities_to_tnw": 0.1,
"contingent_liab_pct_networth": 5.0,
"borrowings_to_assets": 0.1,
"liabilities_to_assets": 0.4,
"current_ratio": 2.5,
"quick_ratio": 2.0,
"cash_to_cur_liabilities": 0.5,
"cash_to_cost_per_day": 30.0,
"creditors_turnover": 12.0,
"debtors_turnover": 8.0,
"finished_goods_turnover": 15.0,
"wip_turnover": 10.0,
"raw_material_turnover": 15.0,
"altman_z": 4.5,
"ohlson_prob": 0.01,
"fin_services_pct_income": 0.025,
"other_income_pct": 0.075
},
"ml_pd": 0.02,
"company_name": "Test Healthy Corp"
}
# Wait, CompositeScoreRequest requires ml_pd
# class CompositeScoreRequest(BaseModel):
# features: Dict[str, float]
# ml_pd: float
# company_name: Optional[str]
try:
# Pydantic schema expects features, ml_pd, company_name
response = requests.post(url, json=payload)
print(f"Status: {response.status_code}")
try:
print(f"Response: {json.dumps(response.json(), indent=2)}")
except:
print(f"Raw Response: {response.text}")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
test_prediction()