Azure ML Studio环境中的Python自定义模型错误0085,在本地环境中正常工作

问题描述 投票:-2回答:1

Azure ML Studio Environment在使用自定义python模型中的pickle文件时抛出以下错误。 python本地模型,pickle文件在本地环境中运行良好,但在Azure ML Studio环境中运行不正常

错误0085:脚本评估期间发生以下错误,请查看输出日志以获取更多信息:---------- Python解释器启动错误消息----------捕获异常时执行函数:回溯(最近一次调用最后一次):文件“C:\ server \ invokepy.py”,第199行,批处理odfs = mod.azureml_main(* idfs)文件“C:\ temp \ b1cb10c870d842b9afcf8bb8037155a1.py”,行49,在azureml_main中返回DATA,model.predict_proba(DATA)文件“C:\ pyhome \ lib \ site-packages \ sklearn \ ensemble \ forest.py”,第540行,在predict_proba中n_jobs,_,_ = _partition_estimators(self。 n_estimators,self.n_jobs)文件“C:\ pyhome \ lib \ site-packages \ sklearn \ ensemble \ base.py”,第101行,在_partition_estimators中n_jobs = min(_get_n_jobs(n_jobs),n_estimators)文件“C:\ pyhome \ lib \ site-packages \ sklearn \ utils__init __。py“,第456行,如果n_jobs <0,则为_get_n_jobs:TypeError:不可订的类型:NoneType()<int()返回非零退出代码1的进程----- -----来自Python i的错误消息结束nterpreter ----------

什么都丢失了?

Python Pickle文件适用于本地环境。

# The script MUST contain a function named azureml_main
# which is the entry point for this module.

# imports up here can be used to
import pandas as pd
import sys
import pickle
from sklearn.ensemble import RandomForestClassifier
from sklearn.preprocessing import LabelEncoder
import numpy as np
import pickle
import os

def azureml_main(DATA = None, dataframe2 = None):

# Execution logic goes here
# print('Input pandas.DataFrame #1:\r\n\r\n{0}'.format(DATA))

# If a zip file is connected to the third input port is connected,
# it is unzipped under ".\Script Bundle". This directory is added
# to sys.path. Therefore, if your zip file contains a Python file
# mymodule.py you can import it using:
# import mymodule

sys.path.append('.\\Script Bundle\\MyLocalModel.zip')
sys.path.insert(0,".\Script Bundle")
model = pickle.load(open(".\Script Bundle\MyLocalModel.pkl", 'rb'))

#result = pd.DataFrame(model.predict_proba(dataframe1), columns=['p0','p1'])

# Return value must be of a sequence of pandas.DataFrame
return DATA, model.predict_proba(DATA)

python自定义模型需要在azure ml studio中使用,以作为Web服务进行部署,并使用本地模型的相同输出

4月17日更新1:

Python版本2.7.11在本地和Azure ML Studio中是相同的,但发现,sklearn版本在本地[0.18.x]和Azure ML Studio [0.15.x]中有所不同,其中train_test_split与下面的代码不同:

##from sklearn.model_selection import train_test_split ## works only with 0.18.x
import sklearn
from sklearn.cross_validation import train_test_split ## works only with 0.15.x
print ('sklearn version {0}'.format(sklearn.__version__))

1)现在,如何将sklearn包更新到Azure ML Studio中的最新版本?或者另一种方法是降低我的本地sklearn,尝试,将实验这一点。

2)另一个练习是使用MDF [MulticlassDecisionForest]算法在Azure ML Studio中创建模型。并且本地使用RFC [RandomForestClassifier]算法,但两个输出完全不同,不匹配?

使用RFC算法在sklearn版本0.18.x的本地环境中的代码下面:##在本地环境中的随机森林分类器,sklearn.ensemble中的sklearn版本0.18.x导入RandomForestClassifier

## Random Forest Classifier
rfc = RandomForestClassifier(n_estimators = 550,max_depth = 6,max_features = 30,random_state = 0) 
rfc.fit(X_train,y_train)
print (rfc)

## Accuracy test
accuracy = rfc.score(X_test1,y_test1)
print ("Accuracy is {}".format(accuracy))

3)使用较低版本的sklearn版本0.15.x,使用Azure ML Studio Execute Python Script复制了本地python代码,除了极少的测试数据集行外,还产生了相同的本地输出。现在,如何从Python脚本中训练模型作为训练模型组件的未经训练的模型输入?或者在DataSet中编写pickle文件,并作为自定义模型使用?

非常感谢您的宝贵意见。

python machine-learning azure-machine-learning-studio ml-studio mlmodel
1个回答
0
投票

这很可能是因为您用于序列化模型的pickle版本与Azure ML Studio用于反序列化的版本不同。检查Execute Python Script属性以查看可用的Anaconda / Python版本。

© www.soinside.com 2019 - 2024. All rights reserved.