0

I am setting up a Machine Learning model using Linear Regression however trying to run

from sklearn.model_selection import train_test_split 

throws below exception:

ImportError: cannot import name '_argmax' from 'sklearn.utils.fixes'

I am working with PyCharm (Jupyter notebook) and also tried restarting kernel.

However, when I try to run code from Pycharm in a Python file it works.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
JavaMan
  • 465
  • 1
  • 6
  • 21
  • Are you sure you have installed the package correctly? `from sklearn.model_selection import train_test_split` succeeds for me with no errors. What happens when you try to import it in the REPL? – Spirit Pony Jun 11 '22 at 14:31
  • To be honest, I don't get this error when I try to run code from a python file however, I see this error when I try to run this from a Jupyter file in Pycharm. – JavaMan Jun 11 '22 at 14:38
  • Perhaps this could help you? [Import errors with Pycharm](https://stackoverflow.com/questions/19891648/import-errors-with-pycharm) – Spirit Pony Jun 11 '22 at 14:40
  • I started Jupyter from Anaconda and tried running the import. It raised the same exception so seems this something related to Jupyter. Also, I tried downgrading to Python 3.7 following by installing Jupyter, sklearn package again in Pycharm however even that didn't work i.e. it still throws an exception. – JavaMan Jun 11 '22 at 14:54

1 Answers1

0

I reinstalled sklearn followed by creating conda virtual environment. I then used this newly created conda venv from Pycharm and the code start working i.e. PyCharm no longer raised import error.

JavaMan
  • 465
  • 1
  • 6
  • 21