train_test_split#

class usencrypt.ai.preprocessing.train_test_split(X, y, test_size=None, train_size=None, random_state=None, shuffle=True)#

Splits the input arrays into training and test sets.

Parameters
  • X (list or numpy.ndarray) – The input features.

  • y (list or numpy.ndarray) – The input labels.

  • test_size (float) – A value between 0 and 1 that represents the proportion of the input dataset to include in the test set. Defaults to None. If None, it is set to the complement of the training size. If both are None, it is set to 0.25.

  • train_size (float) – A value between 0 and 1 that represents the proportion of the input dataset to include in the training set. Defaults to None. If None, it is set to the complement of the test size. If both are None, it is set to 0.25.

  • random_state (int) – An integer value used to seed the random number generator used to control the shuffling of the dataset. Defaults to None.

  • shuffle (bool) – Determines whether or not the data is shuffled before being the split. Defaults to True.

Returns

The features and labels for both the training and test sets, arranged as (X_train, X_test, y_train, y_test).

Return type

tuple

Examples
>>> import numpy as np
>>> import usencrypt as ue
>>> X = np.arange(10).reshape((5, 2))
>>> X
array([[0, 1],
       [2, 3],
       [4, 5],
       [6, 7],
       [8, 9]])
>>> y = range(5)
>>> list(y)
[0, 1, 2, 3, 4]
>>> X_train, X_test, y_train, y_test = ue.ai.preprocessing.train_test_split(X, y, test_size=0.33, random_state=888)
>>> X_train
array([[4, 5],
       [0, 1],
       [6, 7]])
>>> y_train
[2, 0, 3]
>>> X_test
array([[2, 3],
       [8, 9]])
>>> y_test
[1, 4]