Commit e31a2d70 authored by 张彦钊's avatar 张彦钊

修改ffm转化函数,改成features累计相加

parent 71f3d64d
......@@ -187,7 +187,8 @@ def get_data():
ucity_id = list(set(df["ucity_id"].values.tolist()))
manufacturer = list(set(df["manufacturer"].values.tolist()))
channel = list(set(df["channel"].values.tolist()))
return df,validate_date,ucity_id,ccity_name,manufacturer,channel
level2_ids = list(set(df["level2_ids"].values.tolist()))
return df,validate_date,ucity_id,ccity_name,manufacturer,channel,level2_ids
def transform(a,validate_date):
......@@ -219,7 +220,7 @@ def transform(a,validate_date):
return model
def get_predict_set(ucity_id,model,ccity_name,manufacturer,channel):
def get_predict_set(ucity_id,model,ccity_name,manufacturer,channel,level2_ids):
db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test')
sql = "select e.y,e.z,e.label,e.ucity_id,e.clevel1_id,e.ccity_name," \
"u.device_type,u.manufacturer,u.channel,c.top,df.level2_ids,e.device_id,e.cid_id " \
......@@ -250,6 +251,10 @@ def get_predict_set(ucity_id,model,ccity_name,manufacturer,channel):
print("after channel filter:")
print(df.shape)
df = df[df["level2_ids"].isin(level2_ids)]
print("after level2_ids filter:")
print(df.shape)
df["cid_id"] = df["cid_id"].astype("str")
df["clevel1_id"] = df["clevel1_id"].astype("str")
df["top"] = df["top"].astype("str")
......@@ -302,9 +307,9 @@ def get_predict_set(ucity_id,model,ccity_name,manufacturer,channel):
if __name__ == "__main__":
path = "/home/gmuser/esmm_data/"
a = time.time()
temp, validate_date, ucity_id,ccity_name,manufacturer,channel = get_data()
temp, validate_date, ucity_id,ccity_name,manufacturer,channel,level2_ids = get_data()
model = transform(temp, validate_date)
get_predict_set(ucity_id,model,ccity_name,manufacturer,channel)
get_predict_set(ucity_id,model,ccity_name,manufacturer,channel,level2_ids)
b = time.time()
print("cost(分钟)")
print((b-a)/60)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment