SklearnDataSplitter

class mastml.data_splitters.SklearnDataSplitter(splitter, **kwargs)[source]

Bases: mastml.data_splitters.BaseSplitter

Class to wrap any scikit-learn based data splitter, e.g. KFold

Args:

splitter (str): string denoting the name of a sklearn.model_selection object, e.g. ‘KFold’ will draw from sklearn.model_selection.KFold()

kwargs : key word arguments for the sklearn.model_selection object, e.g. n_splits=5 for KFold()

Methods:
get_n_splits: method to calculate the number of splits to perform
Args:
None
Returns:
(int), number of train/test splits
split: method to perform split into train indices and test indices
Args:
X: (numpy array), array of X features
Returns:
(numpy array), array of train and test indices
_setup_savedir: method to create a savedir based on the provided model, splitter, selector names and datetime
Args:

model: (mastml.models.SklearnModel or other estimator object), an estimator, e.g. KernelRidge

selector: (mastml.feature_selectors or other selector object), a selector, e.g. EnsembleModelFeatureSelector

savepath: (str), string designating the savepath

Returns:
splitdir: (str), string containing the new subdirectory to save results to

Methods Summary

get_n_splits([X, y, groups]) Returns the number of splitting iterations in the cross-validator
split(X[, y, groups]) Generate indices to split data into training and test set.

Methods Documentation

get_n_splits(X=None, y=None, groups=None)[source]

Returns the number of splitting iterations in the cross-validator

split(X, y=None, groups=None)[source]

Generate indices to split data into training and test set.

X : array-like of shape (n_samples, n_features)
Training data, where n_samples is the number of samples and n_features is the number of features.
y : array-like of shape (n_samples,)
The target variable for supervised learning problems.
groups : array-like of shape (n_samples,), default=None
Group labels for the samples used while splitting the dataset into train/test set.
train : ndarray
The training set indices for that split.
test : ndarray
The testing set indices for that split.