import Shared as sd from datetime import datetime countries_ = ["None", "US", "GB", "CA", "DE", "FR", "NL", "IT"] regions_ = sd.get_dict("region") def process(entry, result): # Event - time t = entry["t"] / 1000 min = datetime.fromtimestamp(t).minute sd.binarize(result, min, 60) hour = datetime.fromtimestamp(t).hour sd.binarize(result, hour, 24) day = datetime.fromtimestamp(t).weekday() sd.binarize(result, day, 7) hour_of_week = day*24+hour sd.binarize(result, hour_of_week, 7*24) # Event - country sd.add_to_result(result, entry["cc"], countries_) # Event - region sd.add_to_result(result, entry["rg"], regions_)
import Shared as sd margins_ = [3.5, 2.45, 3.0, 2.0, 1.65, 0.85, 1.25, 0.45, 0.25, 0.15, 0.1, 4.5, 0.0, 4.0] bkcids_ = sd.get_dict("bkc") def if_multiple_tmax(result, tmax, n): tmax_tmp = tmax / float(n) if tmax_tmp == int(tmax_tmp): result.append(1) else: result.append(0) def process(entry, result): # Auction - margin margin = round(float(entry["margin"]), 2) sd.add_to_result(result, margin, margins_) # Auction - tmax tmax = entry["tmax"] if not tmax == "None": # Determine if tmax is multiple of 5 or 10 if_multiple_tmax(result, tmax, 5) if_multiple_tmax(result, tmax, 10) for thres in [500, 700]: if tmax <= thres: result.append(1) else: