0

I have some trained machine learning model saved in a django project, it is multiple files involved (x.p + x_01.npy + ... + x_0n.npy), and I am trying to load them in views.py, got file not found exception, wonder what is the correct way using joblib or pickle for deserialization in django

def home(request):

    classifierDumpFilesDir = os.path.join(settings.BASE_DIR,'myfiles\ExportedFileName.p')
    classifier = joblib.load(classifierDumpFilesDir)
    prediction = classifier.predict([2,0])



    return render(
        request,
        'app/index.html',
        {
            'title':'Home Page',
            'year':datetime.now().year,
        }
    )
user3453552
  • 199
  • 1
  • 2
  • 11

1 Answers1

0

Got it working by following the instruction from this question

Read a local file in django

joblib works the same way as io file open, but another problem shows up, it requires python virtual environment to publish to Azure. And pip can't insall sklearn package correctly, as described in this post

http://velin-georgiev-blog.appspot.com/blog/how-to-install-numpy-matplotlib-pylab-scipy-on-visual-studio-ptvs-virtual-environment-virtualenv-on-azure

I still did not figure out how to install the sklearn on the virtual environment

Community
  • 1
  • 1
user3453552
  • 199
  • 1
  • 2
  • 11