Skip to content

Commit

Permalink
Merge pull request #9 from streamnsight/bugfix/perf
Browse files Browse the repository at this point in the history
bugfix: faker instantiated at every customer
  • Loading branch information
namebrandon authored Jun 8, 2022
2 parents 3f782a2 + 1241ce8 commit 10b6b33
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions datagen_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from datagen_customer import headers


fake = Faker()
transaction_headers = [
'trans_num',
'trans_date',
Expand Down Expand Up @@ -41,7 +42,6 @@ def __init__(self, raw):
self.raw = raw.strip().split('|')
self.attrs = self.parse_customer(raw)
self.fraud_dates = []
self.fake = Faker()

def print_trans(self, trans, is_fraud, fraud_dates):
is_traveling = trans[1]
Expand All @@ -63,8 +63,8 @@ def print_trans(self, trans, is_fraud, fraud_dates):
rad = (float(travel_max) / 100) * 1.43

# geo_coordinate() uses uniform distribution with lower = (center-rad), upper = (center+rad)
merch_lat = self.fake.coordinate(center=float(cust_lat),radius=rad)
merch_long = self.fake.coordinate(center=float(cust_long),radius=rad)
merch_lat = fake.coordinate(center=float(cust_lat),radius=rad)
merch_long = fake.coordinate(center=float(cust_long),radius=rad)

if (is_fraud == 0 and t[1] not in fraud_dates) or is_fraud == 1:
features = self.raw + t + [chosen_merchant, str(merch_lat), str(merch_long)]
Expand Down

0 comments on commit 10b6b33

Please sign in to comment.