I am using python 2.7 in Ubuntu 14.04. I installed scikit-learn, numpy and matplotlib with these commands:
sudo apt-get install build-essential python-dev p
If you have code that needs to run various versions you could do something like this:
import sklearn
if sklearn.__version__ > '0.18':
from sklearn.model_selection import train_test_split
else:
from sklearn.cross_validation import train_test_split
This isn't ideal though because you're comparing package versions as strings, which usually works but doesn't always. If you're willing to install packaging
, this is a much better approach:
from packaging.version import parse
import sklearn
if parse(sklearn.__version__) > parse('0.18'):
from sklearn.model_selection import train_test_split
else:
from sklearn.cross_validation import train_test_split