作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我可以使用以下命令创建 ml 模型服务器
mlflow models serve -m file:///C:/Users/SawarkarFamily/Desktop/mlflow-master/examples/sklearn_elasticnet_wine/mlruns/0/9aeb7ba16d7e4c20870b664e267524ea/artifacts/model -p 8000
2020/07/28 17:10:59 INFO mlflow.models.cli: Selected backend for flavor 'python_function'
2020/07/28 17:11:03 INFO mlflow.pyfunc.backend: === Running command 'conda activate mlflow-76d7aedf36021b9bb7f176264305cf2b7868ca8d & waitress-serve --host=127.0.0.1 --port=8000 --ident=mlflow mlflow.pyfunc.scoring_server.wsgi:app'
c:\users\sawarkarfamily\anaconda3\envs\mlflow-76d7aedf36021b9bb7f176264305cf2b7868ca8d\lib\site-packages\waitress\adjustments.py:441: DeprecationWarning: In future versions of Waitress clear_untrusted_proxy_headers will be set to True by default. You may opt-out by setting this value to False, or opt-in explicitly by setting this to True.
warnings.warn(
Serving on http://DESKTOP-AO59MJC:8000
在文档中给出了使用 curl 命令发送预测的方法,如下所示:
curl -X POST -H "Content-Type:application/json; format=pandas-split" --data '{"columns":["alcohol", "chlorides", "citric acid", "density", "fixed acidity", "free sulfur dioxide", "pH", "residual sugar", "sulphates", "total sulfur dioxide", "volatile acidity"],"data":[[12.8, 0.029, 0.48, 0.98, 6.2, 29, 3.33, 1.2, 0.39, 75, 0.66]]}' http://127.0.0.1:1234/invocations
我用 8000 替换了端口号,但出现错误。
curl: (6) Could not resolve host: chlorides,
curl: (6) Could not resolve host: citric acid,
curl: (6) Could not resolve host: density,
curl: (6) Could not resolve host: fixed acidity,
curl: (6) Could not resolve host: free sulfur dioxide,
curl: (6) Could not resolve host: pH,
curl: (6) Could not resolve host: residual sugar,
curl: (6) Could not resolve host: sulphates,
curl: (6) Could not resolve host: total sulfur dioxide,
curl: (3) [globbing] unmatched close brace/bracket in column 17
curl: (6) Could not resolve host: 0.029,
curl: (6) Could not resolve host: 0.48,
curl: (6) Could not resolve host: 0.98,
curl: (6) Could not resolve host: 6.2,
curl: (6) Could not resolve host: 29,
curl: (6) Could not resolve host: 3.33,
curl: (6) Could not resolve host: 1.2,
curl: (6) Could not resolve host: 0.39,
curl: (6) Could not resolve host: 75,
curl: (3) [globbing] unmatched close brace/bracket in column 5
{"error_code": "MALFORMED_REQUEST", "message": "Failed to parse input as a Pandas DataFrame. Ensure that the input is a valid JSON-formatted Pandas DataFrame with the `split` orient produced using the `pandas.DataFrame.to_json(..., orient='split')` method.", "stack_trace": "Traceback (most recent call last):\n File \"c:\\users\\sawarkarfamily\\anaconda3\\envs\\mlflow-76d7aedf36021b9bb7f176264305cf2b7868ca8d\\lib\\site-packages\\mlflow\\pyfunc\\scoring_server\\__init__.py\", line 74, in parse_json_input\n return _dataframe_from_json(json_input, pandas_orient=orient, schema=schema)\n File \"c:\\users\\sawarkarfamily\\anaconda3\\envs\\mlflow-76d7aedf36021b9bb7f176264305cf2b7868ca8d\\lib\\site-packages\\mlflow\\utils\\proto_json_utils.py\", line 106, in _dataframe_from_json\n return pd.read_json(path_or_str, orient=pandas_orient, dtype=False,\n File \"c:\\users\\sawarkarfamily\\anaconda3\\envs\\mlflow-76d7aedf36021b9bb7f176264305cf2b7868ca8d\\lib\\site-packages\\pandas\\util\\_decorators.py\", line 214, in wrapper\n return func(*args, **kwargs)\n File \"c:\\users\\sawarkarfamily\\anaconda3\\envs\\mlflow-76d7aedf36021b9bb7f176264305cf2b7868ca8d\\lib\\site-packages\\pandas\\io\\json\\_json.py\", line 608, in read_json\n result = json_reader.read()\n File \"c:\\users\\sawarkarfamily\\anaconda3\\envs\\mlflow-76d7aedf36021b9bb7f176264305cf2b7868ca8d\\lib\\site-packages\\pandas\\io\\json\\_json.py\", line 731, in read\n obj = self._get_object_parser(self.data)\n File \"c:\\users\\sawarkarfamily\\anaconda3\\envs\\mlflow-76d7aedf36021b9bb7f176264305cf2b7868ca8d\\lib\\site-packages\\pandas\\io\\json\\_json.py\", line 753, in _get_object_parser\n obj = FrameParser(json, **kwargs).parse()\n File \"c:\\users\\sawarkarfamily\\anaconda3\\envs\\mlflow-76d7aedf36021b9bb7f176264305cf2b7868ca8d\\lib\\site-packages\\pandas\\io\\json\\_json.py\", line 857, in parse\n self._parse_no_numpy()\n File \"c:\\users\\sawarkarfamily\\anaconda3\\envs\\mlflow-76d7aedf36021b9bb7f176264305cf2b7868ca8d\\lib\\site-packages\\pandas\\io\\json\\_json.py\", line 1094, in _parse_no_numpy\n for k, v in loads(json, precise_float=self.precise_float).items()\nValueError: Expected object or value\n"}
请有人帮助我。
最佳答案
你的主机名/URI 在请求中放错了地方
curl -X POST http://127.0.0.1:1234/invocations -H "Content-Type:application/json; format=pandas-split" --data '{"columns":["alcohol", "chlorides", "citric acid", "density", "fixed acidity", "free sulfur dioxide", "pH", "residual sugar", "sulphates", "total sulfur dioxide", "volatile acidity"],"data":[[12.8, 0.029, 0.48, 0.98, 6.2, 29, 3.33, 1.2, 0.39, 75, 0.66]]}'
关于python - 如何将数据发送到服务器进行预测 - MLflow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63133902/
我是一名优秀的程序员,十分优秀!