RamyE / SFU_ML

SFU MSE ML Course Labs and Tools
MIT License
0 stars 3 forks source link

No module named 'sklearn.neighbours._dist_metrics' #21

Open jacob-ango opened 2 years ago

jacob-ango commented 2 years ago

We were able to successfully run the model on the Pi for lab 1, however when we try and process the data for lab 2 we receive the error: ERROR: Acknowledgment Failed, received: EXCEPTION: Problem opening the current model with path /home/pi/SFU_ML/RPi_Script/saved_models/Model_knn.pkl because of exception: No module named 'sklearn.neighbors._dist_metrics' So I tried to reinstall the scikit-learn package, but that did not fix the problem. I also followed all the steps you outlined in the video as well for debugging errors when trying to run the model, but all of them produced the same error. I uploaded a photo as well showing what the processing log tells us when we try and run it. If you have any ideas how to fix this issue, it would be greatly appreciated thank you. error

RamyE commented 2 years ago

Looks like the model may have been trained with a newer version of scikit learn than what’s available on the RPi. Please try to SSH into the raspberry pi and run the following command pip install -U scikit-learn

RamyE commented 2 years ago

If it still doesn’t work, can you check the version of sklearn on the RPi using pip show scikit-learn

RamyE commented 2 years ago

Maybe try replacing pip in the commands above with pip3

jacob-ango commented 2 years ago

Thank you so much! It worked!

cybrkatt commented 2 years ago

Getting the same error message. Using pip install -U scikit-learn or pip3 install -U scikit-learn did not help. Produces the following response.

Capture

jacob-ango commented 2 years ago

@cybrkatt Try downgrading/upgrading the version of scikit-learn on your computer to the same version that is installed on your Pi.

cybrkatt commented 2 years ago

That did it, thank you!

Mahdi-Torabi1997 commented 2 years ago

Hi, I get the same error. I tried all the solutions above but still, I get the same result

photo_2022-03-10_22-33-59 photo_2022-03-10_22-33-59 . image

Mahdi-Torabi1997 commented 2 years ago

Hi, I get the same error. I tried all the solutions above but still, I get the same result

photo_2022-03-10_22-33-59 photo_2022-03-10_22-33-59 . image

Can you help me with this please.

RamyE commented 2 years ago

Which environment is used to train the model ml_course or ml_course_32?

Mahdi-Torabi1997 commented 2 years ago

Which environment is used to train the model ml_course or ml_course_32?

None of them. I used Pycharm to train my model. then I saved the model and now I am sending it to the RPi.

Mahdi-Torabi1997 commented 2 years ago

Hi again I tried downgrading the sklearn and now I get this error. Could you help me with this, please? image

RamyE commented 2 years ago

When you say you tried downgrading, do you mean on the RPi, or the one in the environment used to train the model?

The version on the RPi has to match the version used while training and saving the model. If the latest version have issues, you can try downgrading to an earlier version, but you still have to do it on both.

JiajieJohn1027 commented 2 years ago

Hi, I have installed scikit-learn. The version 1.0.2 is shown in below figure. It still doesn't work. And the version I used to trained in Anaconda is 0.24.2. image image image

RamyE commented 2 years ago

Make sure your pi is running the same version. You can pip3 install scikit-learn==0.24.2

JiajieJohn1027 commented 2 years ago

Make sure your pi is running the same version. You can pip3 install scikit-learn==0.24.2

It can works now. But the recall value and F1-Score are zero in the result. Is that means the model I selected is not right? image

RamyE commented 2 years ago

Possibly, you can always compare with the results you get if you evaluated the model on your PC, which should be the same. I'd also recommend going through the results file where the processed data is saved and you can see for yourself if the numbers make sense. You may have the wrong model or the wrong inputs or the right inputs in the wrong order (which makes them wrong too)