from sklearn.model_selection import ShuffleSplit # Create a ShuffleSplit object with n_splits=5 and test_size=0.3 ss = ShuffleSplit(n_splits=5, test_size=0.3, random_state=0) # Get the indices of the splits for train_index, test_index in ss.split(X): print("TRAIN:", train_index, "TEST:", test_index)
from sklearn.cross_validation import ShuffleSplit # Create a ShuffleSplit object with n_splits=1 and test_size=0.2 ss = ShuffleSplit(n=10, n_iter=1, test_size=0.2, random_state=0) # Get the indices of the split for train_index, test_index in ss: print("TRAIN:", train_index, "TEST:", test_index)Package Library: The package library used in the above code examples is "sklearn" which stands for scikit-learn. It is a python module for machine learning built on top of the NumPy and SciPy libraries. The module includes a wide range of algorithms for supervised and unsupervised learning tasks such as classification, regression, clustering, and dimensionality reduction.