notice

This is documentation for Rasa Documentation v2.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (3.x).

Version: 2.x

rasa.shared.nlu.training_data.features

Features Objects

class Features()

Stores the features produced by any featurizer.

__init__

| __init__(features: Union[np.ndarray, scipy.sparse.spmatrix], feature_type: Text, attribute: Text, origin: Union[Text, List[Text]]) -> None

Initializes the Features object.

Arguments:

  • features - The features.
  • feature_type - Type of the feature, e.g. FEATURE_TYPE_SENTENCE.
  • attribute - Message attribute, e.g. INTENT or TEXT.
  • origin - Name of the component that created the features.

is_sparse

| is_sparse() -> bool

Checks if features are sparse or not.

Returns:

True, if features are sparse, false otherwise.

is_dense

| is_dense() -> bool

Checks if features are dense or not.

Returns:

True, if features are dense, false otherwise.

combine_with_features

| combine_with_features(additional_features: Optional["Features"]) -> None

Combine the incoming features with this instance's features.

Arguments:

  • additional_features - additional features to add

Returns:

Combined features.

__key__

| __key__() -> Tuple[
| Text, Text, Union[np.ndarray, scipy.sparse.spmatrix], Union[Text, List[Text]]
| ]

Returns a 4-tuple of defining properties.

Returns:

Tuple of type, attribute, features, and origin properties.

__eq__

| __eq__(other: Any) -> bool

Tests if the self Feature equals to the other.

Arguments:

  • other - The other object.

Returns:

True when the other object is a Feature and has the same type, attribute, and feature tensors.