sup3r.preprocessing.collections.stats.StatsCollection#
- class StatsCollection(containers, means=None, stds=None)[source]#
Bases:
Collection
Extended collection object with methods for computing means and stds and saving these to files.
Note
We write stats as float64 because float32 is not json serializable
- Parameters:
containers (List[Rasterizer]) – List of containers to compute stats for.
means (str | dict | None) – Usually a file path for saving results, or None for just calculating stats and not saving. Can also be a dict, which will just get returned as the “result”.
stds (str | dict | None) – Usually a file path for saving results, or None for just calculating stats and not saving. Can also be a dict, which will just get returned as the “result”.
Methods
check_shared_attr
(attr)Check if all containers have the same value for attr.
get_means
(means)Dictionary of means for each feature, computed across all data handlers.
get_stds
(stds)Dictionary of standard deviations for each feature, computed across all data handlers.
normalize
(containers)Normalize container data with computed stats.
post_init_log
([args_dict])Log additional arguments after initialization.
save_stats
(stds, means)Save stats to json files.
wrap
(data)Return a
Sup3rDataset
object or tuple of such.Attributes
Get weights used to sample from different containers based on relative sizes
Return underlying data.
Get all features contained in data.
Get shape of underlying data.
- get_stds(stds)[source]#
Dictionary of standard deviations for each feature, computed across all data handlers.
Check if all containers have the same value for attr. If they do the collection effectively inherits those attributes.
- property container_weights#
Get weights used to sample from different containers based on relative sizes
- property data#
Return underlying data.
- Returns:
See also
- property features#
Get all features contained in data.
- post_init_log(args_dict=None)#
Log additional arguments after initialization.
- property shape#
Get shape of underlying data.
- wrap(data)#
Return a
Sup3rDataset
object or tuple of such. This is a tuple when the .data attribute belongs to aCollection
object likeBatchHandler
. Otherwise this isSup3rDataset
object, which is either a wrapped 2-tuple or 1-tuple (e.g.len(data) == 2
orlen(data) == 1)
. This is a 2-tuple when.data
belongs to a dual container object likeDualSampler
and a 1-tuple otherwise.