Skip to content

histogram

Histogram feature types.

Classes:

Name Description
HistogramFeature

Feature representing a histogram-based data distribution.

HistogramFeature #

Feature representing a histogram-based data distribution.

This feature encodes the statistical distribution of values through histogram bins. It can be used to summarize numerical data, such as activation distributions, probability outputs, or pixel intensity histograms in an image.

Parameters:

Name Type Description Default

bin_names #

tuple[str, ...]

Names of the histogram bins. Each entry typically corresponds to a range or label describing the data segment represented by the bin.

required

bins #

list[float] or None

Numerical values representing the histogram counts or frequencies for each bin.

None

Methods:

Name Description
to_model

Convert to a HistogramFeatureType instance.

from_model

Instantiate from a json response.

Attributes:

Name Type Description
bin_names tuple[str, ...]
bins list[float] | None
name Literal['HISTOGRAM']

bin_names: tuple[str, ...] #

bins: list[float] | None = None #

name: Literal['HISTOGRAM'] = 'HISTOGRAM' #

to_model() -> HistogramFeatureType #

Convert to a HistogramFeatureType instance.

Returns:

Type Description
HistogramFeatureType

A feature model representation including the bin names and bin values.

Source code in src/xpdeep/dataset/feature/feature_types/histogram.py
def to_model(self) -> HistogramFeatureType:
    """Convert to a `HistogramFeatureType` instance.

    Returns
    -------
    HistogramFeatureType
        A feature model representation including the bin names and bin values.
    """
    return HistogramFeatureType(name=self.name, channel_names=list(self.bin_names), bins=self.bins)

from_model(feature_type_input: HistogramFeatureType) -> HistogramFeature #

Instantiate from a json response.

Source code in src/xpdeep/dataset/feature/feature_types/histogram.py
@staticmethod
def from_model(feature_type_input: HistogramFeatureType) -> HistogramFeature:
    """Instantiate from a json response."""
    bin_names = feature_type_input.channel_names
    bins = feature_type_input.bins if not isinstance(feature_type_input.bins, Unset) else None

    return HistogramFeature(bin_names=tuple(bin_names), bins=bins)