return result def logloss(act, pred): epsilon = 1e-15 pred = sp.maximum(epsilon, pred) pred = sp.minimum(1 - epsilon, pred) ll = sum(act * sp.log(pred) + sp.subtract(1, act) * sp.log(sp.subtract(1, pred))) ll = ll * -1.0 / len(act) return ll if __name__ == '__main__': debug = False print('reading data...') ad = Advertisement(Configure.ad_path, debug=debug) app = App(Configure.app_categories_path, debug=debug) data_set = Dataset(Configure.train_path, Configure.test_path, debug=debug) position = Position(Configure.position_path, debug=debug) user = User(Configure.user_path, debug=debug) user_app_actions = User_App_Actions(Configure.user_app_actions_path, debug=debug) # user_app_installed = User_App_Installed(Configure.user_installedapps_path, debug=debug) data_set.add_to_position(position) data_set.add_to_advertisement(ad) data_set.add_to_app_cat(ad, app) func_dict = {'creativeID': creative_dlist, 'adID': ad_dlist, 'camgaignID': camgaign_dlist, 'advertiserID': advertiser_dlist, 'appID': app_dlist, 'positionID': position_dlist} path_dict = {'creativeID': Configure.creative_correlate,
import xgboost as xgb from conf.configure import Configure from reading.advertisement import Advertisement from reading.app import App from reading.dataset import Dataset from reading.position import Position from reading.user import User from reading.user_app_actions import User_App_Actions import matplotlib.pyplot as plt import numpy as np if __name__ == '__main__': data_set = Dataset(Configure.train_path, Configure.test_path) data_set.output_by_userid(Configure.dataset_sort_by_userid)