handwriting_features.interface.featurizer package

Submodules

handwriting_features.interface.featurizer.exceptions module

handwriting_features.interface.featurizer.handlers module

class handwriting_features.interface.featurizer.handlers.BaseFeatureExtractorHandler[source]

Bases: object

Base class for the feature extractor handlers

features

alias of HandwritingFeatures

mapping

alias of HandwritingFeaturesMapping

pipeline_utils

alias of FeaturesPipelineUtils

validation

alias of HandwritingFeaturesValidation

class handwriting_features.interface.featurizer.handlers.MultiSubjectFeatureExtractorHandler[source]

Bases: BaseFeatureExtractorHandler

Class implementing the multi-subject features extractor handler

classmethod extract(data_values, data_labels=None, pipeline=None, **configuration)[source]

Extracts the features specified in the pipeline for multiple subjects.

Parameters:
  • data_values (numpy.ndarray) – samples values to extract the features from

  • data_labels (list, optional) – labels for data samples, defaults to None

  • pipeline (list, optional) – pipeline of the features, defaults to None

  • configuration (**kwargs) – common extractor configuration

Returns:

extracted features and labels

Return type:

dict {“features”: …, “labels”: …}

extractor

alias of SingleSubjectFeatureExtractorHandler

utils

alias of MultiSubjectFeatureUtils

class handwriting_features.interface.featurizer.handlers.SingleSubjectFeatureExtractorHandler[source]

Bases: BaseFeatureExtractorHandler

Class implementing the single-subject features extractor handler

classmethod extract(data_values, data_labels=None, pipeline=None, preparation=True, **configuration)[source]

Extracts the features specified in the pipeline for a single subject.

Parameters:
  • data_values (numpy.ndarray) – sample values to extract the features from

  • data_labels (list, optional) – labels for data samples, defaults to None

  • pipeline (list, optional) – pipeline of the features, defaults to None

  • preparation (bool, optional) – prepare the pipeline of features, defaults to True

  • configuration (**kwargs) – common extractor configuration

Returns:

extracted features and labels

Return type:

dict {“features”: …, “labels”: …}

utils

alias of SingleSubjectFeatureUtils

handwriting_features.interface.featurizer.utils module

class handwriting_features.interface.featurizer.utils.FeaturesPipelineUtils[source]

Bases: object

Class implementing features pipeline utils

arguments_to_prepare = ['axis', 'in_air']
classmethod prepare_features_pipeline(pipeline)[source]

Prepares the features pipeline.

Parameters:

pipeline (list) – pipeline of the features to be extracted

Returns:

prepared pipeline

Return type:

list

class handwriting_features.interface.featurizer.utils.MultiSubjectFeatureUtils[source]

Bases: object

Class implementing multi-subject feature values/labels utils

classmethod prepare_feature_labels(extracted, pipeline)[source]

Prepares the feature labels.

Parameters:
  • extracted (list) – extracted features

  • pipeline (list) – pipeline of the features to be extracted

Returns:

finalized feature labels

Return type:

list

classmethod prepare_feature_values(extracted, pipeline)[source]

Prepares the feature values.

Parameters:
  • extracted (list) – extracted features

  • pipeline (list) – pipeline of the features to be extracted

Returns:

finalized feature values

Return type:

numpy.ndarray

class handwriting_features.interface.featurizer.utils.SingleSubjectFeatureUtils[source]

Bases: object

Class implementing single-subject feature values/labels utils

features_settings

alias of HandwritingFeaturesSettings

classmethod prepare_feature_labels(extracted, feature_name, feature_args=None)[source]

Prepares the feature labels.

Parameters:
  • extracted (numpy.ndarray) – extracted feature values

  • feature_name (str) – feature name

  • feature_args (dict, optional) – feature arguments, defaults to None

Returns:

prepared feature labels

Return type:

list

classmethod prepare_feature_values(extracted)[source]

Prepares the feature values.

Parameters:

extracted (numpy.ndarray) – extracted feature values

Returns:

prepared feature values

Return type:

numpy.ndarray

Module contents

class handwriting_features.interface.featurizer.FeatureExtractor(values, labels=None, **configuration)[source]

Bases: object

Class implementing the features extractor interface for the Featurizer API.

For more information about featurizer, see the following repositories: 1. [server side](#github.com/BDALab/featurizer-api) 1. [client side](#github.com/BDALab/featurizer-api-client)

For more information about the attributes, see: extract(...)

extract(pipeline)[source]

Interface method: extract the features.

Data

  1. data is of type: numpy.ndarray.

  2. data is mandatory.

  3. data shape: In general, data to have the shape (M, …, D). Where M stands for subjects (i.e. subjects are in the first dimension), and D stands for D data samples (of shape …).

    1. in the case of data having the following shape: (D, ), the API assumes it is a vector of D data sample points for one subject. It transforms the data to a row vector: (1, D) to add the dimension for the subject.

    2: in the case of data having the following shape: (M, …, D),

    the API does not transform the data, but it assumes there are M subjects abd D data samples, each having (…) dimensionality, e.g. if data has the shape (M, 3, 10) it means that there are M subjects and each of the subjects has 10 data samples (each being three dimensional).

Labels

  1. labels are of type: list.

  2. labels are optional.

  3. labels are of length D (for each data sample, there is one label)

Configuration

  1. configuration are of type: dict.

  2. configuration is optional.

  3. configuration provides common kwargs for feature extraction

Pipeline

  1. pipeline is of type: list.

  2. pipeline is mandatory.

  3. each element in the pipeline is of type: dict.

  4. each element in the pipeline has the following keys: a) name to hold the name of the feature to be computed, and b) args to hold the arguments (kwargs) for the specific feature extraction method that is going to be used (it is of type: dict).

Output

The extracted features follow the same shape convention as the input data: the subjects are in the first dimension, and the features are in the last dimension (each feature having shape …).

Parameters:

pipeline (list) – pipeline of the features to be extracted

Returns:

extracted features and labels

Return type:

dict {“features”: …, “labels”: …}