vriyal
vriyal

Reputation: 51

How to load an external pickle file contents as a data frame in azure ml studio in the 'execute python script' section?

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

Upvotes: 1

Views: 1634

Answers (1)

Vlad Iliescu
Vlad Iliescu

Reputation: 8221

The model is available under './Script Bundle', you don't need the whole sys.path.append thing. So you can use something like the code below:

import pandas as pd
import pickle

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

    model = pickle.load( open( "./Script Bundle/iris.pkl", "rb" ) )
    cleanFrame = dataframe1[['sepal-length','sepal-width','petal-length','petal-width']]

    prediction = model.predict(cleanFrame)

    dataframe1['Scored Labels'] = prediction

    return dataframe1

You can take a look at this ML Studio experiment for an example.

Upvotes: 1

Related Questions