{"id":1047,"hash":"74e9242a5f0793d2536d36cffb265ba944fe250af6640524b32fcf7096e1bee1","pattern":"ImportError: No module named model_selection","full_message":"I am trying to use train_test_split function and write:\n\nfrom sklearn.model_selection import train_test_split\n\nand this causes \n\nImportError: No module named model_selection\n\nWhy? And how to overcome?","ecosystem":"pypi","package_name":"scikit-learn","package_version":null,"solution":"I guess you have the wrong version of scikit-learn, a similar situation was described here on GitHub. Previously (before v0.18), train_test_split was located in the cross_validation module:\n\nfrom sklearn.cross_validation import train_test_split\n\nHowever, now it's in the model_selection module:\n\nfrom sklearn.model_selection import train_test_split\n\nso you'll need the newest version.\n\nTo upgrade to at least version 0.18, do:\n\npip install -U scikit-learn\n\n(Or pip3, depending on your version of Python). If you've installed it in a different way, make sure you use another method to update, for example when using Anaconda.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/40704484/importerror-no-module-named-model-selection","votes":100,"created_at":"2026-04-19T04:52:13.803111+00:00","updated_at":"2026-04-19T04:52:13.803111+00:00"}