Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between from sklearn.model_selection import train_test_split and from sklearn.cross_validation import train_test_split

Can anyone help me? I am having hard time to know the difference between these

from sklearn.model_selection import train_test_split

from sklearn.cross_validation import train_test_split

In the documentation I saw it is written

"Split arrays or matrices into random train and test subsets"

for both of them.

Which should be used when??

like image 900
Tushar Jajodia Avatar asked Jan 14 '19 10:01

Tushar Jajodia


People also ask

What is from Sklearn Model_selection import Train_test_split?

The train_test_split function of the sklearn. model_selection package in Python splits arrays or matrices into random subsets for train and test data, respectively.

What does Sklearn Cross_validation Train_test_split do?

cross_validation. train_test_split. Quick utility that wraps calls to check_arrays and next(iter(ShuffleSplit(n_samples))) and application to input data into a single call for splitting (and optionally subsampling) data in a oneliner. Python lists or tuples occurring in arrays are converted to 1D numpy arrays.

What is test size and random state in Sklearn Train_test_split?

You should provide either train_size or test_size . If neither is given, then the default share of the dataset that will be used for testing is 0.25 , or 25 percent. random_state is the object that controls randomization during splitting. It can be either an int or an instance of RandomState .

What is the name of the package or class from which the function Train_test_split () is taken?

The scikit-learn Python machine learning library provides an implementation of the train-test split evaluation procedure via the train_test_split() function. The function takes a loaded dataset as input and returns the dataset split into two subsets.


1 Answers

sklearn.cross_validation.train_test_split is deprecated, you should use

from sklearn.model_selection import train_test_split

like image 78
Mikhail Stepanov Avatar answered Sep 30 '22 20:09

Mikhail Stepanov