I am trying to build a project, where I will get the data from the webpage and it will be passed to my ML model, the predictions of which will be shown finally. The model is completed and I have it in the .sav - named as "litemodel.sav" and below is the code for the same.
Below is the text snippet of the error that I am getting. Since there isn't a description attached to it, it is getting difficult to debug. Anyone encountered a similar issue?
Traceback (most recent call last):
File "E:\__COURSE IIT\XYZ\ROAD\main.py", line 10, in <module>
model = joblib.load('litemodel.sav')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mitta\AppData\Local\Programs\Python\Python312\Lib\site-packages\joblib\numpy_pickle.py", line 658, in load
obj = _unpickle(fobj, filename, mmap_mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mitta\AppData\Local\Programs\Python\Python312\Lib\site-packages\joblib\numpy_pickle.py", line 577, in _unpickle
obj = unpickler.load()
^^^^^^^^^^^^^^^^
File "C:\Users\mitta\AppData\Local\Programs\Python\Python312\Lib\pickle.py", line 1205, in load
dispatch[key[0]](self)
File "C:\Users\mitta\AppData\Local\Programs\Python\Python312\Lib\pickle.py", line 1521, in load_global
klass = self.find_class(module, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mitta\AppData\Local\Programs\Python\Python312\Lib\pickle.py", line 1572, in find_class
__import__(module, level=0)
ModuleNotFoundError: No module named 'sklearn.ensemble.forest'
Below is the code producing the error:
from flask import Flask, render_template, request
import pandas as pd
import numpy as np
import urllib.request
import urllib.parse
import joblib
app = Flask(__name__)
model = joblib.load('litemodel.sav')
[1. joblib is installed in the system (I have checked it - below is the text snippet confirming it) ]
PS E:\__COURSE IIT\XYZ\ROAD> pip install joblib
Requirement already satisfied: joblib in c:\users\mitta\appdata\local\programs\python\python312\lib\site-packages (1.3.2)
UPDATE
Below is the new error (should I get my python to lower version?)
File "E:\__COURSE IIT\BTP\ROAD-ACCIDENTS-PREDICTION-AND-CLASSIFICATION\main.py", line 10, in <module>
model = joblib.load('litemodel.sav')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mitta\AppData\Local\Programs\Python\Python312\Lib\site-packages\joblib\numpy_pickle.py", line 658, in load
obj = _unpickle(fobj, filename, mmap_mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mitta\AppData\Local\Programs\Python\Python312\Lib\site-packages\joblib\numpy_pickle.py", line 591, in _unpickle
raise new_exc
ValueError: You may be trying to read with python 3 a joblib pickle generated with python 2. This feature is not supported by joblib.
How to resolve this?