zfit.data.
Data
Bases: zfit.util.cache.GraphCachable, zfit.core.interfaces.ZfitData, zfit.core.dimension.BaseDimensional, zfit.core.baseobject.BaseObject
zfit.util.cache.GraphCachable
zfit.core.interfaces.ZfitData
zfit.core.dimension.BaseDimensional
zfit.core.baseobject.BaseObject
Create a data holder from a dataset used to feed into models.
dataset (Union[DatasetV2, LightDataset]) – A dataset storing the actual values
Union
DatasetV2
LightDataset
obs (Union[str, Iterable[str], Space, None]) – Observables where the data is defined in
str
Iterable
Space
None
name (Optional[str]) – Name of the Data
Optional
iterator_feed_dict (Optional[Dict]) –
Dict
dtype (Optional[DType]) – The DType of the return value. Defaults to the zfit default (usually float64).
DType
set_weights
Set (temporarily) the weights of the dataset.
weights (Union[Tensor, None, ndarray]) –
Tensor
ndarray
from_root
Create a Data from a ROOT file. Arguments are passed to uproot.
path (str) –
treepath (str) –
branches (Optional[List[str]]) –
List
branches_alias (Optional[Dict]) – A mapping from the branches (as keys) to the actual observables (as values). This allows to have different observable names, independent of the branch name in the file.
weights (Union[Tensor, None, ndarray, str]) – Weights of the data. Has to be 1-D and match the shape of the data (nevents). Can be a column of the ROOT file by using a string corresponding to a column.
name (Optional[str]) –
root_dir_options –
zfit.Data
from_pandas
Create a Data from a pandas DataFrame. If obs is None, columns are used as obs.
df (DataFrame) –
DataFrame
weights (Union[Tensor, None, ndarray]) – Weights of the data. Has to be 1-D and match the shape of the data (nevents).
obs (Union[str, Iterable[str], Space, None]) –
from_numpy
Create Data from a np.array.
obs (Union[str, Iterable[str], Space]) –
array (ndarray) –
Returns:
from_tensor
Create a Data from a tf.Tensor. Value simply returns the tensor (in the right order).
tensor (Tensor) –
to_pandas
Create a pd.DataFrame from obs as columns and return it.
obs (Union[str, Iterable[str], Space, None]) – The observables to use as columns. If None, all observables are used.
unstack_x
Return the unstacked data: a list of tensors or a single Tensor.
obs (Union[str, Iterable[str], Space, None]) – which observables to return
always_list (bool) – If True, always return a list (also if length 1)
bool
List(tf.Tensor)
convert_sort_space
Convert the inputs (using eventually obs, axes) to Space and sort them according to own obs.
axes (Union[int, Iterable[int], None]) –
int
limits (Union[ZfitLimit, Tensor, ndarray, Iterable[float], float, Tuple[float], List[float], bool, None]) –
ZfitLimit
float
Tuple
Optional[Space]
add_cache_deps
Add dependencies that render the cache invalid if they change.
cache_deps (Union[ForwardRef, Iterable[ForwardRef]]) –
ForwardRef
allow_non_cachable (bool) – If True, allow cache_dependents to be non-cachables. If False, any cache_dependents that is not a ZfitCachable will raise an error.
TypeError – if one of the cache_dependents is not a ZfitCachable _and_ allow_non_cachable if False.
name
The name of the object.
register_cacher
Register a cacher that caches values produces by this instance; a dependent.
cacher (Union[ForwardRef, Iterable[ForwardRef]]) –
reset_cache_self
Clear the cache of self and all dependent cachers.