facet.data.partition.IntegerRangePartitioner#
- class facet.data.partition.IntegerRangePartitioner(max_partitions=None)[source]#
Partition integer values in adjacent intervals of the same length.
The range of intervals and interval size is computed based on attributes
max_partitions
,lower_bound
, andupper_bound
.Partition boundaries and interval sized are chosen with interpretability in mind and are always an integer and a power of 10, or a multiple of 2 or 5 of a power of 10, e.g. 1, 2, 5, 10, 20, 50, and so on.
The intervals also satisfy the following conditions:
lower_bound
is within the first intervalupper_bound
is within the last interval
For example, with
max_partitions
= 5,lower_bound
= 3, andupper_bound
= 11, the resulting partitioning would be: [2, 4), [4, 6), [6, 8), [8, 10), [10, 12)- Bases
RangePartitioner
[int64
,int
]- Metaclasses
- Parameters
max_partitions (
Optional
[int
]) – the maximum number of partitions to generate; must be at least 2 (default: 20)
Method summary
Calculate the partitioning for the given observed values.
Attribute summary
DEFAULT_MAX_PARTITIONS
The count of values allocated to each partition.
False
True
if this object is fitted,False
otherwise.The maximum number of partitions to be generated by this partitioner.
Return the endpoints of the intervals that delineate each partition.
The width of each partition.
The values representing the partitions.
Definitions
- fit(values, *, lower_bound=None, upper_bound=None, **fit_params)#
Calculate the partitioning for the given observed values.
The lower and upper bounds of the range to be partitioned can be provided as optional arguments. If no bounds are provided, the partitioner automatically chooses the lower and upper outlier thresholds based on the Tukey test, i.e., \([- 1.5 \cdot \mathit{iqr}, 1.5 \cdot \mathit{iqr}]\) where \(\mathit{iqr}\) is the inter-quartile range.
- Parameters
values (
ndarray
[Any
,dtype
[int64
]]) – a sequence of observed values as the empirical basis for calculating the partitionslower_bound (
Union
[int64
,float
,int
,None
]) – the inclusive lower bound of the elements to partitionupper_bound (
Union
[int64
,float
,int
,None
]) – the inclusive upper bound of the elements to partitionfit_params (
Any
) – optional fitting parameters
- Return type
- Returns
self
- property frequencies_: numpy.ndarray[Any, numpy.dtype[numpy.int64]]#
The count of values allocated to each partition.
- property max_partitions: int#
The maximum number of partitions to be generated by this partitioner.
- Return type
- property partition_bounds_: Sequence[Tuple[T_Values_Scalar, T_Values_Scalar]]#
Return the endpoints of the intervals that delineate each partition.
- property partition_width_: T_Values_Scalar#
The width of each partition.