train_val_test_split#

class usencrypt.ai.preprocessing.train_val_test_split(X, y, train_size=0.8, val_size=0.1, test_size=0.1, random_state=None, shuffle=True)#

Splits the input arrays into training, validation, and test sets.

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

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

  • 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 0.8.

  • val_size (float) – A value between 0 and 1 that represents the proportion of the input dataset to include in the validation set. Defaults to 0.1.

  • 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 0.1.

  • 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 the training, validation, and test sets, arranged as (X_train, X_val, X_test, y_train, y_val, y_test).

Return type

tuple

Examples
>>> import numpy as np
>>> import usencrypt as ue
>>> X = np.arange(20).reshape((10, 2))
>>> X
array([[ 0  1],
       [ 2  3],
       [ 4  5],
       [ 6  7],
       [ 8  9],
       [10 11],
       [12 13],
       [14 15],
       [16 17],
       [18 19]])
>>> y = range(10)
>>> list(y)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> X_train, X_val, X_test, y_train, y_val, y_test = ue.ai.preprocessing.train_test_split(X, list(y), random_state=888)
>>> X_train
array([[18 19]
       [10 11]
       [ 6  7]
       [16 17]
       [ 2  3]
       [ 8  9]
       [ 4  5]
       [14 15]] )
>>> X_val
array([[0 1]])
>>> X_test
array([[12 13]])
>>> y_train
array([9 5 3 8 1 4 2 7])
>>> y_val
array([0])
>>> y_test
array([6])