Commit 38beeac6 authored by 张彦钊's avatar 张彦钊

change int to float

parent c9afa57f
...@@ -63,9 +63,8 @@ def get_data(): ...@@ -63,9 +63,8 @@ def get_data():
test = df[df["stat_date"] == validate_date+"stat_date"] test = df[df["stat_date"] == validate_date+"stat_date"]
for i in features: for i in features:
train[i] = train[i].map(value_map) train[i] = train[i].map(value_map)
train[i] = train[i].astype('int64')
test[i] = test[i].map(value_map) test[i] = test[i].map(value_map)
test[i] = test[i].astype('int64')
print("train shape") print("train shape")
print(train.shape) print(train.shape)
...@@ -123,11 +122,11 @@ def get_predict(date,value_map): ...@@ -123,11 +122,11 @@ def get_predict(date,value_map):
native_pre[i] = native_pre[i].map(value_map) native_pre[i] = native_pre[i].map(value_map)
# TODO 没有覆盖到的类别会处理成na,暂时用0填充,后续完善一下 # TODO 没有覆盖到的类别会处理成na,暂时用0填充,后续完善一下
native_pre[i] = native_pre[i].fillna(0) native_pre[i] = native_pre[i].fillna(0)
native_pre[i] = native_pre[i].astype('int64')
nearby_pre[i] = nearby_pre[i].map(value_map) nearby_pre[i] = nearby_pre[i].map(value_map)
# TODO 没有覆盖到的类别会处理成na,暂时用0填充,后续完善一下 # TODO 没有覆盖到的类别会处理成na,暂时用0填充,后续完善一下
nearby_pre[i] = nearby_pre[i].fillna(0) nearby_pre[i] = nearby_pre[i].fillna(0)
nearby_pre[i] = nearby_pre[i].astype('int64')
print("native") print("native")
print(native_pre.shape) print(native_pre.shape)
......
...@@ -29,18 +29,18 @@ def gen_tfrecords(in_file): ...@@ -29,18 +29,18 @@ def gen_tfrecords(in_file):
for i in range(df.shape[0]): for i in range(df.shape[0]):
features = tf.train.Features(feature={ features = tf.train.Features(feature={
"y": tf.train.Feature(int64_list=tf.train.Int64List(value=[df["y"][i]])), "y": tf.train.Feature(float_list=tf.train.FloatList(value=[df["y"][i]])),
"z": tf.train.Feature(int64_list=tf.train.Int64List(value=[df["z"][i]])), "z": tf.train.Feature(float_list=tf.train.FloatList(value=[df["z"][i]])),
"top": tf.train.Feature(int64_list=tf.train.Int64List(value=[df["top"][i]])), "top": tf.train.Feature(float_list=tf.train.FloatList(value=[df["top"][i]])),
"channel": tf.train.Feature(int64_list=tf.train.Int64List(value=[df["channel"][i]])), "channel": tf.train.Feature(float_list=tf.train.FloatList(value=[df["channel"][i]])),
"ucity_id": tf.train.Feature(int64_list=tf.train.Int64List(value=[df["ucity_id"][i]])), "ucity_id": tf.train.Feature(float_list=tf.train.FloatList(value=[df["ucity_id"][i]])),
"clevel1_id": tf.train.Feature(int64_list=tf.train.Int64List(value=[df["clevel1_id"][i]])), "clevel1_id": tf.train.Feature(float_list=tf.train.FloatList(value=[df["clevel1_id"][i]])),
"ccity_name": tf.train.Feature(int64_list=tf.train.Int64List(value=[df["ccity_name"][i]])), "ccity_name": tf.train.Feature(float_list=tf.train.FloatList(value=[df["ccity_name"][i]])),
"device_type": tf.train.Feature(int64_list=tf.train.Int64List(value=[df["device_type"][i]])), "device_type": tf.train.Feature(float_list=tf.train.FloatList(value=[df["device_type"][i]])),
"manufacturer": tf.train.Feature(int64_list=tf.train.Int64List(value=[df["manufacturer"][i]])), "manufacturer": tf.train.Feature(float_list=tf.train.FloatList(value=[df["manufacturer"][i]])),
"level2_ids": tf.train.Feature(int64_list=tf.train.Int64List(value=[df["level2_ids"][i]])), "level2_ids": tf.train.Feature(float_list=tf.train.FloatList(value=[df["level2_ids"][i]])),
"time": tf.train.Feature(int64_list=tf.train.Int64List(value=[df["time"][i]])), "time": tf.train.Feature(float_list=tf.train.FloatList(value=[df["time"][i]])),
"stat_date": tf.train.Feature(int64_list=tf.train.Int64List(value=[df["stat_date"][i]])) "stat_date": tf.train.Feature(float_list=tf.train.FloatList(value=[df["stat_date"][i]]))
}) })
example = tf.train.Example(features = features) example = tf.train.Example(features = features)
......
...@@ -53,16 +53,16 @@ def input_fn(filenames, batch_size=32, num_epochs=1, perform_shuffle=False): ...@@ -53,16 +53,16 @@ def input_fn(filenames, batch_size=32, num_epochs=1, perform_shuffle=False):
features = { features = {
"y": tf.FixedLenFeature([], tf.float32), "y": tf.FixedLenFeature([], tf.float32),
"z": tf.FixedLenFeature([], tf.float32), "z": tf.FixedLenFeature([], tf.float32),
"top": tf.FixedLenFeature([], tf.int64), "top": tf.FixedLenFeature([], tf.float32),
"channel": tf.FixedLenFeature([], tf.int64), "channel": tf.FixedLenFeature([], tf.float32),
"ucity_id": tf.FixedLenFeature([], tf.int64), "ucity_id": tf.FixedLenFeature([], tf.float32),
"clevel1_id": tf.FixedLenFeature([], tf.int64), "clevel1_id": tf.FixedLenFeature([], tf.float32),
"ccity_name": tf.FixedLenFeature([], tf.int64), "ccity_name": tf.FixedLenFeature([], tf.float32),
"device_type": tf.FixedLenFeature([], tf.int64), "device_type": tf.FixedLenFeature([], tf.float32),
"manufacturer": tf.FixedLenFeature([], tf.int64), "manufacturer": tf.FixedLenFeature([], tf.float32),
"level2_ids": tf.FixedLenFeature([], tf.int64), "level2_ids": tf.FixedLenFeature([], tf.float32),
"time": tf.FixedLenFeature([], tf.int64), "time": tf.FixedLenFeature([], tf.float32),
"stat_date": tf.FixedLenFeature([], tf.int64) "stat_date": tf.FixedLenFeature([], tf.float32)
} }
parsed = tf.parse_single_example(record, features) parsed = tf.parse_single_example(record, features)
......
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