他的回复:
那在notebook上加载这个模型、并做predict看能成功吗?可以尝试执行下面这段代码,模型路径改成你本地的如果这是好的,说明本地模型是好的。那就把obs上的模型下载到notebook上、再测试这个模型是否是好的,下载方法参考baseline中的moxing.file.copyXXX。def test_model(): #pre print("begin pre") data="{\"req_data\":[\"2019-2-4,2019-2-7\"]}" json_data = json.loads(data, object_pairs_hook=collections.OrderedDict) days = json_data["req_data"][0].split(",") df = pd.DataFrame(columns = ["weekday", "timeindex"]) # generate X_test time between 5:00-20:55 in requested days for day in days: timestamp = to_datetime(day, format="%Y-%m-%d") df1 = pd.DataFrame({"weekday":(timestamp.dayofweek/6.0), "timeindex":(np.arange(300, 1256, 5))/(24 * 60.0)}) df = df.append(df1, ignore_index=True) #inference,修改为你本地模型路径 load_model = xgb.Booster(model_file=LOCAL_MODEL_PATH) pre_data = xgb.DMatrix(df) pre_result = load_model.predict(pre_data) pre_result = pre_result.tolist() #post print("begin to post process") schema = json.loads('{"wuhe_zhangheng":[1,2,3]}') schema["wuhe_zhangheng"] = pre_result res_data = json.dumps(schema) res_data = {"resp_data": res_data} print(res_data) print("end to post process")