scikit-learn - MLflow 网络服务器返回 400 状态,“列 X 的输入类型不兼容。无法安全地将 float64 转换为
我正在使用MLflow
and实现异常检测 Web 服务sklearn.pipeline.Pipeline()
。该模型的目的是使用服务器日志检测网络爬虫,而response_length
列是我的功能之一。在服务模型之后,为了测试 Web 服务,我发送了下面的请求
问题描述
我正在使用MLflow
and实现异常检测 Web 服务sklearn.pipeline.Pipeline()
。该模型的目的是使用服务器日志检测网络爬虫,而response_length
列是我的功能之一。在服务模型之后,为了测试 Web 服务,我发送了下面的请求,其中包含训练数据的前 20 列。
$ curl --location --request POST '127.0.0.1:8000/invocations'
--header 'Content-Type: text/csv' \
--data-binary 'datasets/test.csv'
但是 Web 服务器的响应有状态码 400 (BAD REQUEST) 和这个 JSON 正文:
{
"error_code": "BAD_REQUEST",
"message": "Incompatible input types for column response_length. Can not safely convert float64 to <U0."
}
以下是模型编译 MLflow Tracking 组件日志:
[Pipeline] ......... (step 1 of 3) Processing transform, total=11.8min
[Pipeline] ............... (step 2 of 3) Processing pca, total= 4.8s
[Pipeline] ........ (step 3 of 3) Processing rule_based, total= 0.0s
2021/07/16 04:55:12 WARNING mlflow.sklearn: Training metrics will not be recorded because training labels were not specified. To automatically record training metrics, provide training labels as inputs to the model training function.
2021/07/16 04:55:12 WARNING mlflow.utils.autologging_utils: MLflow autologging encountered a warning: "/home/matin/workspace/Rahnema College/venv/lib/python3.8/site-packages/mlflow/models/signature.py:129: UserWarning: Hint: Inferred schema contains integer column(s). Integer columns in Python cannot represent missing values. If your input data contains missing values at inference time, it will be encoded as floats and will cause a schema enforcement error. The best way to avoid this problem is to infer the model schema based on a realistic data sample (training dataset) that includes missing values. Alternatively, you can declare integer columns as doubles (float64) whenever these columns may have missing values. See `Handling Integers With Missing Values <https://www.mlflow.org/docs/latest/models.html#handling-integers-with-missing-values>`_ for more details."
Logged data and model in run: 8843336f5c31482c9e246669944b1370
---------- logged params ----------
{'memory': 'None',
'pca': 'PCAEstimator()',
'rule_based': 'RuleBasedEstimator()',
'steps': "[('transform', <log_transformer.LogTransformer object at "
"0x7f05a8b95760>), ('pca', PCAEstimator()), ('rule_based', "
'RuleBasedEstimator())]',
'transform': '<log_transformer.LogTransformer object at 0x7f05a8b95760>',
'verbose': 'True'}
---------- logged metrics ----------
{}
---------- logged tags ----------
{'estimator_class': 'sklearn.pipeline.Pipeline', 'estimator_name': 'Pipeline'}
---------- logged artifacts ----------
['model/MLmodel',
'model/conda.yaml',
'model/model.pkl',
'model/requirements.txt']
如果有人能准确地告诉我如何解决这个模型服务问题,那将非常有帮助。
mlflow.utils.autologging_utils
WARNING引起的问题。
创建模型时,数据输入签名MLmodel
与一些文件一起保存在文件中。您应该通过替换将response_length
签名输入类型从string
更改为double
{"name": "response_length", "type": "double"}
代替
{"name": "response_length", "type": "string"}
所以不需要转换。在为模型提供编辑MLmodel
文件后,Web 服务器按预期工作。
解决方案
mlflow.utils.autologging_utils
WARNING引起的问题。
创建模型时,数据输入签名MLmodel
与一些文件一起保存在文件中。您应该通过替换将response_length
签名输入类型从string
更改为double
{"name": "response_length", "type": "double"}
代替
{"name": "response_length", "type": "string"}
所以不需要转换。在为模型提供编辑MLmodel
文件后,Web 服务器按预期工作。
推荐阅读
- html - 我的代码的哪一部分使滚动条不出现?
- ruby-on-rails - Docker 容器未在端口 3000 上公开 Rails 应用程序
- android - 如何防止admob在后台工作
- python - 完成脚本中的断言?
- docker - 卷值'不匹配任何正则表达式:u'^[a-zA-Z0-9._-]+$' - elasticsearch docker-compose中的错误
- c# - 使用实体框架(C#),有没有办法加密字段,以便只有在用户登录时才能解密它们?
- linux - LVM Linux。我的任务中的 LE 是什么意思?可能是错字
- c++ - 基于 C++ QMap 在 QML 中动态创建元素的最佳方法
- excel - chrome 中的检查元素在网站上没有显示任何 id 框,我如何找到它?包含代码
- python - 如何使用 Selenium 和 Python 更改用户代理
我正在使用MLflow
and实现异常检测 Web 服务sklearn.pipeline.Pipeline()
。该模型的目的是使用服务器日志检测网络爬虫,而response_length
列是我的功能之一。在服务模型之后,为了测试 Web 服务,我发送了下面的请求
问题描述
我正在使用MLflow
and实现异常检测 Web 服务sklearn.pipeline.Pipeline()
。该模型的目的是使用服务器日志检测网络爬虫,而response_length
列是我的功能之一。在服务模型之后,为了测试 Web 服务,我发送了下面的请求,其中包含训练数据的前 20 列。
$ curl --location --request POST '127.0.0.1:8000/invocations'
--header 'Content-Type: text/csv' \
--data-binary 'datasets/test.csv'
但是 Web 服务器的响应有状态码 400 (BAD REQUEST) 和这个 JSON 正文:
{
"error_code": "BAD_REQUEST",
"message": "Incompatible input types for column response_length. Can not safely convert float64 to <U0."
}
以下是模型编译 MLflow Tracking 组件日志:
[Pipeline] ......... (step 1 of 3) Processing transform, total=11.8min
[Pipeline] ............... (step 2 of 3) Processing pca, total= 4.8s
[Pipeline] ........ (step 3 of 3) Processing rule_based, total= 0.0s
2021/07/16 04:55:12 WARNING mlflow.sklearn: Training metrics will not be recorded because training labels were not specified. To automatically record training metrics, provide training labels as inputs to the model training function.
2021/07/16 04:55:12 WARNING mlflow.utils.autologging_utils: MLflow autologging encountered a warning: "/home/matin/workspace/Rahnema College/venv/lib/python3.8/site-packages/mlflow/models/signature.py:129: UserWarning: Hint: Inferred schema contains integer column(s). Integer columns in Python cannot represent missing values. If your input data contains missing values at inference time, it will be encoded as floats and will cause a schema enforcement error. The best way to avoid this problem is to infer the model schema based on a realistic data sample (training dataset) that includes missing values. Alternatively, you can declare integer columns as doubles (float64) whenever these columns may have missing values. See `Handling Integers With Missing Values <https://www.mlflow.org/docs/latest/models.html#handling-integers-with-missing-values>`_ for more details."
Logged data and model in run: 8843336f5c31482c9e246669944b1370
---------- logged params ----------
{'memory': 'None',
'pca': 'PCAEstimator()',
'rule_based': 'RuleBasedEstimator()',
'steps': "[('transform', <log_transformer.LogTransformer object at "
"0x7f05a8b95760>), ('pca', PCAEstimator()), ('rule_based', "
'RuleBasedEstimator())]',
'transform': '<log_transformer.LogTransformer object at 0x7f05a8b95760>',
'verbose': 'True'}
---------- logged metrics ----------
{}
---------- logged tags ----------
{'estimator_class': 'sklearn.pipeline.Pipeline', 'estimator_name': 'Pipeline'}
---------- logged artifacts ----------
['model/MLmodel',
'model/conda.yaml',
'model/model.pkl',
'model/requirements.txt']
如果有人能准确地告诉我如何解决这个模型服务问题,那将非常有帮助。
mlflow.utils.autologging_utils
WARNING引起的问题。
创建模型时,数据输入签名MLmodel
与一些文件一起保存在文件中。您应该通过替换将response_length
签名输入类型从string
更改为double
{"name": "response_length", "type": "double"}
代替
{"name": "response_length", "type": "string"}
所以不需要转换。在为模型提供编辑MLmodel
文件后,Web 服务器按预期工作。
解决方案
mlflow.utils.autologging_utils
WARNING引起的问题。
创建模型时,数据输入签名MLmodel
与一些文件一起保存在文件中。您应该通过替换将response_length
签名输入类型从string
更改为double
{"name": "response_length", "type": "double"}
代替
{"name": "response_length", "type": "string"}
所以不需要转换。在为模型提供编辑MLmodel
文件后,Web 服务器按预期工作。
推荐阅读
- html - 我的代码的哪一部分使滚动条不出现?
- ruby-on-rails - Docker 容器未在端口 3000 上公开 Rails 应用程序
- android - 如何防止admob在后台工作
- python - 完成脚本中的断言?
- docker - 卷值'不匹配任何正则表达式:u'^[a-zA-Z0-9._-]+$' - elasticsearch docker-compose中的错误
- c# - 使用实体框架(C#),有没有办法加密字段,以便只有在用户登录时才能解密它们?
- linux - LVM Linux。我的任务中的 LE 是什么意思?可能是错字
- c++ - 基于 C++ QMap 在 QML 中动态创建元素的最佳方法
- excel - chrome 中的检查元素在网站上没有显示任何 id 框,我如何找到它?包含代码
- python - 如何使用 Selenium 和 Python 更改用户代理