-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_generator.py
More file actions
91 lines (82 loc) · 3.46 KB
/
data_generator.py
File metadata and controls
91 lines (82 loc) · 3.46 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
89
90
91
import random
import json
def poor_big_spender():
data = [0,0,0,0,0,0]
age = random.randint(16, 80)
total_income = random.randint(6000, 40000)+random.randint(-1, 1)*random.randint(1000, 3000)
monthly_income = total_income/12.0
rcs = -0.6
for i in range(1,12):
poor_status = random.uniform(0, 0.5)
saving_rate = random.uniform(3,6)
spending_rate = random.uniform(6,9)
monthly_expenditure = monthly_income/saving_rate
account_total = total_income*(1.0-poor_status)
rcs = (monthly_income-monthly_expenditure)/monthly_income
data = [x + y for x, y in zip(data, [monthly_income, monthly_expenditure, total_income, rcs, age, account_total])]
data = [x / 12 for x in data]
return data
def saver_big_spender():
data = [0,0,0,0,0,0]
age = random.randint(16, 80)
total_income = random.randint(6000, 200000)+random.randint(-1, 1)*random.randint(1000, 3000)
monthly_income = total_income/12.0
rcs = -0.6
for i in range(1,12):
poor_status = random.uniform(0, 1)
saving_rate = random.uniform(6,9)
spending_rate = random.uniform(6,9)
monthly_expenditure = monthly_income/saving_rate
account_total = total_income*(1.0-poor_status)
rcs = (monthly_income-monthly_expenditure)/monthly_income
data = [x + y for x, y in zip(data, [monthly_income, monthly_expenditure, total_income, rcs, age, account_total])]
data = [x / 12 for x in data]
return data
def saver_small_spender():
data = [0,0,0,0,0,0]
age = random.randint(16, 80)
total_income = random.randint(6000, 200000)+random.randint(-1, 1)*random.randint(1000, 3000)
monthly_income = total_income/12.0
rcs = -0.6
for i in range(1,12):
poor_status = random.uniform(0, 1)
saving_rate = random.uniform(6,9)
spending_rate = random.uniform(3,6)
monthly_expenditure = monthly_income/spending_rate
account_total = total_income*(1.0-poor_status)
rcs = (monthly_income-monthly_expenditure)/monthly_income
data = [x + y for x, y in zip(data, [monthly_income, monthly_expenditure, total_income, rcs, age, account_total])]
data = [x / 12 for x in data]
return data
def average_spender():
data = [0,0,0,0,0,0]
age = random.randint(16, 80)
total_income = random.randint(6000, 200000)+random.randint(-1, 1)*random.randint(1000, 3000)
monthly_income = total_income/12.0
rcs = -0.6
for i in range(1,12):
poor_status = random.uniform(0, 1)
saving_rate = random.uniform(4,7)
spending_rate = random.uniform(4,7)
monthly_expenditure = monthly_income/spending_rate
account_total = total_income*(1.0-poor_status)
rcs = (monthly_income-monthly_expenditure)/monthly_income
data = [x + y for x, y in zip(data, [monthly_income, monthly_expenditure, total_income, rcs, age, account_total])]
data = [x / 12 for x in data]
return data
if __name__ == "__main__":
data = []
targets = []
for i in range(0, 1000000):
rand = random.randint(0, 3)
targets.append(rand)
if(rand == 0): data.append(poor_big_spender())
elif (rand == 1): data.append(saver_big_spender())
elif (rand == 2): data.append(saver_small_spender())
else: data.append(average_spender())
file = open('data.txt', 'w')
file.write(json.dumps(data))
file.close()
file = open('targets.txt', 'w')
file.write(json.dumps(targets))
file.close()