如何在'执行python脚本'部分中将外部pickle文件内容作为数据框加载到azure ml studio中? [英] How to load an external pickle file contents as a data frame in azure ml studio in the 'execute python script' section?
本文介绍了如何在'执行python脚本'部分中将外部pickle文件内容作为数据框加载到azure ml studio中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我正在使用的脚本:
import 警告
警告 。 filterwarnings ( 'ignore' )
import pandas as pd
import sys
import 泡菜
def azureml_main ( dataframe1 = < span class ="pln"style ="margin:0px; padding:0px; border:0px; font-style:inherit; font-variant:inherit; font-weight:inherit; line-height:inherit; font-family:inherit ; vertical-align:baseline; color:#303336"> None , dataframe2 = 无 ):
sys 。 路径 。 追加 ( '。\\Script Bundle' )
dataframe1 = 泡菜 。 加载 ( open ( < span class ="pln"style ="margin:0px; padding:0px; border:0px; font-style:inherit; font-variant:inherit; font-weight:inherit; line-height:inherit; font-family:inherit ; vertical-align:baseline; color:#303336"> r '/ Script Bundle / descript.pkl' , 'rb' ))
返回 dataframe1 ,
但是当我执行它时,得到以下错误
FileNotFoundError : [ Errno 2 ] 否 此类文件 或 目录 : '/ Script
Bundle / descript.pkl'
过程 返回 非 - 零退出代码 1
解决方案
您好,
我认为您应该使用sys.path.insert(),因为未正确设置路径以加载模型文件。也许您可以使用以下内容重写:
sys.path.insert(0," .\Script Bundle\descript")
model = pickle。 load(打开("。\Script Bundle \descript.pkl","rb"))
pred = model.predict(dataframe1)
返回pd。 DataFrame([pred [0]]),
---------- -------------------------------------------------- -----------------------------------------------
如果您发现这篇文章有帮助,请给它一个"有用的"投票。
如果有帮助,请记得将回复标记为答案。
This is script which I am using:
import warnings
warnings.filterwarnings('ignore')
import pandas as pd
import sys
import pickle
def azureml_main(dataframe1 = None, dataframe2 = None):
sys.path.append('.\\Script Bundle')
dataframe1 = pickle.load(open(r'/Script Bundle/descript.pkl', 'rb'))
return dataframe1,
but when I execute it , getting below error
FileNotFoundError: [Errno 2] No such file or directory: '/Script
Bundle/descript.pkl'
Process returned with non-zero exit code 1
解决方案
Hello,
I think you should use sys.path.insert() as the path is not set correctly to load the model file.Maybe you can rewrite with the following:
sys.path.insert(0,".\Script Bundle\descript") model=pickle.load(open(".\Script Bundle\descript.pkl", 'rb')) pred=model.predict(dataframe1) return pd.DataFrame([pred[0]]),-----------------------------------------------------------------------------------------------------------
If you found this post helpful, please give it a "Helpful" vote.
Please remember to mark the replies as answers if they help.
这篇关于如何在'执行python脚本'部分中将外部pickle文件内容作为数据框加载到azure ml studio中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文