6

I'm trying to reproduce 2 tutorials below using my own dataset instead of MNIST dataset. https://learn.microsoft.com/ja-jp/azure/machine-learning/service/tutorial-auto-train-models https://learn.microsoft.com/ja-jp/azure/machine-learning/service/tutorial-deploy-models-with-aml

About '/notebooks/tutorials/03.auto-train-models.ipynb' there's no problem. I've got 'model.pkl'.

However, '/notebooks/tutorials/02.deploy-models.ipynb' has an error below in 'Predict test data' cell. I guess it's a matter of 'pickle' and 'import'.

Tell me solutions, please.

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-6-11cf888b622f> in <module>
      2 from sklearn.externals import joblib
      3 
----> 4 clf = joblib.load('./model.pkl')
      5 # clf = joblib.load('./sklearn_mnist_model.pkl')
      6 y_hat = clf.predict(X_test)

~/anaconda3_501/lib/python3.6/site-packages/sklearn/externals/joblib/numpy_pickle.py in load(filename, mmap_mode)
    576                     return load_compatibility(fobj)
    577 
--> 578                 obj = _unpickle(fobj, filename, mmap_mode)
    579 
    580     return obj

~/anaconda3_501/lib/python3.6/site-packages/sklearn/externals/joblib/numpy_pickle.py in _unpickle(fobj, filename, mmap_mode)
    506     obj = None
    507     try:
--> 508         obj = unpickler.load()
    509         if unpickler.compat_mode:
    510             warnings.warn("The file '%s' has been generated with a "

~/anaconda3_501/lib/python3.6/pickle.py in load(self)
   1048                     raise EOFError
   1049                 assert isinstance(key, bytes_types)
-> 1050                 dispatch[key[0]](self)
   1051         except _Stop as stopinst:
   1052             return stopinst.value

~/anaconda3_501/lib/python3.6/pickle.py in load_global(self)
   1336         module = self.readline()[:-1].decode("utf-8")
   1337         name = self.readline()[:-1].decode("utf-8")
-> 1338         klass = self.find_class(module, name)
   1339         self.append(klass)
   1340     dispatch[GLOBAL[0]] = load_global

~/anaconda3_501/lib/python3.6/pickle.py in find_class(self, module, name)
   1386             elif module in _compat_pickle.IMPORT_MAPPING:
   1387                 module = _compat_pickle.IMPORT_MAPPING[module]
-> 1388         __import__(module, level=0)
   1389         if self.proto >= 4:
   1390             return _getattribute(sys.modules[module], name)[0]

ModuleNotFoundError: No module named 'automl'
siv7qVI4
  • 63
  • 1
  • 3

2 Answers2

5

you have to include azureml-train-automl package. and you have to do this:

import azureml.train.automl

Hai Ning
  • 386
  • 1
  • 2
4

It seems that you don't have the automl python package installed. It is possible to import it by import azureml.train.automl, but you should really install it using pip.

Follow the guide on this page to see how to set up your python environment for Azure ML services.

For most use cases notebook and automl are the only extra packages needed, so the command

pip install --upgrade azureml-sdk[notebooks,automl]

should be sufficient.

Use pip list to see all installed packages and version number. You should see azureml-train-automl if the package is installed correctly.

  • How would you install these extra packages using an environment.yml file? Can you just have an entry with - azureml-sdk[automl] – Ivo Merchiers Dec 17 '19 at 08:58
  • @IvoMerchiers (I know, I am a year late with my answer, but better late than sorry), I do not have that much experience with .yml files, so I'm not really sure how this would work. I suggest you play around a little, and see what works. – Arvid Bäärnhielm Jan 19 '21 at 13:01
  • 2023 this doesn't seem to work anymore, the azureml.train library is no longer recognized – PJ_ Apr 17 '23 at 18:56