一、研究目的
80/20原则被许多企业证明是正确的——只有一小部分客户产生了大部分收入。因此,营销团队面临的挑战是在促销策略上进行适当的投入。
在这个比赛中,选手需要分析一个Google商品商店(也称为GStore,Google swag在这里销售)的客户数据集,以预测每个客户带来的营收。希望其结果是更加可控的,以及更好的使公司利用这些数据进行数据分析,进而管理营销预算。
综上可知,该项目属于回归预测问题
二、数据探索
dir_path = '../input/'
os.listdir(dir_path)
for file in os.listdir(dir_path):
f_path = dir_path+file
stat_f = os.stat(f_path)
n_line = sum(1 for line in open(f_path))
print('{a} size is {b}M, lines is {c}'.format(a=file, b=round(stat_f.st_size/(1024*1024),3), c=n_line))
可见数据还是很庞大的。
由于数据量太大,先读入前5行看看
%%time
r = 0
for each in open('../input/train.csv'):
print(each)
r += 1
if r > 4:
break
columns 共12列:
channelGrouping, date, device, fullVisitorId, geoNetwork, sessionId, socialEngagementType, totals, trafficSource, visitId, visitNumber, visitStartTime
data内容是取一行看:
可知device、geoNetwork、 totals, trafficSource 是json,
visitStartTime 是时间戳
date 是非标准日期格式
Organic Search,20160902,"{""browser"": ""Chrome"", ""browserVersion"": ""not available in demo dataset"", ""browserSize"": ""not available in demo dataset"", ""operatingSystem"": ""Windows"", ""operatingSystemVersion"": ""not available in demo dataset"", ""isMobile"": false, ""mobileDeviceBranding"": ""not available in demo dataset"", ""mobileDeviceModel"": ""not available in demo dataset"", ""mobileInputSelector"": ""not available in demo dataset"", ""mobileDeviceInfo"": ""not available in demo dataset"", ""mobileDeviceMarketingName"": ""not available in demo dataset"", ""flashVersion"": ""not available in demo dataset"", ""language"": ""not available in demo dataset"", ""screenColors"": ""not available in demo dataset"", ""screenResolution"": ""not available in demo dataset"", ""deviceCategory"": ""desktop""}",1131660440785968503,"{""continent"": ""Asia"", ""subContinent"": ""Western Asia"", ""country"": ""Turkey"", ""region"": ""Izmir"", ""metro"": ""(not set)"", ""city"": ""Izmir"", ""cityId"": ""not available in demo dataset"", ""networkDomain"": ""ttnet.com.tr"", ""latitude"": ""not available in demo dataset"", ""longitude"": ""not available in demo dataset"", ""networkLocation"": ""not available in demo dataset""}",1131660440785968503_1472830385,Not Socially Engaged,"{""visits"": ""1"", ""hits"": ""1"", ""pageviews"": ""1"", ""bounces"": ""1"", ""newVisits"": ""1""}","{""campaign"": "