types Module

The skll.types module contains custom type aliases that are used throughout the SKLL code in type hints and docstrings.

skll.types.ClassMap

alias of Dict[str, List[str]]

Class map that maps new labels (string) to list of old labels (list of string).

skll.types.ConfusionMatrix

alias of List[List[int]]

Confusion matrix represented by a list of list of integers.

skll.types.FeatureDict

alias of Dict[str, Any]

Feature dictionary that maps a string to other dictionaries or other objects.

skll.types.FeatureDictList

alias of List[Dict[str, Any]]

List of feature dictionaries.

skll.types.FeaturesetIterator

alias of Iterator[Tuple[skll.data.FeatureSet, skll.data.FeatureSet]]

An iterator over two FeatureSets, usually test and train.

skll.types.FoldMapping

alias of Dict[Union[float, str], str]

Mapping from example ID to fold ID; the example ID may be a float or a string but the fold ID is always a string.

skll.types.IdType

alias of Union[float, str]

A float or a string; this is useful or SKLL IDs that can be both.

skll.types.IndexIterator

alias of Generator[Tuple[ndarray, ndarray], None, None]

Generator over two numpy arrays containing indices - usually for train and test data.

skll.types.LabelType

alias of Union[float, int, str]

A float, integer, or a string; this is useful for SKLL labels that can be any of them.

skll.types.LearningCurveSizes

alias of Union[List[Union[float, int]], ndarray]

Learning curve sizes can either be a numpy array (or a list) containing floats or integers.

skll.types.FeatGenerator

alias of Generator[Tuple[Union[float, str], Optional[Union[float, int, str]], Dict[str, Any]], None, None]

Generator that yields a 3-tuple containing:

  1. An example ID (float or string).

  2. A label (integer, float, or string).

  3. A feature dictionary.

skll.types.PathOrStr

alias of Union[Path, str]

A string path or Path object.

skll.types.SparseFeatureMatrix

alias of csr_matrix

A scipy sparse matrix to hold SKLL features in FeatureSets.

skll.types.ComputeEvalMetricsResults

alias of Tuple[Optional[List[List[int]]], Optional[float], Dict[Union[float, int, str], Any], Optional[float], Dict[str, Optional[float]]]

Learner evaluate task results 5-tuple containing:

  1. The confusion matrix for a classifier, None for a regressor.

  2. Accuracy for a classifier, None for a regressor.

  3. The dictionary of results.

  4. Score for the grid objective, None if no grid search was performed.

  5. The dictionary of scores for any additional metrics.

skll.types.EvaluateTaskResults

alias of Tuple[Optional[List[List[int]]], Optional[float], Dict[Union[float, int, str], Any], Dict[str, Any], Optional[float], Dict[str, Optional[float]]]

Learner evaluate task results 6-tuple containing:

  1. The confusion matrix for a classifier, None for a regressor.

  2. Accuracy for a classifier, None for a regressor.

  3. The dictionary of results.

  4. The dictionary containing the model parameters.

  5. Score for the grid objective, None if no grid search

  6. The dictionary of score for any additional metrics.

skll.types.CrossValidateTaskResults

alias of Tuple[List[Tuple[Optional[List[List[int]]], Optional[float], Dict[Union[float, int, str], Any], Dict[str, Any], Optional[float], Dict[str, Optional[float]]]], List[float], List[Dict[str, Any]], Optional[Dict[Union[float, str], str]], Optional[List[skll.learner.Learner]]]

Learner cross-validate task results 5-tuple containing:

  1. The confusion matrix, overall accuracy, per-label precision/recall/F1, model parameters, objective function score, and evaluation metrics (if any) for each fold.

  2. The grid search scores for each fold.

  3. The list of dictionaries of grid search CV results, one per fold, with keys such as “params”, “mean_test_score”, etc, that are mapped to lists of values associated with each combination of hyper-parameters.

  4. The dictionary containing the test-fold number for each, None if folds were not saved.

  5. The list of learners, one for each fold, None if the models were not saved.

skll.types.VotingCrossValidateTaskResults

alias of Tuple[List[Tuple[Optional[List[List[int]]], Optional[float], Dict[Union[float, int, str], Any], Dict[str, Any], Optional[float], Dict[str, Optional[float]]]], Optional[Dict[Union[float, str], str]], Optional[List[skll.learner.voting.VotingLearner]]]

Voting Learner cross-validate task results 3-tuple containing:

  1. The confusion matrix, overall accuracy, per-label precision/recall/F1, model parameters, objective function score, and evaluation metrics (if any) for each fold.

  2. The dictionary containing the test-fold number for each, None if folds were not saved.

  3. The list of voting learners, one for each fold, None if the models were not saved.