-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreate_mass_population_model.py
More file actions
35 lines (27 loc) · 998 Bytes
/
create_mass_population_model.py
File metadata and controls
35 lines (27 loc) · 998 Bytes
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
from prediction_models import get_cat_and_loc_model
import pickle
import json
from sklearn import svm
from td-api import get_all_customer_data, get_transations_by_customer
import requests
X = []
Y = []
for c in get_all_customer_data()[:300]:
transations = get_transations_by_customer(c['id'])
print("customer", c['id'])
for t in transations:
print("transaction", t['id'])
price = float(t['currencyAmount'])
if price > 0 and "merchantCategoryCode" in t and "locationLongitude" in t:
merchantCatCode = int(t['merchantCategoryCode'])
loc_long = float(t['locationLongitude'])
loc_lat = float(t['locationLatitude'])
X.append([merchantCatCode, loc_long, loc_lat])
Y.append(price)
print("creating model")
clf = svm.SVR()
print("finished creating model")
print("training model")
clf.fit(X, Y)
print("finished training model")
pickle.dump(clf, open("mass-population-category-and-location.model", "wb"))