-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
91 lines (82 loc) · 2.51 KB
/
main.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
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
import requests
import json
from typing import List, Dict
# API base URL
BASE_URL = "http://localhost:8000"
# Create a model
def create_model():
data = {
"standard_template": ["CUSTOMER_NUMBER", "ACC_NO", "Case", "Customer_Name", "BKT_IS", "BKT_Was"],
"examples": [
{
"Act RIM": "CUSTOMER_NUMBER",
"APPLICATION ID": "ACC_NO",
"Case": "Case",
"CUST NAME": "Customer_Name",
"Is": "BKT_IS",
"Was": "BKT_Was"
},
{
"رقم القرض": "CUSTOMER_NUMBER",
"رقم حساب العميل": "ACC_NO",
"Case": "Case",
"اسم العميل": "Customer_Name",
"BKT": "BKT_IS",
"BKT": "BKT_Was"
}
],
"model_name": "collection_mapper"
}
response = requests.post(f"{BASE_URL}/models", json=data)
print("Created model:", response.json())
# Map new data
def map_template():
data = {
"columns": ["RIM", "Card Acc", "Case", "Customer Name", "Is", "Was"],
"data": [
{
"RIM": "13587",
"Card Acc": "5558899662147521EG",
"Case": "P123",
"Customer Name": "Ali",
"Is": 99.99,
"Was": 88.99
}
],
"threshold": 0.3
}
response = requests.post(
f"{BASE_URL}/models/collection_mapper/map",
json=data
)
print("Mapping result:", json.dumps(response.json(), indent=2))
def train_existing_model():
new_training_examples = [
{
"Account Rim": "CUSTOMER_NUMBER",
"Account Number": "ACC_NO",
"Case ID": "Case",
"Customer Full Name": "Customer_Name",
"Current Bucket": "BKT_IS",
"Previous Bucket": "BKT_Was"
},
{
"رقم الزبون": "CUSTOMER_NUMBER",
"رقم الحساب": "ACC_NO",
"الحالة": "Case",
"اسم الزبون": "Customer_Name",
"التصنيف الحالي": "BKT_IS",
"التصنيف السابق": "BKT_Was"
}
]
response = requests.post(
f"http://localhost:8000/models/collection_mapper/train",
json={
"examples": new_training_examples
}
)
print(response.json())
if __name__ == "__main__":
create_model()
train_existing_model()
map_template()