Commit a46d094c authored by 赵威's avatar 赵威

add printer

parent b1c603f0
...@@ -92,7 +92,7 @@ def main(): ...@@ -92,7 +92,7 @@ def main():
device_ids = list(device_dict.keys())[:20] device_ids = list(device_dict.keys())[:20]
diary_ids = list(diary_dict.keys()) diary_ids = list(diary_dict.keys())
for i in range(5): for i in range(2):
time_1 = timeit.default_timer() time_1 = timeit.default_timer()
model_predict2(random.sample(device_ids, 1)[0], random.sample(diary_ids, 200), device_dict, diary_dict, predict_fn) model_predict2(random.sample(device_ids, 1)[0], random.sample(diary_ids, 200), device_dict, diary_dict, predict_fn)
total_1 = (timeit.default_timer() - time_1) total_1 = (timeit.default_timer() - time_1)
......
...@@ -129,39 +129,11 @@ def model_predict2(device_id, diary_ids, device_dict, diary_dict, predict_fn): ...@@ -129,39 +129,11 @@ def model_predict2(device_id, diary_ids, device_dict, diary_dict, predict_fn):
time_1 = timeit.default_timer() time_1 = timeit.default_timer()
predictions = predict_fn({"examples": examples}) predictions = predict_fn({"examples": examples})
diary_ids = []
for i in diary_lst:
diary_ids.append(i.get("card_id", "-1"))
print(predictions)
print(diary_ids)
total_1 = (timeit.default_timer() - time_1) total_1 = (timeit.default_timer() - time_1)
print("prediction cost {:.5f}s".format(total_1)) print("prediction cost {:.5f}s".format(total_1))
return predictions return predictions
# def model_predict(inputs, predict_fn):
# time_1 = timeit.default_timer()
# int_columns = [
# "active_type", "active_days", "card_id", "is_pure_author", "is_have_reply", "is_have_pure_reply", "content_level",
# "topic_num", "favor_num", "vote_num"
# ]
# float_columns = ["one_ctr", "three_ctr", "seven_ctr", "fifteen_ctr"]
# examples = []
# for index, row in inputs.iterrows():
# features = {}
# for col, value in row.iteritems():
# if col in ["click_label", "conversion_label"]:
# pass
# elif col in int_columns:
# features[col] = _int64_feature(int(value))
# elif col in float_columns:
# features[col] = _float_feature(float(value))
# else:
# features[col] = _bytes_feature(str(value).encode(encoding="utf-8"))
# example = tf.train.Example(features=tf.train.Features(feature=features))
# examples.append(example.SerializeToString())
# total_1 = (timeit.default_timer() - time_1)
# print("make example cost {:.5f}s".format(total_1))
# time_1 = timeit.default_timer()
# predictions = predict_fn({"examples": examples})
# total_1 = (timeit.default_timer() - time_1)
# print("prediction cost {:.5f}s".format(total_1))
# # print(predictions)
# # TODO get the diary ids
# return predictions
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