Splitter
rackio_AI.preprocessing.RackioAISplitter()This is a RackioAI preprocessing class to split the data to create a Deep learning model
init(self)Splitter instantiation
Parameters
- None
:return:
- Splitter: (Splitter object)
Snippet code
>>> from rackio_AI import RackioAI
>>> preprocess = RackioAI.get("Preprocessing", _type="Preprocessing")
>>> print(preprocess.splitter)
Splitter Object
{'train_size': None, 'test_size': None, 'validation_size': None, 'random_state': None, 'shuffle': True, 'stratify': None}
split(self, *arrays, **options)Split arrays or matrices into random train and test subsets
Parameters
-
:*arrays: (sequence of indexables with the same length / shape[0]) Allowed inputs are lists, numpy arrays, scipy-sparse matrices or pandas DataFrame
-
:train_size: (float or int, default=None) If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the train split. If int, represents the absolute number of train samples. If None, the value is automatically set to the complement of the test size.
-
:test_size: (float or int, default=None) If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the test split. If int, represents the absolute number of test samples. If None, the value is set to the complement of the train size. If train_size is also None, it will be set to 0.30.
-
:validation_size: (float or int, default=None) If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the validation split. If int, represents the absolute number of test samples. If None, the value is set to the complement of the train size and test size. If train_size is also None, it will be set to 0.0.
-
:random_state: (int or RandomState instance, default=None) Controls the suffling applied to the data before applying split. Pass an int for reproducible output across multiple function calls. See Glosary
-
:shuffle: (bool, default=True) Whether or not to shuffle the data before splitting. If shuffle=False then stratify must be None.
-
:stratify: (array-like, default=None) If not None, data is split in a stratified fashion, using this as the class labels.
:return:
- splitting: (list, length=3 * len(arrays)) list containing train-test split of inputs.
Snippet code
>>> from rackio_AI import RackioAI
>>> import numpy as np
>>> preprocess = RackioAI.get("Preprocessing", _type="Preprocessing")
>>> X, y = np.arange(20).reshape((10, 2)), range(10)
>>> X
array([[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7],
[ 8, 9],
[10, 11],
[12, 13],
[14, 15],
[16, 17],
[18, 19]])
>>> list(y)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Snippet code 2
>>> X_train, X_test, X_validation, y_train, y_test, y_validation = preprocess.splitter.split(X, y, train_size=0.6, test_size=0.2, validation_size=0.2, random_state=0)
>>> X_train
array([[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7],
[ 8, 9],
[10, 11]])
>>> X_test
array([[12, 13],
[14, 15]])
>>> X_validation
array([[16, 17],
[18, 19]])
>>> y_train
[0, 1, 2, 3, 4, 5]
>>> y_test
[6, 7]
>>> y_validation
[8, 9]
Snippet code 3
>>> X_train, X_test, y_train, y_test = preprocess.splitter.split(X, y, train_size=0.6, test_size=0.4, random_state=0)
>>> X_train
array([[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7],
[ 8, 9],
[10, 11]])
>>> X_test
array([[12, 13],
[14, 15],
[16, 17],
[18, 19]])
>>> y_train
[0, 1, 2, 3, 4, 5]
>>> y_test
[6, 7, 8, 9]