Code Documentation: Data Splitters
mastml.data_splitters Module
This module contains a collection of methods to split data into different types of train/test sets. Data splitters are the core component to evaluating model performance.
- BaseSplitter:
Base class that handles the core MAST-ML data splitting and model evaluation workflow. This class is responsible for looping over provided feature selectors, models, and data splits and training and evaluating the model for each split, then generating the necessary plots and performance statistics. All different splitter types inherit this base class.
- SklearnDataSplitter:
Wrapper class to enable MAST-ML workflow compatible use of any data splitter contained in scikit-learn, e.g. KFold, RepeatedKFold, LeaveOneGroupOut, etc.
- NoSplit:
Class that doesn’t perform any data split. Equivalent to a “full fit” of the data where all data is used in training.
- JustEachGroup:
Class that splits data so each individual group is used as training with all other groups used as testing. Essentially the inverse of LeaveOneGroupOut, this class trains only on one group and predicts the rest, as opposed to training on all but one group and testing on the left-out group.
- LeaveCloseCompositionsOut:
Class to split data based on their compositional similiarity. A useful means to separate compositionally similar compounds into the training or testing set, so that similar materials are not contained in both sets.
- LeaveOutPercent:
Method to randomly split the data based on fraction of total data points, rather than a designated number of splits. Enables one to do higher than 50% leave out (this is highest leave out possible with KFold where k=2), so can do e.g. leave out 90% data.
- LeaveOutTwinCV:
Another method to help separate similar data from the training and testing set. This method makes use of a general distance metric on the provided features, and flags twins as those data points within some provided distance threshold in the feature space.
- LeaveOutClusterCV:
Method to use a clustering algorithm to pre-cluster data into groups. Then, these different groups are used as each left-out data set. Basically functions as a leave out group test where the groups are automatically obtained from a clustering algorithm.
- LeaveMultiGroupOut:
Class to train the model on multiple groups at a time and test it on the rest of the data
- Bootstrap:
Method to perform bootstrap resampling, i.e. random leave-out with replacement.
Functions
|
Return the ceiling of x as an Integral. |
|
Turn seed into a np.random.RandomState instance. |
|
|
|
Helper function to make collections of different types of plots after a single or multiple data splits are evaluated. |
|
Compute the Minkowski distance between two 1-D arrays. |
|
Run some function in parallel. |
|
Pretty-print a Python object to a stream [default is sys.stdout]. |
Classes
Class functioning as a base splitter with methods for organizing output and evaluating any mastml data splitter |
|
|
Methods: |
|
# Note: Bootstrap taken directly from sklearn Github (https://github.com/scikit-learn/scikit-learn/blob/0.11.X/sklearn/cross_validation.py) # which was necessary as it was later removed from more recent sklearn releases Random sampling with replacement cross-validation iterator Provides train/test indices to split data in train test sets while resampling the input n_bootstraps times: each time a new random split of the data is performed and then samples are drawn (with replacement) on each side of the split to build the training and test sets. |
|
Represents a Composition, a mapping of {element/species: amount} with enhanced functionality tailored for handling chemical compositions. |
|
|
|
Class to calculate the atomic fraction of each element in a composition. |
|
Collection of functions to conduct error analysis on certain types of models (uncertainty quantification), and prepare residual and model error data for plotting, as well as recalibrate model errors with various methods |
|
Class to train the model on one group at a time and test it on the rest of the data This class wraps scikit-learn's LeavePGroupsOut with P set to n-1. |
|
Leave-P-out where you exclude materials with compositions close to those the test set |
|
Class to train the model on multiple groups at a time and test it on the rest of the data |
|
Class to generate train/test split using clustering. |
|
Class to train the model using a certain percentage of data as training data |
|
Class to remove data twins from the test data. |
|
Class containing access to a wide range of metrics from scikit-learn and a number of MAST-ML custom-written metrics |
|
Unsupervised learner for implementing neighbor searches. |
|
Class for having a "null" transform where the output is the same as the input. |
|
Class for having a "null" transform where the output is the same as the input. |
|
Class to just train the model on the training data and test it on that same data. |
|
|
|
Class to wrap any scikit-learn based data splitter, e.g. KFold. |
|
The year, month and day arguments are required. |
|
Decorate an iterable object, returning an iterator which acts exactly like the original iterable, but prints a dynamically updating progressbar every time a value is requested. |