Representation#
Functional Data#
- class FDApy.representation.functional_data.FunctionalData#
Bases:
ABCMetaclass for the definition of diverse functional data objects.
- Attributes:
n_dimensionGet the number of input dimension of the functional data.
n_obsGet the number of observations of the functional data.
n_pointsGet the number of sampling points.
Methods
center([mean, method_smoothing])Center the data.
concatenate(*fdata)Concatenate FunctionalData objects.
covariance([points, method_smoothing])Compute an estimate of the covariance.
inner_product([method_integration, ...])Compute an estimate of the inner product matrix.
mean([points, method_smoothing])Compute an estimate of the mean.
noise_variance([order])Estimate the variance of the noise.
norm([squared, method_integration, ...])Norm of each observation of the data.
normalize(**kwargs)Normalize the data.
rescale([weights, method_integration, ...])Rescale the data.
smooth([points, method, bandwidth, penalty])Smooth the data.
standardize([center])Standardize the data.
to_long([reindex])Convert the data to long format.
- abstract static concatenate(*fdata: Type[FunctionalData]) Type[FunctionalData]#
Concatenate FunctionalData objects.
- Parameters:
- *fdata: FunctionalData
Functional data to concatenate.
- Raises:
- ValueError
When all fdata do not have the same dimension.
- TypeError
When all fdata do not have the same type.
- abstract property n_obs: int#
Get the number of observations of the functional data.
- abstract property n_dimension: int#
Get the number of input dimension of the functional data.
- abstract property n_points: Tuple[int, ...] | Dict[int, Tuple[int, ...]]#
Get the number of sampling points.
- abstract to_long(reindex: bool = False) DataFrame#
Convert the data to long format.
- abstract noise_variance(order: int = 2) float#
Estimate the variance of the noise.
- abstract smooth(points: DenseArgvals | None = None, method: str = 'PS', bandwidth: float | None = None, penalty: float | None = None, **kwargs) Type[FunctionalData]#
Smooth the data.
- abstract mean(points: DenseArgvals | None = None, method_smoothing: str | None = None, **kwargs) FunctionalData#
Compute an estimate of the mean.
- abstract center(mean: DenseFunctionalData | None = None, method_smoothing: str | None = None, **kwargs) FunctionalData#
Center the data.
- abstract norm(squared: bool = False, method_integration: str = 'trapz', use_argvals_stand: bool = False) ndarray[Any, dtype[float64]]#
Norm of each observation of the data.
- abstract normalize(**kwargs) FunctionalData#
Normalize the data.
- abstract standardize(center: bool = True, **kwargs) FunctionalData#
Standardize the data.
- abstract rescale(weights: float = 0.0, method_integration: str = 'trapz', use_argvals_stand: bool = False, **kwargs) Tuple[FunctionalData, float]#
Rescale the data.
- abstract inner_product(method_integration: str = 'trapz', method_smoothing: str | None = None, noise_variance: float | None = None, **kwargs) ndarray[Any, dtype[float64]]#
Compute an estimate of the inner product matrix.
- abstract covariance(points: DenseArgvals | None = None, method_smoothing: str | None = None, **kwargs) Type[FunctionalData]#
Compute an estimate of the covariance.
- class FDApy.representation.functional_data.GridFunctionalData(argvals: Type[Argvals], values: Type[Values])#
Bases:
FunctionalDataMetaclass for the definition of functional data objects defined on grids.
- Parameters:
- argvals: Type[Argvals]
Sampling points of the functional data.
- values: Type[Values]
Values of the functional data.
- Attributes:
argvalsGetter for argvals.
argvals_standGetter for argvals_stand.
n_dimensionGet the number of input dimension of the functional data.
n_obsGet the number of observations of the functional data.
n_pointsGet the number of sampling points.
valuesGetter for values.
Methods
center([mean, method_smoothing])Center the data.
concatenate(*fdata)Concatenate FunctionalData objects.
covariance([points, method_smoothing])Compute an estimate of the covariance.
inner_product([method_integration, ...])Compute an estimate of the inner product matrix.
mean([points, method_smoothing])Compute an estimate of the mean.
noise_variance([order])Estimate the variance of the noise.
norm([squared, method_integration, ...])Norm of each observation of the data.
normalize(**kwargs)Normalize the data.
rescale([weights, method_integration, ...])Rescale the data.
smooth([points, method, bandwidth, penalty])Smooth the data.
standardize([center])Standardize the data.
to_basis([points, method])Convert the data to basis format.
to_long([reindex])Convert the data to long format.
- abstract property argvals: Type[Argvals]#
Getter for argvals.
- property argvals_stand: Type[Argvals]#
Getter for argvals_stand.
- abstract property values: Type[Values]#
Getter for values.
- property n_obs: int#
Get the number of observations of the functional data.
- Returns:
- int
Number of observations within the functional data.
- property n_dimension: int#
Get the number of input dimension of the functional data.
- Returns:
- int
Number of input dimension with the functional data.
- property n_points: Tuple[int, ...] | Dict[int, Tuple[int, ...]]#
Get the number of sampling points.
- Returns:
- Union[Tuple[int, …], Dict[int, Tuple[int, …]]]
Number of sampling points.
- abstract to_basis(points: DenseArgvals | None = None, method: str = 'PS', **kwargs) BasisFunctionalData#
Convert the data to basis format.
- abstract to_long(reindex: bool = False) DataFrame#
Convert the data to long format.
- abstract noise_variance(order: int = 2) float#
Estimate the variance of the noise.
- abstract smooth(points: DenseArgvals | None = None, method: str = 'PS', bandwidth: float | None = None, penalty: float | None = None, **kwargs) Type[FunctionalData]#
Smooth the data.
- abstract mean(points: DenseArgvals | None = None, method_smoothing: str | None = None, **kwargs) FunctionalData#
Compute an estimate of the mean.
- abstract center(mean: DenseFunctionalData | None = None, method_smoothing: str | None = None, **kwargs) FunctionalData#
Center the data.
- abstract norm(squared: bool = False, method_integration: str = 'trapz', use_argvals_stand: bool = False) ndarray[Any, dtype[float64]]#
Norm of each observation of the data.
- abstract normalize(**kwargs) FunctionalData#
Normalize the data.
- abstract standardize(center: bool = True, **kwargs) FunctionalData#
Standardize the data.
- abstract rescale(weights: float = 0.0, method_integration: str = 'trapz', use_argvals_stand: bool = False, **kwargs) Tuple[FunctionalData, float]#
Rescale the data.
- abstract inner_product(method_integration: str = 'trapz', method_smoothing: str | None = None, noise_variance: float | None = None, **kwargs) ndarray[Any, dtype[float64]]#
Compute an estimate of the inner product matrix.
- abstract covariance(points: DenseArgvals | None = None, method_smoothing: str | None = None, **kwargs) Type[FunctionalData]#
Compute an estimate of the covariance.
- class FDApy.representation.functional_data.DenseFunctionalDataIterator(fdata)#
Bases:
IteratorIterator for DenseFunctionalData object.
- class FDApy.representation.functional_data.DenseFunctionalData(argvals: DenseArgvals, values: DenseValues)#
Bases:
GridFunctionalDataClass for defining Dense Functional Data.
A class used to define dense functional data. We denote by \(n\), the number of observations and by \(p\), the number of input dimensions. Here, we are in the case of univariate functional data, and so the output dimension will be \(\mathbb{R}\). We note by \(X\) an observation, while we use \(X_1, \dots, X_n\) if we refer to a particular set of observations. The observations are defined as:
\[X(t): \mathcal{T} \longrightarrow \mathbb{R},\]where \(\mathcal{T} \subset \mathbb{R}^p\). We denote the mean function by
\[\mu(t): \mathcal{T} \longrightarrow \mathbb{R},\]and the covariance function by:
\[C(s, t): \mathcal{T} \times \mathcal{T} \longrightarrow \mathbb{R}.\]We also note \(\mathbf{M}\) the Gram matrix of the set of observations.
- Parameters:
- argvals: DenseArgvals
The sampling points of the functional data. Each entry of the dictionary represents an input dimension. The shape of the \(j\) th dimension is \((m_j,)\) for \(0 \leq j \leq p\).
- values: DenseValues
The values of the functional data. The shape of the array is \((n, m_1, \dots, m_p)\).
- Attributes:
Methods
center([mean, method_smoothing])Center the data.
concatenate(*fdata)Concatenate DenseFunctional objects.
covariance([points, method_smoothing, ...])Compute an estimate of the covariance function.
inner_product([method_integration, ...])Compute the inner product matrix of the data.
mean([points, method_smoothing])Compute an estimate of the mean.
noise_variance([order])Estimate the variance of the noise.
norm([squared, method_integration, ...])Norm of each observation of the data.
normalize(**kwargs)Normalize the data.
rescale([weights, method_integration, ...])Rescale the data.
smooth([points, method, bandwidth, penalty])Smooth the data.
standardize([center])Standardize the data.
to_basis([points, method, penalty])Convert the data to basis format.
to_long([reindex])Convert the data to long format.
Examples
For 1-dimensional dense data:
>>> argvals = DenseArgvals({'input_dim_0': np.array([1, 2, 3, 4, 5])}) >>> values = DenseValues(np.array([ ... [1, 2, 3, 4, 5], ... [6, 7, 8, 9, 10], ... [11, 12, 13, 14, 15] ... ])) >>> DenseFunctionalData(argvals, values)
For 2-dimensional dense data:
>>> argvals = DenseArgvals({ ... 'input_dim_0': np.array([1, 2, 3, 4]), ... 'input_dim_1': np.array([5, 6, 7]) ... }) >>> values = DenseValues(np.array([ ... [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]], ... [[5, 6, 7], [5, 6, 7], [5, 6, 7], [5, 6, 7]], ... [[3, 4, 5], [3, 4, 5], [3, 4, 5], [3, 4, 5]] ... ])) >>> DenseFunctionalData(argvals, values)
- static concatenate(*fdata: DenseFunctionalData) DenseFunctionalData#
Concatenate DenseFunctional objects.
- Returns:
- DenseFunctionalData
The concatenated object.
- property argvals: Type[Argvals]#
Getter for argvals.
- property values: Type[Values]#
Getter for values.
- to_basis(points: DenseArgvals | None = None, method: str = 'PS', penalty: float | None = None, **kwargs) BasisFunctionalData#
Convert the data to basis format.
This function transform a DenseFunctionalData object into a BasisFunctonalData object using method.
- Parameters:
- points: Optional[DenseArgvals], default=None
The argvals of the basis.
- method: str, default=’PS’
The method to get the coefficients.
- penalty: Optional[float], default=None
Strictly positive. Penalty used in the P-splined fitting of the data.
- kwargs:
Other keyword arguments are passed to the function:
preprocessing.smoothing.PSplines()
- Returns:
- BasisFunctionalData
The expanded data.
- to_long(reindex: bool = False) DataFrame#
Convert the data to long format.
This function transform a DenseFunctionalData object into pandas DataFrame. It uses the long format to represent the DenseFunctionalData object as a dataframe. This is a helper function as it might be easier for some computation, e.g., smoothing of the mean and covariance functions to have a long format.
- Parameters:
- reindex: bool, default=False
Not used here.
- Returns:
- pd.DataFrame
The data in a long format.
Examples
>>> argvals = DenseArgvals({'input_dim_0': np.array([1, 2, 3, 4, 5])}) >>> values = DenseValues(np.array([ ... [1, 2, 3, 4, 5], ... [6, 7, 8, 9, 10], ... [11, 12, 13, 14, 15] ... ])) >>> fdata = DenseFunctionalData(argvals, values)
>>> fdata.to_long() input_dim_0 id values 0 1 0 1 1 2 0 2 2 3 0 3 3 4 0 4 4 5 0 5 5 1 1 6 6 2 1 7 7 3 1 8 8 4 1 9 9 5 1 10 10 1 2 11 11 2 2 12 12 3 2 13 13 4 2 14 14 5 2 15
- noise_variance(order: int = 2) float#
Estimate the variance of the noise.
This function estimates the variance of the noise. The noise is estimated for each individual curve using the methodology in [1]. As the curves are assumed to be generated by the same process, the estimation of the variance of the noise is the mean over the set of curves.
- Parameters:
- order: int, default=2
Order of the difference sequence. The order has to be between 1 and 10. See [1] for more information.
- Returns:
- float
The estimation of the variance of the noise.
References
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=100) >>> kl.add_noise(0.05) >>> kl.noisy_data.noise_variance(order=2) 0.051922438333740877
- smooth(points: DenseArgvals | None = None, method: str = 'PS', bandwidth: float | None = None, penalty: float | None = None, **kwargs) DenseFunctionalData#
Smooth the data.
This function smooths each curves individually. Based on [3], it fits a local polynomial smoother to the data. Based on [1], it fits P-splines to the data.
- Parameters:
- points: Optional[DenseArgvals], default=None
Points at which the curves are estimated. The default is None, meaning we use the argvals as estimation points.
- method: str, default=’PS’
The method to used for the smoothing. If ‘PS’, the method is P-splines [1]. If ‘LP’, the method is local polynomials [3]. Otherwise, it raises an error.
- bandwidth: Optional[float], default=None
Strictly positive. Control the size of the associated neighborhood. If
bandwidth=None, it is assumed that the curves are twice differentiable and the bandwidth is set to \(n^{-1/5}\) [2] where \(n\) is the number of sampling points per curve. Be careful that it will not work if the curves are not sampled on \([0, 1]\).- penalty: Optional[float], default=None
Strictly positive. Penalty used in the P-splined fitting of the data.
- kwargs
Other keyword arguments are passed to one of the following functions:
preprocessing.smoothing.PSplines()(method='PS'),preprocessing.smoothing.LocalPolynomial()(method='LP').
- Returns:
- DenseFunctionalData
Smoothed data.
References
[1] (1,2)Eilers, P. H. C., Marx, B. D. (2021). Practical Smoothing: The Joys of P-splines. Cambridge University Press, Cambridge.
[2]Tsybakov, A.B. (2008), Introduction to Nonparametric Estimation. Springer Series in Statistics.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=1) >>> kl.add_noise(0.05) >>> kl.noisy_data.smooth() Functional data object with 1 observations on a 1-dimensional support.
- mean(points: DenseArgvals | None = None, method_smoothing: str | None = None, **kwargs) DenseFunctionalData#
Compute an estimate of the mean.
This function computes an estimate of the mean curve of a DenseFunctionalData object. As the curves are sampled on a common grid, we consider the sample mean, as defined in [3]. The sampled mean is rate optimal [1]. We included some smoothing using Local Polynonial Estimators [4] or P-Splines [2].
- Parameters:
- points: Optional[DenseArgvals], default=None
The sampling points at which the mean is estimated. If None, the DenseArgvals of the DenseFunctionalData is used.
- method_smoothing: Optional[str], default=None
The method to used for the smoothing. If ‘None’, no smoothing is performed. If ‘PS’, the method is P-splines [2]. If ‘LP’, the method is local polynomials [4].
- kwargs
Other keyword arguments are passed to the following function:
- Returns:
- DenseFunctionalData
An estimate of the mean as a DenseFunctionalData object.
References
[1]Cai, T.T., Yuan, M., (2011), Optimal estimation of the mean function based on discretely sampled functional data: Phase transition. The Annals of Statistics 39, 2330-2355.
[2] (1,2)Eilers, P. H. C., Marx, B. D. (2021). Practical Smoothing: The Joys of P-splines. Cambridge University Press, Cambridge.
[3]Ramsey, J. O. and Silverman, B. W. (2005), Functional Data Analysis, Springer Science, Chapter 8.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=100) >>> kl.add_noise(0.01) >>> kl.noisy_data.mean(smooth=True) Functional data object with 1 observations on a 1-dimensional support.
- center(mean: DenseFunctionalData | None = None, method_smoothing: str | None = None, **kwargs) DenseFunctionalData#
Center the data.
The centering is done by estimating the mean from the data and then substracting it to the data. It results in
\[\widetilde{X}(t) = X(t) - \mu(t).\]- Parameters:
- mean: Optional[DenseFunctionalData], default=None
A precomputed mean as a DenseFunctionalData object.
- method_smoothing: Optional[str], default=None
The method to used for the smoothing of the mean. If ‘None’, no smoothing is performed. If ‘PS’, the method is P-splines [1]. If ‘LP’, the method is local polynomials [2].
- **kwargs
Other keyword arguments are passed to one of the following functions:
DenseFunctionalData.mean()(mean=None),
- Returns:
- DenseFunctionalData
The centered version of the data.
References
[1]Eilers, P. H. C., Marx, B. D. (2021). Practical Smoothing: The Joys of P-splines. Cambridge University Press, Cambridge.
[2]Zhang, J.-T. and Chen J. (2007), Statistical Inferences for Functional Data, The Annals of Statistics, Vol. 35, No. 3.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=10) >>> kl.data.center(smooth=True) Functional data object with 10 observations on a 1-dimensional support.
- norm(squared: bool = False, method_integration: str = 'trapz', use_argvals_stand: bool = False) ndarray[Any, dtype[float64]]#
Norm of each observation of the data.
For each observation in the data, it computes its norm defined in [1] as
\[\| X \| = \left\{\int_{\mathcal{T}} X(t)^2dt\right\}^{\frac12}.\]- Parameters:
- squared: bool, default=`False`
If
True, the function calculates the squared norm, otherwise it returns the norm.- method_integration: str, {‘simpson’, ‘trapz’}, default=’trapz’
The method used to estimate the integral.
- use_argvals_stand: bool, default=False
Use standardized argvals to compute the normalization of the data.
- Returns:
- npt.NDArray[np.float64], shape=(n_obs,)
The norm of each observations.
References
[1]Ramsey, J. O. and Silverman, B. W. (2005), Functional Data Analysis, Springer Science, Chapter 2.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=10) >>> kl.data.norm() array([ 0.53253351, 0.42212112, 0.6709846 , 0.26672898, 0.27440755, 0.37906252, 0.65277413, 0.53998411, 0.2872874 , 0.4934973 ])
- normalize(**kwargs) DenseFunctionalData#
Normalize the data.
The normalization is performed by divising each functional datum \(X\) by its norm \(\| X \|\). It results in
\[\widetilde{X} = \frac{X}{\| X \|}.\]- Parameters:
- **kwargs
Other keyword arguments are passed to the following function:
- Returns:
- DenseFunctionalData
The normalized data.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=10) >>> kl.data.normalize() Functional data object with 10 observations on a 1-dimensional support.
- standardize(center: bool = True, **kwargs) DenseFunctionalData#
Standardize the data.
The standardization is performed by first centering the data and then dividing by the standard deviation curve [1]. It results in
\[\widetilde{X}(t) = C(t, t)^{-\frac12}\{X(t) - \mu(t)\}, \quad t \in \mathcal{T}.\]- Parameters:
- center: bool, default=True
Should the data be centered?
- **kwargs
Other keyword arguments are passed to the following function:
- Returns:
- DenseFunctionalData
The standardized data.
References
[1]Chiou, J.-M., Chen, Y.-T., Yang, Y.-F. (2014). Multivariate Functional Principal Component Analysis: A Normalization Approach. Statistica Sinica 24, 1571–1596.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=10) >>> kl.data.standardize() Functional data object with 10 observations on a 1-dimensional support.
- rescale(weights: float = 0.0, method_integration: str = 'trapz', use_argvals_stand: bool = False, **kwargs) Tuple[DenseFunctionalData, float]#
Rescale the data.
The rescaling is performed by first centering the data and then multiplying with a common weight:
\[\widetilde{X}(t) = w\{X(t) - \mu(t)\}.\]The weights are defined in [1].
- Parameters:
- weights: float, default=0.0
The weights used to normalize the data. If weights = 0.0, the weights are estimated by integrating the variance function [1].
- method_integration: str, {‘simpson’, ‘trapz’}, default=’trapz’
The method used to estimate the integral.
- use_argvals_stand: bool, default=False
Use standardized argvals to compute the normalization of the data.
- Returns:
- Tuple[DenseFunctionalData, float]
The rescaled data and the weight.
References
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=10) >>> kl.data.rescale() Functional data object with 10 observations on a 1-dimensional support.
- inner_product(method_integration: str = 'trapz', method_smoothing: str | None = None, noise_variance: float | None = None, **kwargs) ndarray[Any, dtype[float64]]#
Compute the inner product matrix of the data.
The inner product matrix is a
n_obsbyn_obsmatrix where each entry is defined as\[\langle x, y \rangle = \int_{\mathcal{T}} x(t)y(t)dt, t \in \mathcal{T},\]where \(\mathcal{T}\) is a one- or multi-dimensional domain [3].
- Parameters:
- method_integration: str, {‘simpson’, ‘trapz’}, default=’trapz’
The method used to integrated.
- method_smoothing: Optional[str], default=None
The method to used for the smoothing of the mean. If ‘None’, no smoothing is performed. If ‘PS’, the method is P-splines [2]. If ‘LP’, the method is local polynomials [4].
- noise_variance: Optional[float], default=None
An estimation of the variance of the noise. If None, an estimation is computed using the methodology in [1].
- kwargs
Other keyword arguments are passed to the following function:
- Returns:
- npt.NDArray[np.float64], shape=(n_obs, n_obs)
Inner product matrix of the data.
References
[1]Benko, M., Härdle, W. and Kneip, A. (2009). Common functional principal components. The Annals of Statistics 37, 1–34.
[2]Eilers, P. H. C., Marx, B. D. (2021). Practical Smoothing: The Joys of P-splines. Cambridge University Press, Cambridge.
[3]Ramsey, J. O. and Silverman, B. W. (2005), Functional Data Analysis, Springer Science, Chapter 2.
[4]Zhang, J.-T. and Chen J. (2007), Statistical Inferences for Functional Data, The Annals of Statistics, Vol. 35, No. 3.
Examples
For one-dimensional functional data:
>>> kl = KarhunenLoeve( ... basis_name='bsplines', n_functions=5, random_state=42 ... ) >>> kl.new(n_obs=3) >>> kl.data.inner_product(noise_variance=0) array([ [ 0.16288536, 0.01958865, -0.10017322], [ 0.01958865, 0.17701988, -0.2459348 ], [-0.10017322, -0.2459348 , 0.42008035] ])
For two-dimensional functional data:
>>> kl = KarhunenLoeve( ... basis_name='bsplines', dimension='2D', n_functions=5, ... random_state=42, argvals=np.linspace(0, 1, 11) ... ) >>> kl.new(n_obs=3) >>> kl.data.inner_product(noise_variance=0) array([ [ 0.01669878, 0.00349892, -0.00817676], [ 0.00349892, 0.03208174, -0.03777796], [-0.00817676, -0.03777796, 0.05083159] ])
- covariance(points: DenseArgvals | None = None, method_smoothing: str | None = None, center: bool = True, kwargs_center: Dict[str, object] = {}, **kwargs) DenseFunctionalData#
Compute an estimate of the covariance function.
This function computes an estimate of the covariance surface of a DenseFunctionalData object. As the curves are sampled on a common grid, we consider the sample covariance [2].
- Parameters:
- points: Optional[DenseArgvals], default=None
The sampling points at which the covariance is estimated. If None, the DenseArgvals of the DenseFunctionalData is used. If smooth is False, the DenseArgvals of the DenseFunctionalData is used.
- method_smoothing: Optional[str], default=None
The method to used for the smoothing of the mean. If ‘None’, no smoothing is performed. If ‘PS’, the method is P-splines [1]. If ‘LP’, the method is local polynomials [3].
- center: bool, default=True
Should the data be centered before computing the covariance.
- kwargs_center: Dict[str, object], default={}
Keyword arguments to be passed to the function
FunctionalData.center().- kwargs
Other keyword arguments are passed to the following function:
functional_data._smooth_covariance().
- Returns:
- DenseFunctionalData
An estimate of the covariance as a two-dimensional DenseFunctionalData object.
References
[1]Eilers, P. H. C., Marx, B. D. (2021). Practical Smoothing: The Joys of P-splines. Cambridge University Press, Cambridge.
[2]Ramsey, J. O. and Silverman, B. W. (2005), Functional Data Analysis, Springer Science, Chapter 2.
[3]Zhang, J.-T. and Chen J. (2007), Statistical Inferences for Functional Data, The Annals of Statistics, Vol. 35, No. 3.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=100) >>> kl.add_noise(0.01) >>> kl.noisy_data.covariance(smooth=True) Functional data object with 1 observations on a 2-dimensional support.
- class FDApy.representation.functional_data.IrregularFunctionalDataIterator(fdata)#
Bases:
IteratorIterator for IrregularFunctionalData object.
- class FDApy.representation.functional_data.IrregularFunctionalData(argvals: IrregularArgvals, values: IrregularValues)#
Bases:
GridFunctionalDataA class for defining Irregular Functional Data.
- Parameters:
- argvals: IrregularArgvals
The sampling points of the functional data. Each entry of the dictionary represents an input dimension. Then, each dimension is a dictionary where entries are the different observations. So, the observation \(i\) for the dimension \(j\) is a np.ndarray with shape \((m^i_j,)\) for \(0 \leq i \leq n\) and \(0 \leq j \leq p\).
- values: IrregularValues
The values of the functional data. Each entry of the dictionary is an observation of the process. And, an observation is represented by a np.ndarray of shape \((n, m_1, \dots, m_p)\). It should not contain any missing values.
- Attributes:
Methods
center([mean, method_smoothing])Center the data.
concatenate(*fdata)Concatenate IrregularFunctionalData objects.
covariance([points, method_smoothing, ...])Compute an estimate of the covariance function.
inner_product([method_integration, ...])Compute the inner product matrix of the data.
mean([points, method_smoothing, approx])Compute an estimate of the mean.
noise_variance([order])Estimate the variance of the noise.
norm([squared, method_integration, ...])Norm of each observation of the data.
normalize(**kwargs)Normalize the data.
rescale([weights, method_integration, ...])Rescale the data.
smooth([points, method, bandwidth, penalty])Smooth the data.
standardize([center])Standardize the data.
to_basis([points, method, penalty])Convert the data to basis format.
to_long([reindex])Convert the data to long format.
Examples
For 1-dimensional irregular data:
>>> argvals = IrregularArgvals({ ... 0: DenseArgvals({'input_dim_0': np.array([0, 1, 2, 3, 4])}), ... 1: DenseArgvals({'input_dim_0': np.array([0, 2, 4])}), ... 2: DenseArgvals({'input_dim_0': np.array([2, 4])}) ... }) >>> values = IrregularValues({ ... 0: np.array([1, 2, 3, 4, 5]), ... 1: np.array([2, 5, 6]), ... 2: np.array([4, 7]) ... }) >>> IrregularFunctionalData(argvals, values)
For 2-dimensional irregular data:
>>> argvals = IrregularArgvals({ ... 0: DenseArgvals({ ... 'input_dim_0': np.array([1, 2, 3, 4]), ... 'input_dim_1': np.array([5, 6, 7]) ... }), ... 1: DenseArgvals({ ... 'input_dim_0': np.array([2, 4]), ... 'input_dim_1': np.array([1, 2, 3]) ... }), ... 2: DenseArgvals({ ... 'input_dim_0': np.array([4, 5, 6]), ... 'input_dim_1': np.array([8, 9]) ... }) ... }) >>> values = IrregularValues({ ... 0: np.array([[1, 2, 3], [4, 1, 2], [3, 4, 1], [2, 3, 4]]), ... 1: np.array([[1, 2, 3], [1, 2, 3]]), ... 2: np.array([[8, 9], [8, 9], [8, 9]]) ... }) >>> IrregularFunctionalData(argvals, values)
- static concatenate(*fdata: IrregularFunctionalData) IrregularFunctionalData#
Concatenate IrregularFunctionalData objects.
- Returns:
- IrregularFunctionalData
The concatenated objects.
- property argvals: Type[Argvals]#
Getter for argvals.
- property values: Type[Values]#
Getter for values.
- to_basis(points: DenseArgvals | None = None, method: str = 'PS', penalty: float | None = None, **kwargs) BasisFunctionalData#
Convert the data to basis format.
This function transforms a IrregularFunctionalData object into a BasisFunctonalData object using method.
- Parameters:
- points: Optional[DenseArgvals], default=None
The argvals of the basis.
- method: str, default=’PS’
The method to get the coefficients.
- penalty: Optional[float], default=None
Strictly positive. Penalty used in the P-splined fitting of the data.
- kwargs:
Other keyword arguments are passed to the function:
preprocessing.smoothing.PSplines()
- Returns:
- BasisFunctionalData
The expanded data.
- to_long(reindex: bool = False) DataFrame#
Convert the data to long format.
This function transform a IrregularFunctionalData object into pandas DataFrame. It uses the long format to represent the IrregularFunctionalData object as a dataframe. This is a helper function as it might be easier for some computation, e.g., smoothing of the mean and covariance functions to have a long format.
- Returns:
- pd.DataFrame
The data in a long format.
Examples
For one-dimensional functional data:
>>> argvals = IrregularArgvals({ ... 0: DenseArgvals({'input_dim_0': np.array([0, 1, 2, 3, 4])}), ... 1: DenseArgvals({'input_dim_0': np.array([0, 2, 4])}), ... 2: DenseArgvals({'input_dim_0': np.array([2, 4])}) ... }) >>> values = IrregularValues({ ... 0: np.array([1, 2, 3, 4, 5]), ... 1: np.array([2, 5, 6]), ... 2: np.array([4, 7]) ... }) >>> fdata = IrregularFunctionalData(argvals, values) >>> fdata.to_long() input_dim_0 id values 0 0 0 1 1 1 0 2 2 2 0 3 3 3 0 4 4 4 0 5 5 0 1 2 6 2 1 5 7 4 1 6 8 2 2 4 9 4 2 7
- noise_variance(order: int = 2) float#
Estimate the variance of the noise.
This function estimates the variance of the noise. The noise is estimated for each individual curve using the methodology in [1]. As the curves are assumed to be generated by the same process, the estimation of the variance of the noise is the mean over the set of curves.
TODO: Add multidimensional estimation.
- Parameters:
- order: int, default=2
Order of the difference sequence. The order has to be between 1 and 10. See [1] for more information.
- Returns:
- float
The estimation of the variance of the noise.
References
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=100) >>> kl.sparsify(0.5) >>> kl.sparse_data.noise_variance(order=2) 0.006671248206782777
- smooth(points: DenseArgvals | None = None, method: str = 'PS', bandwidth: float | None = None, penalty: float | None = None, **kwargs) DenseFunctionalData#
Smooth the data.
This function smooths each curves individually. Based on [3], it fits a local polynomial smoother to the data. Based on [1], it fits P-splines to the data.
- Parameters:
- points: Optional[DenseArgvals], default=None
Points at which the curves are estimated. The default is None, meaning we use the argvals as estimation points.
- method: str, default=’PS’
The method to used for the smoothing. If ‘PS’, the method is P-splines [1]. If ‘LP’, the method is local polynomials [3]. Otherwise, it raises an error.
- bandwidth: Optional[float], default=None
Strictly positive. Control the size of the associated neighborhood. If
bandwidth=None, it is assumed that the curves are twice differentiable and the bandwidth is set to \(n^{-1/5}\) [2] where \(n\) is the number of sampling points per curve. Be careful that it will not work if the curves are not sampled on \([0, 1]\).- penalty: Optional[float], default=None
Strictly positive. Penalty used in the P-splined fitting of the data.
- kwargs
Other keyword arguments are passed to one of the following functions:
preprocessing.smoothing.PSplines()(method='PS'),preprocessing.smoothing.LocalPolynomial()(method='LP').
- Returns:
- DenseFunctionalData
Smoothed data.
References
[1] (1,2)Eilers, P. H. C., Marx, B. D. (2021). Practical Smoothing: The Joys of P-splines. Cambridge University Press, Cambridge.
[2]Tsybakov, A.B. (2008), Introduction to Nonparametric Estimation. Springer Series in Statistics.
Examples
For one-dimensional functional data:
>>> argvals = IrregularArgvals({ ... 0: DenseArgvals({'input_dim_0': np.array([0, 1, 2, 3, 4])}), ... 1: DenseArgvals({'input_dim_0': np.array([0, 2, 4])}), ... 2: DenseArgvals({'input_dim_0': np.array([2, 4])}) ... }) >>> values = IrregularValues({ ... 0: np.array([1, 2, 3, 4, 5]), ... 1: np.array([2, 5, 6]), ... 2: np.array([4, 7]) ... }) >>> fdata = IrregularFunctionalData(argvals, values) >>> fdata.smooth() Functional data object with 3 observations on a 1-dimensional support.
- mean(points: DenseArgvals | None = None, method_smoothing: str = 'LP', approx: bool = True, **kwargs) DenseFunctionalData#
Compute an estimate of the mean.
This function computes an estimate of the mean curve of a IrregularFunctionalData object. The curves are not sampled on a common grid. We implement the methodology from [1].
- Parameters:
- points: Optional[DenseArgvals], default=None
The sampling points at which the mean is estimated. If None, the concatenation of the argvals of the IrregularFunctionalData is used.
- method_smoothing: str, default=’LP’
The method to used for the smoothing. If ‘PS’, the method is P-splines [2]. If ‘LP’, the method is local polynomials [1].
- approx: bool, default=True
Approximation of the estimation.
- kwargs
Other keyword arguments are passed to the following function:
- Returns:
- DenseFunctionalData
An estimate of the mean as a DenseFunctionalData object.
References
[1] (1,2)Cai, T.T., Yuan, M., (2011), Optimal estimation of the mean function based on discretely sampled functional data: Phase transition. The Annals of Statistics 39, 2330-2355.
[2]Eilers, P. H. C., Marx, B. D. (2021). Practical Smoothing: The Joys of P-splines. Cambridge University Press, Cambridge.
Examples
For one-dimensional functional data:
>>> argvals = IrregularArgvals({ ... 0: DenseArgvals({'input_dim_0': np.array([0, 1, 2, 3, 4])}), ... 1: DenseArgvals({'input_dim_0': np.array([0, 2, 4])}), ... 2: DenseArgvals({'input_dim_0': np.array([2, 4])}) ... }) >>> values = IrregularValues({ ... 0: np.array([1, 2, 3, 4, 5]), ... 1: np.array([2, 5, 6]), ... 2: np.array([4, 7]) ... }) >>> fdata = IrregularFunctionalData(argvals, values) >>> fdata.mean() Functional data object with 1 observations on a 1-dimensional support.
- center(mean: DenseFunctionalData | None = None, method_smoothing: str = 'LP', **kwargs) IrregularFunctionalData#
Center the data.
- Parameters:
- mean: Optional[DenseFunctionalData], default=None
A precomputed mean as a DenseFunctionalData object.
- method_smoothing: str, default=’LP’
The method to used for the smoothing of the mean. If ‘PS’, the method is P-splines [1]. If ‘LP’, the method is local polynomials [2].
- kwargs
Other keyword arguments are passed to one of the following functions:
- Returns:
- IrregularFunctionalData
The centered version of the data.
References
[1]Eilers, P. H. C., Marx, B. D. (2021). Practical Smoothing: The Joys of P-splines. Cambridge University Press, Cambridge.
[2]Zhang, J.-T. and Chen J. (2007), Statistical Inferences for Functional Data, The Annals of Statistics, Vol. 35, No. 3.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=10) >>> kl.add_noise_and_sparsify(0.01, 0.95) >>> kl.sparse_data.center(smooth=True) Functional data object with 10 observations on a 1-dimensional support.
- norm(squared: bool = False, method_integration: str = 'trapz', use_argvals_stand: bool = False) ndarray[Any, dtype[float64]]#
Norm of each observation of the data.
For each observation in the data, it computes its norm defined in [1] as
\[\| X \| = \left\{\int_{\mathcal{T}} X(t)^2dt\right\}^{\frac12}.\]- Parameters:
- squared: bool, default=False
If True, the function calculates the squared norm, otherwise the result is not squared.
- method_integration: str, {‘simpson’, ‘trapz’}, default = ‘trapz’
The method used to integrated.
- use_argvals_stand: bool, default=False
Use standardized argvals to compute the normalization of the data.
- Returns:
- npt.NDArray[np.float64], shape=(n_obs,)
The norm of each observations.
References
[1]Ramsey, J. O. and Silverman, B. W. (2005), Functional Data Analysis, Springer Science, Chapter 2.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=10) >>> kl.sparsify(percentage=0.5, epsilon=0.05) >>> kl.sparse_data.norm() array([ 0.53419879, 0.40750272, 0.67092435, 0.26762124, 0.27425138, 0.37419987, 0.65775515, 0.54579643, 0.25830787, 0.49324345 ])
- normalize(**kwargs) IrregularFunctionalData#
Normalize the data.
The normalization is performed by divising each functional datum \(X\) by its norm \(\| X \|\). It results in
\[\widetilde{X} = \frac{X}{\| X \|}.\]- Parameters:
- **kwargs
Other keyword arguments are passed to the following function:
- Returns:
- IrregularFunctionalData
The normalized data.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=10) >>> kl.sparsify(percentage=0.5, epsilon=0.05) >>> kl.sparse_data.normalize() Functional data object with 10 observations on a 1-dimensional support.
- standardize(center: bool = True, **kwargs) IrregularFunctionalData#
Standardize the data.
The standardization is performed by first centering the data and then dividing by the standard deviation curve [1]. It results in
\[\widetilde{X}(t) = C(t, t)^{-\frac12}\{X(t) - \mu(t)\}, \quad t \in \mathcal{T}.\]- Parameters:
- center: bool, default=True
Should the data be centered?
- **kwargs
Other keyword arguments are passed to the following functions:
- Returns:
- IrregularFunctionalData
The standardized data.
References
[1]Chiou, J.-M., Chen, Y.-T., Yang, Y.-F. (2014). Multivariate Functional Principal Component Analysis: A Normalization Approach. Statistica Sinica 24, 1571–1596.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=10) >>> kl.sparsify(percentage=0.5, epsilon=0.05) >>> kl.sparse_data.standardize() Functional data object with 10 observations on a 1-dimensional support.
- rescale(weights: float = 0.0, method_integration: str = 'trapz', method_smoothing: str = 'LP', use_argvals_stand: bool = False, **kwargs) Tuple[IrregularFunctionalData, float]#
Rescale the data.
The rescaling is performed by first centering the data and then multiplying with a common weight:
\[\widetilde{X}(t) = w\{X(t) - \mu(t)\}.\]The weights are defined in [1].
- Parameters:
- weights: float, default=0.0
The weights used to normalize the data. If weights = 0.0, the weights are estimated by integrating the variance function [1].
- method_integration: str, {‘simpson’, ‘trapz’}, default = ‘trapz’
The method used to integrated.
- use_argvals_stand: bool, default=False
Use standardized argvals to compute the normalization of the data.
- **kwargs
Other keyword arguments are passed to the following function:
- Returns:
- Tuple[IrregularFunctionalData, float]
The rescaled data and the weight.
References
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=10) >>> kl.sparsify(percentage=0.5, epsilon=0.05) >>> kl.sparse_data.normalize() (Functional data object with 10 observations on a 1-dimensional support., DenseValues(0.16802008))
- inner_product(method_integration: str = 'trapz', method_smoothing: str = 'LP', noise_variance: float | None = None, **kwargs) ndarray[Any, dtype[float64]]#
Compute the inner product matrix of the data.
The inner product matrix is a
n_obsbyn_obsmatrix where each entry is defined as\[\langle x, y \rangle = \int_{\mathcal{T}} x(t)y(t)dt, t \in \mathcal{T},\]where \(\mathcal{T}\) is a one- or multi-dimensional domain.
- Parameters:
- method_integration: str, {‘simpson’, ‘trapz’}, default = ‘trapz’
The method used to integrated.
- method_smoothing: bool, default=True
Should the mean be smoothed?
- noise_variance: Optional[float], default=None
An estimation of the variance of the noise. If None, an estimation is computed using the methodology in [1].
- kwargs
Other keyword arguments are passed to the following function:
- Returns:
- npt.NDArray[np.float64], shape=(n_obs, n_obs)
Inner product matrix of the data.
- Raises:
- NotImplementedError
Not implement for higher-dimensional data.
References
[1]Benko, M., Härdle, W., Kneip, A., (2009), Common functional principal components. The Annals of Statistics 37, 1-34.
Examples
For one-dimensional functional data:
>>> kl = KarhunenLoeve( ... basis_name='bsplines', n_functions=5, random_state=5 ... ) >>> kl.new(n_obs=3) >>> kl.sparsify(percentage=0.8, epsilon=0.05) >>> kl.sparse_data.inner_product(noise_variance=0) array([ [ 0.15749721, 0.01983093, -0.09607059], [ 0.01983093, 0.17937531, -0.24773228], [-0.09607059, -0.24773228, 0.41648575] ])
- covariance(points: DenseArgvals | None = None, method_smoothing: str = 'LP', center: bool = True, smooth: bool = True, kwargs_center: Dict[str, object] = {}, **kwargs) IrregularFunctionalData#
Compute an estimate of the covariance function.
This function computes an estimate of the covariance surface of a IrregularFunctionalData object. As the curves are not sampled on a common grid, we consider the method in [2].
- Parameters:
- points: Optional[DenseArgvals], default=None
The sampling points at which the covariance is estimated. If None, the concatenation of the IrregularArgvals of the IrregularFunctionalData is used.
- method_smoothing: Optional[str], default=None
The method to used for the smoothing of the mean. If ‘PS’, the method is P-splines [1]. If ‘LP’, the method is local polynomials [2].
- kwargs
Other keyword arguments are passed to the following function:
- Returns:
- DenseFunctionalData
An estimate of the covariance as a two-dimensional DenseFunctionalData object.
- Raises:
- NotImplementedError
Not implement for higher-dimensional data.
References
[1]Eilers, P. H. C., Marx, B. D. (2021). Practical Smoothing: The Joys of P-splines. Cambridge University Press, Cambridge.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=100) >>> kl.sparsify(percentage=0.5, epsilon=0.05) >>> kl.sparse_data.covariance() Functional data object with 1 observations on a 2-dimensional support.
- class FDApy.representation.functional_data.BasisFunctionalDataIterator(fdata)#
Bases:
IteratorIterator for BasisFunctionalData object.
- class FDApy.representation.functional_data.BasisFunctionalData(basis: Type[Basis], coefficients: npt.NDArray[np.float64])#
Bases:
FunctionalDataClass for defining Basis Functional Data.
A class used to defined functional data with a basis expansion. We denote by \(n\), the number of observations and by \(p\), the number of input dimensions. Here, we are in the case of univariate functional data, and so the output dimension will be \(\mathbb{R}\). We note by \(X\) an observation, while we use \(X_1, \dots, X_n\) if we refer to a particular set of observations. The observations are defined as:
\[X(t) = \sum_{k = 1}^K c_k \phi_k(t), \quad t \in \mathcal{T},\]where \(\mathcal{T} \subset \mathbb{R}^p\) and the \(\phi_k(t)\) is a set of functions.
- Parameters:
- basis: Basis
The basis of the functional data.
- coefficients: npt.NDArray[np.float64]
The set of coefficients.
- Attributes:
n_dimensionGet the number of input dimension of the functional data.
n_obsGet the number of observations of the functional data.
n_pointsGet the number of sampling points.
Methods
center([mean, method_smoothing])Center the data.
concatenate(*fdata)Concatenate FunctionalData objects.
covariance([points, method_smoothing])Compute an estimate of the covariance.
inner_product([method_integration, ...])Compute an estimate of the inner product matrix.
mean([points, method_smoothing])Compute an estimate of the mean.
noise_variance([order])Estimate the variance of the noise.
norm([squared, method_integration, ...])Norm of each observation of the data.
normalize(**kwargs)Normalize the data.
rescale([weights, method_integration, ...])Rescale the data.
smooth([points, method, bandwidth, penalty])Smooth the data.
standardize([center])Standardize the data.
to_grid()Convert the data to grid format.
to_long([reindex])Convert the data to long format.
- static concatenate(*fdata: Type[FunctionalData]) Type[FunctionalData]#
Concatenate FunctionalData objects.
- Parameters:
- *fdata: FunctionalData
Functional data to concatenate.
- property n_obs: int#
Get the number of observations of the functional data.
- property n_dimension: int#
Get the number of input dimension of the functional data.
- property n_points: Tuple[int, ...] | Dict[int, Tuple[int, ...]]#
Get the number of sampling points.
- to_grid() DenseFunctionalData#
Convert the data to grid format.
- to_long(reindex: bool = False) DataFrame#
Convert the data to long format.
- noise_variance(order: int = 2) float#
Estimate the variance of the noise.
- smooth(points: DenseArgvals | None = None, method: str = 'PS', bandwidth: float | None = None, penalty: float | None = None, **kwargs) Type[FunctionalData]#
Smooth the data.
- mean(points: DenseArgvals | None = None, method_smoothing: str | None = None, **kwargs) FunctionalData#
Compute an estimate of the mean.
- center(mean: DenseFunctionalData | None = None, method_smoothing: str | None = None, **kwargs) FunctionalData#
Center the data.
- norm(squared: bool = False, method_integration: str = 'trapz', use_argvals_stand: bool = False) ndarray[Any, dtype[float64]]#
Norm of each observation of the data.
- normalize(**kwargs) FunctionalData#
Normalize the data.
- standardize(center: bool = True, **kwargs) FunctionalData#
Standardize the data.
- rescale(weights: float = 0.0, method_integration: str = 'trapz', use_argvals_stand: bool = False, **kwargs) Tuple[FunctionalData, float]#
Rescale the data.
- inner_product(method_integration: str = 'trapz', method_smoothing: str | None = None, noise_variance: float | None = None, **kwargs) ndarray[Any, dtype[float64]]#
Compute an estimate of the inner product matrix.
- covariance(points: DenseArgvals | None = None, method_smoothing: str | None = None, **kwargs) Type[FunctionalData]#
Compute an estimate of the covariance.
- class FDApy.representation.functional_data.MultivariateFunctionalData(initlist: List[Type[FunctionalData]])#
Bases:
UserList[Type[FunctionalData]]A class for defining Multivariate Functional Data.
An instance of MultivariateFunctionalData is a list containing objects of the class DenseFunctionalData or IrregularFunctionalData.
- Parameters:
- initlist: List[Type[FunctionalData]]
The list containing the elements of the MultivariateFunctionalData.
- Attributes:
n_dimensionGet the number of input dimension of the functional data.
n_functionalGet the number of functional data with self.
n_obsGet the number of observations of the functional data.
n_pointsGet the mean number of sampling points.
Methods
append(item)Add an item to self.
center([mean, method_smoothing])Center the data.
clear()Remove all items from the list.
concatenate(*fdata)Concatenate MultivariateFunctionalData objects.
count(value)covariance([points, method_smoothing])Compute an estimate of the covariance.
extend(other)Extend the list of FunctionalData by appending from iterable.
index(value, [start, [stop]])Raises ValueError if the value is not present.
inner_product([method_integration, ...])Compute the inner product matrix of the data.
insert(i, item)Insert an item item at a given position i.
mean([points, method_smoothing])Compute an estimate of the mean.
noise_variance([order])Estimate the variance of the noise.
norm([squared, method_integration, ...])Norm of each observation of the data.
normalize(**kwargs)Normalize the data.
pop([i])Remove the item at the given position in the list, and return it.
remove(item)Remove the first item from self where value is item.
rescale([weights, method_integration, ...])Rescale the data.
reverse()Reserve the elements of the list in place.
smooth([points, method, bandwidth, penalty])Smooth the data.
standardize([center])Standardize the data.
to_basis(**kwargs)Convert the data to basis format.
to_grid()Convert the data to grid.
to_long([reindex])Convert the data to long format.
copy
sort
Notes
Be careful that we will not check if all the elements have the same type. It is possible to create MultivariateFunctionalData containing both Dense and Iregular functional data. However, only this two types are allowed to be in the list. The number of observations has to be the same for each element of the list.
Examples
>>> argvals = DenseArgvals({'input_dim_0': np.array([1, 2, 3, 4, 5])}) >>> values = DenseValues(np.array([ ... [1, 2, 3, 4, 5], ... [6, 7, 8, 9, 10], ... [11, 12, 13, 14, 15] ... ])) >>> fdata_dense = DenseFunctionalData(argvals, values)
>>> argvals = IrregularArgvals({ ... 0: DenseArgvals({'input_dim_0': np.array([0, 1, 2, 3, 4])}), ... 1: DenseArgvals({'input_dim_0': np.array([0, 2, 4])}), ... 2: DenseArgvals({'input_dim_0': np.array([2, 4])}) ... }) >>> values = IrregularValues({ ... 0: np.array([1, 2, 3, 4, 5]), ... 1: np.array([2, 5, 6]), ... 2: np.array([4, 7]) ... }) >>> fdata_irregular = IrregularFunctionalData(argvals, values)
>>> MultivariateFunctionalData([fdata_dense, fdata_irregular])
- static concatenate(*fdata: MultivariateFunctionalData) MultivariateFunctionalData#
Concatenate MultivariateFunctionalData objects.
- Parameters:
- data: MultivariateFunctionalData
The data to concatenate with self.
- Returns:
- MultivariateFunctionalData
The concatenation of self and data.
- Raises:
- ValueError
When all fdata do not have the same number of elements.
- property n_obs: int#
Get the number of observations of the functional data.
- Returns:
- int
Number of observations within the functional data.
- property n_functional: int#
Get the number of functional data with self.
- Returns:
- int
Number of functions in the list.
- property n_dimension: List[int]#
Get the number of input dimension of the functional data.
- Returns:
- List[int]
List containing the dimension of each component in the functional data.
- property n_points: List[Dict[str, int]]#
Get the mean number of sampling points.
- Returns:
- List[Union[Tuple[int, …], Dict[int, Tuple[int, …]]]]
A list containing the number of sampling points along each axis for each function.
- append(item: Type[FunctionalData]) None#
Add an item to self.
- Parameters:
- item: Type[FunctionalData]
Item to add.
- extend(other: Iterable[Type[FunctionalData]]) None#
Extend the list of FunctionalData by appending from iterable.
- insert(i: int, item: Type[FunctionalData]) None#
Insert an item item at a given position i.
- remove(item: Type[FunctionalData]) None#
Remove the first item from self where value is item.
- pop(i: int = -1) Type[FunctionalData]#
Remove the item at the given position in the list, and return it.
- clear() None#
Remove all items from the list.
- reverse() None#
Reserve the elements of the list in place.
- to_basis(**kwargs) MultivariateFunctionalData#
Convert the data to basis format.
This function transforms a MultivariateFunctionalData object into a MultivariateFunctionalData that contains BasisFunctionalData.
- Parameters:
- kwargs:
Other keyword arguments are passed to the functions:
representation.functional_data.DenseFunctionalData(),representation.functional_data.IrregularFunctionalData().
- Returns:
- MultivariateFunctionalData
The expanded data.
- to_grid() MultivariateFunctionalData#
Convert the data to grid.
- to_long(reindex: bool = True) List[DataFrame]#
Convert the data to long format.
This function transform a MultivariateFunctionalData object into a list of pandas DataFrame. It uses the long format to represent each element of the MultivariateFunctionalData object as a dataframe. This is a helper function as it might be easier for some computation.
- Returns:
- List[pd.DataFrame]
The data in a long format.
Examples
>>> argvals = DenseArgvals({'input_dim_0': np.array([1, 2, 3, 4, 5])}) >>> values = DenseValues(np.array([ ... [1, 2, 3, 4, 5], ... [6, 7, 8, 9, 10], ... [11, 12, 13, 14, 15] ... ])) >>> fdata_dense = DenseFunctionalData(argvals, values)
>>> argvals = IrregularArgvals({ ... 0: DenseArgvals({'input_dim_0': np.array([0, 1, 2, 3, 4])}), ... 1: DenseArgvals({'input_dim_0': np.array([0, 2, 4])}), ... 2: DenseArgvals({'input_dim_0': np.array([2, 4])}) ... }) >>> values = IrregularValues({ ... 0: np.array([1, 2, 3, 4, 5]), ... 1: np.array([2, 5, 6]), ... 2: np.array([4, 7]) ... }) >>> fdata_irregular = IrregularFunctionalData(argvals, values) >>> fdata = MultivariateFunctionalData([fdata_dense, fdata_irregular])
>>> fdata.to_long() [ input_dim_0 id values 0 1 0 1 1 2 0 2 2 3 0 3 3 4 0 4 4 5 0 5 5 1 1 6 6 2 1 7 7 3 1 8 8 4 1 9 9 5 1 10 10 1 2 11 11 2 2 12 12 3 2 13 13 4 2 14 14 5 2 15, input_dim_0 id values 0 0 0 5 1 1 0 4 2 2 0 3 3 3 0 2 4 4 0 1 5 0 1 5 6 2 1 3 7 4 1 1 8 2 2 5 9 4 2 3]
- noise_variance(order: int = 2) float#
Estimate the variance of the noise.
This function estimates the variance of the noise. The noise is estimated for each individual curve using the methodology in [1]. As the curves are assumed to be generated by the same process, the estimation of the variance of the noise is the mean over the set of curves.
- Parameters:
- order: int, default=2
Order of the difference sequence. The order has to be between 1 and 10. See [1] for more information.
- Returns:
- float
The estimation of the variance of the noise.
References
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', ... n_functions=5, ... random_state=42 ... ) >>> kl.new(n_obs=100) >>> kl.add_noise(0.05) >>> kl.sparsify(0.5) >>> fdata = MultivariateFunctionalData([kl.noisy_data, kl.sparse_data]) >>> fdata.noise_variance [0.051922438333740877, 0.006671248206782777]
- smooth(points: DenseArgvals | None = None, method: str = 'PS', bandwidth: float | None = None, penalty: float | None = None, **kwargs)#
Smooth the data.
This function smooths each curves individually. It fits a local smoother to the data (the argument
degreecontrols the degree of the local fits). All the paraneters have to be passed as a list of the same length of the MultivariateFunctionalData.- Parameters:
- points: Optional[List[DenseArgvals]], default=None
Points at which the curves are estimated. The default is None, meaning we use the argvals as estimation points.
- method: str, default=’PS’
The method to used for the smoothing. If ‘PS’, the method is P-splines [1]. If ‘LP’, the method is local polynomials [3]. Otherwise, it raises an error.
- bandwidth: Optional[List[float]], default=None
Strictly positive. Control the size of the associated neighborhood. If
bandwidth == None, it is assumed that the curves are twice differentiable and the bandwidth is set to \(n^{-1/5}\) [2] where \(n\) is the number of sampling points per curve. Be careful that it will not work if the curves are not sampled on \([0, 1]\).- penalty: Optional[float], default=None
Strictly positive. Penalty used in the P-splined fitting of the data.
- kwargs
Other keyword arguments are passed to one of the following functions:
- Returns:
- MultivariateFunctionalData
Smoothed data.
References
[1]Eilers, P. H. C., Marx, B. D. (2021). Practical Smoothing: The Joys of P-splines. Cambridge University Press, Cambridge.
[2]Tsybakov, A.B. (2008), Introduction to Nonparametric Estimation. Springer Series in Statistics.
[3]Zhang, J.-T. and Chen J. (2007), Statistical Inferences for Functional Data, The Annals of Statistics, Vol. 35, No. 3.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', n_functions=5, random_state=42 ... ) >>> kl.new(n_obs=50) >>> kl.add_noise_and_sparsify(0.05, 0.5)
>>> fdata_1 = kl.data >>> fdata_2 = kl.noisy_data >>> fdata = MultivariateFunctionalData([fdata_1, fdata_2])
>>> points = DenseArgvals({'input_dim_0': np.linspace(0, 1, 11)}) >>> fdata_smooth = fdata.smooth( ... points=[points, points], ... kernel_name=['epanechnikov', 'epanechnikov'], ... bandwidth=[0.05, 0.1], ... degree=[1, 2] ... ) Multivariate functional data object with 2 functions of 50 observations
- mean(points: List[DenseArgvals] | None = None, method_smoothing: str | None = None, **kwargs) MultivariateFunctionalData#
Compute an estimate of the mean.
This function computes an estimate of the mean curve of a MultivariateFunctionalData object.
- Parameters:
- points: Optional[List[DenseArgvals]], default=None
Points at which the mean is estimated. The default is None, meaning we use the argvals as estimation points.
- method_smoothing: Optional[str], default=None
The method to used for the smoothing. If ‘None’, no smoothing is performed. If ‘PS’, the method is P-splines [2]_. If ‘LP’, the method is local polynomials [4]_.
- kwargs
Other keyword arguments are passed to the following function:
- Returns:
- MultivariateFunctionalData
An estimate of the mean as a MultivariateFunctionalData object.
References
[1]Happ and Greven (2018), Multivariate Functional Principal Component Analysis for Data Observed on Different (Dimensional) Domains. Journal of the American Statistical Association, 113, pp. 649–659.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', n_functions=5, random_state=42 ... ) >>> kl.new(n_obs=50) >>> kl.add_noise_and_sparsify(0.05, 0.5)
>>> fdata_1 = kl.data >>> fdata_2 = kl.noisy_data >>> fdata = MultivariateFunctionalData([fdata_1, fdata_2])
>>> points = DenseArgvals({'input_dim_0': np.linspace(0, 1, 11)}) >>> fdata.mean(points=points) Multivariate functional data object with 2 functions of 1 observations.
- center(mean: MultivariateFunctionalData | None = None, method_smoothing: str | None = None, **kwargs) MultivariateFunctionalData#
Center the data.
- Parameters:
- mean: Optional[MultivariateFunctionalData], default=None
A precomputed mean as a MultivariateFunctionalData object.
- method_smoothing: Optional[str], default=None
The method to used for the smoothing of the mean. If ‘None’, no smoothing is performed. If ‘PS’, the method is P-splines [1]_. If ‘LP’, the method is local polynomials [2]_.
- kwargs
Other keyword arguments are passed to one of the following functions:
DenseFunctionalData.mean()(mean=None),
- Returns:
- MultivariateFunctionalData
The centered version of the data.
Examples
>>> kl = KarhunenLoeve( ... basis_name=name, n_functions=n_functions, random_state=42 ... ) >>> kl.new(n_obs=10) >>> kl.add_noise_and_sparsify(0.05, 0.5)
>>> fdata_1 = kl.data >>> fdata_2 = kl.sparse_data >>> fdata = MultivariateFunctionalData([fdata_1, fdata_2]) >>> fdata.center(smooth=True) Functional data object with 10 observations on a 1-dimensional support.
- norm(squared: bool = False, method_integration: str = 'trapz', use_argvals_stand: bool = False) ndarray[Any, dtype[float64]]#
Norm of each observation of the data.
For each observation in the data, it computes its norm defined in [1] as
\[\| X \| = \left\{\int_{\mathcal{T}} X(t)^2dt\right\}^{\frac12}.\]- Parameters:
- squared: bool, default=False
If True, the function calculates the squared norm, otherwise it returns the norm.
- method_integration: str, {‘simpson’, ‘trapz’}, default = ‘trapz’
The method used to integrated.
- use_argvals_stand: bool, default=False
Use standardized argvals to compute the normalization of the data.
- Returns:
- npt.NDArray[np.float64], shape=(n_obs,)
The norm of each observations.
References
[1]Ramsey, J. O. and Silverman, B. W. (2005), Functional Data Analysis, Springer Science, Chapter 2.
Examples
>>> kl = KarhunenLoeve( ... basis_name=name, n_functions=n_functions, random_state=42 ... ) >>> kl.new(n_obs=4) >>> kl.add_noise_and_sparsify(0.05, 0.5)
>>> fdata_1 = kl.data >>> fdata_2 = kl.sparse_data >>> fdata = MultivariateFunctionalData([fdata_1, fdata_2]) >>> fdata.norm() array([1.05384959, 0.84700578, 1.37439764, 0.59235447])
- normalize(**kwargs) MultivariateFunctionalData#
Normalize the data.
The normalization is performed by divising each functional datum \(X\) by its norm \(\| X \|\). It results in
\[\widetilde{X} = \frac{X}{\| X \|}.\]- Parameters:
- **kwargs
Other keyword arguments are passed to the following function:
- Returns:
- MultivariateFunctionalData
The normalized data.
Examples
>>> kl = KarhunenLoeve( ... basis_name=name, n_functions=n_functions, random_state=42 ... ) >>> kl.new(n_obs=4) >>> kl.add_noise_and_sparsify(0.05, 0.5)
>>> fdata_1 = kl.data >>> fdata_2 = kl.sparse_data >>> fdata = MultivariateFunctionalData([fdata_1, fdata_2]) >>> fdata.normalize() Functional data object with 10 observations on a 1-dimensional support.
- standardize(center: bool = True, **kwargs) MultivariateFunctionalData#
Standardize the data.
The standardization is performed by first centering the data and then dividing by the standard deviation curve [1]. It results in
\[\widetilde{X}(t) = C(t, t)^{-\frac12}\{X(t) - \mu(t)\}, \quad t \in \mathcal{T}.\]- Parameters:
- center: bool, default=True
Should the data be centered?
- **kwargs
Other keyword arguments are passed to the following function:
IrregularFunctionalData.stansardize().
- Returns:
- MultivariateFunctionalData
The standardized data.
References
[1]Chiou, J.-M., Chen, Y.-T., Yang, Y.-F. (2014). Multivariate Functional Principal Component Analysis: A Normalization Approach. Statistica Sinica 24, 1571–1596.
Examples
>>> kl = KarhunenLoeve( ... basis_name=name, n_functions=n_functions, random_state=42 ... ) >>> kl.new(n_obs=4) >>> kl.add_noise_and_sparsify(0.05, 0.5)
>>> fdata_1 = kl.data >>> fdata_2 = kl.sparse_data >>> fdata = MultivariateFunctionalData([fdata_1, fdata_2]) >>> fdata.standardize() Functional data object with 10 observations on a 1-dimensional support.
- rescale(weights: ndarray[Any, dtype[float64]] | None = None, method_integration: str = 'trapz', method_smoothing: str = 'LP', use_argvals_stand: bool = False, **kwargs) Tuple[MultivariateFunctionalData, ndarray[Any, dtype[float64]]]#
Rescale the data.
The normalization is performed by divising each functional datum by \(w_j = \int_{T} Var(X(t))dt\).
- Parameters:
- weights: Optional[npt.NDArray[np.float64]], default=None
The weights used to normalize the data. If weights = None, the weights are estimated by integrating the variance function [1].
- method_integration: str, {‘simpson’, ‘trapz’}, default = ‘trapz’
The method used to integrated.
- use_argvals_stand: bool, default=False
Use standardized argvals to compute the normalization of the data.
- **kwargs:
Keyword parameters for the smoothing of the observations.
- Returns:
- Tuple[MultivariateFunctionalData, npt.NDArray[np.float64]]
The normalized data.
References
[1]Happ and Greven (2018), Multivariate Functional Principal Component Analysis for Data Observed on Different (Dimensional) Domains. Journal of the American Statistical Association, 113, pp. 649–659.
Examples
>>> kl = KarhunenLoeve( ... basis_name=name, n_functions=n_functions, random_state=42 ... ) >>> kl.new(n_obs=4) >>> kl.add_noise_and_sparsify(0.05, 0.5)
>>> fdata_1 = kl.data >>> fdata_2 = kl.sparse_data >>> fdata = MultivariateFunctionalData([fdata_1, fdata_2]) >>> fdata.normalize() (Multivariate functional data object with 2 functions of 4 observations., array([0.20365764, 0.19388443]))
- inner_product(method_integration: str = 'trapz', method_smoothing: str | None = None, noise_variance: ndarray[Any, dtype[float64]] | None = None, **kwargs) ndarray[Any, dtype[float64]]#
Compute the inner product matrix of the data.
The inner product matrix is a
n_obsbyn_obsmatrix where each entry is defined as\[\langle\langle x, y \rangle\rangle = \sum_{p = 1}^P \int_{\mathcal{T}_k} x^{(p)}(t)y^{(p)}(t)dt, t \in \mathcal{T},\]where \(\mathcal{T}\) is a one- or multi-dimensional domain.
- Parameters:
- method_integration: str, {‘simpson’, ‘trapz’}, default=’trapz’
The method used to integrated.
- method_smoothing: Optional[str], default=None
Should the mean be smoothed?
- noise_variance: Optional[npt.NDArray[np.float64]], default=None
An estimation of the variance of the noise. If None, an estimation is computed using the methodology in [1].
- kwargs
Other keyword arguments are passed to the following function:
- Returns:
- npt.NDArray[np.float64], shape=(n_obs, n_obs)
Inner product matrix of the data.
References
[1]Benko, M., Härdle, W. and Kneip, A. (2009). Common functional principal components. The Annals of Statistics 37, 1–34.
Examples
>>> kl = KarhunenLoeve( ... basis_name=name, n_functions=n_functions, random_state=42 ... ) >>> kl.new(n_obs=4) >>> kl.add_noise_and_sparsify(0.05, 0.5)
>>> fdata_1 = kl.data >>> fdata_2 = kl.sparse_data >>> fdata = MultivariateFunctionalData([fdata_1, fdata_2]) >>> fdata.inner_product(noise_variance=0) array([ [ 0.39261306, 0.06899153, -0.14614219, -0.0836462 ], [ 0.06899153, 0.32580074, -0.4890299 , 0.07577286], [-0.14614219, -0.4890299 , 0.94953678, -0.09322892], [-0.0836462 , 0.07577286, -0.09322892, 0.17157688] ])
- covariance(points: List[DenseArgvals] | None = None, method_smoothing: str | None = None, **kwargs) MultivariateFunctionalData#
Compute an estimate of the covariance.
This function computes an estimate of the covariance surface of a MultivariateFunctionalData object.
- Parameters:
- points: Optional[List[DenseArgvals]], default=None
Points at which the mean is estimated. The default is None, meaning we use the argvals as estimation points.
- method_smoothing: Optional[str], default=None
Should the mean be smoothed?
- kwargs
Other keyword arguments are passed to the following function:
- Returns:
- MultivariateFunctionalData
An estimate of the covariance as a two-dimensional MultivariateFunctionalData object with same argvals as self.
Examples
>>> kl = KarhunenLoeve( ... basis_name='bsplines', n_functions=5, random_state=42 ... ) >>> kl.new(n_obs=50) >>> kl.add_noise_and_sparsify(0.05, 0.5)
>>> fdata_1 = kl.data >>> fdata_2 = kl.noisy_data >>> fdata = MultivariateFunctionalData([fdata_1, fdata_2])
>>> points = DenseArgvals({'input_dim_0': np.linspace(0, 1, 11)}) >>> fdata.covariance(points=[points, points]) Multivariate functional data object with 2 functions of 1 observations.
Basis#
- class FDApy.representation.basis.Basis(name: Tuple[str] | str = 'bsplines', n_functions: Tuple[int] | int = 5, argvals: DenseArgvals | None = None, values: DenseValues | None = None, is_normalized: bool = False, add_intercept: bool = True, **kwargs)#
Bases:
DenseFunctionalDataDefine univariate orthonormal basis.
- Parameters:
- name: Union[Tuple[str], str], {‘given’, ‘legendre’, ‘wiener’, ‘fourier’, ‘bsplines’}
Denotes the basis of functions to use. The default is bsplines. If name=given, it uses a user defined basis (defined with the argvals and values parameters). For higher dimensional data, name is a tuple for the marginal basis.
- n_functions: Union[Tuple[int], int], default=5
Number of functions in the basis.
- argvals: Optional[DenseArgvals]
The sampling points of the functional data.
- values: Optional[DenseValues]
The values of the functional data. Only used if name=’given’.
- is_normalized: bool, default=False
Should we normalize the basis function?
- add_intercept: bool, default=True
Should the constant functions be into the basis?
- kwargs
Other keyword arguments are passed to the function:
representation.basis._simulate_basis().
- Attributes:
add_interceptGetter for add_intercept.
argvalsGetter for argvals.
argvals_standGetter for argvals_stand.
is_normalizedGetter for is_normalized.
n_dimensionGet the number of input dimension of the functional data.
n_functionsGetter for n_functions.
n_obsGet the number of observations of the functional data.
n_pointsGet the number of sampling points.
nameGetter for name.
valuesGetter for values.
Methods
center([mean, method_smoothing])Center the data.
concatenate(*fdata)Concatenate DenseFunctional objects.
covariance([points, method_smoothing, ...])Compute an estimate of the covariance function.
inner_product([method_integration, ...])Compute the inner product matrix of the basis.
mean([points, method_smoothing])Compute an estimate of the mean.
noise_variance([order])Estimate the variance of the noise.
norm([squared, method_integration, ...])Norm of each observation of the data.
normalize(**kwargs)Normalize the data.
rescale([weights, method_integration, ...])Rescale the data.
smooth([points, method, bandwidth, penalty])Smooth the data.
standardize([center])Standardize the data.
to_basis([points, method, penalty])Convert the data to basis format.
to_long([reindex])Convert the data to long format.
- property name: Tuple[str]#
Getter for name.
- property n_functions: Tuple[int]#
Getter for n_functions.
- property is_normalized: bool#
Getter for is_normalized.
- property add_intercept: bool#
Getter for add_intercept.
- inner_product(method_integration: str = 'trapz', method_smoothing: str | None = None, noise_variance: float | None = None, **kwargs) ndarray[Any, dtype[float64]]#
Compute the inner product matrix of the basis.
- class FDApy.representation.basis.MultivariateBasis(name: List[Tuple[str] | str] = ['fourier', 'legendre'], n_functions: List[Tuple[int] | int] = [5, 5], argvals: List[DenseArgvals] | None = None, values: List[DenseValues] | None = None, is_normalized: bool = False, add_intercept: bool = True, **kwargs)#
Bases:
MultivariateFunctionalDataDefine multivariate orthonormal basis.
- Parameters:
- name: List[Union[Tuple[str], str]]
Name of the basis to use. One of {‘legendre’, ‘wiener’, ‘fourier’, ‘bsplines’}.
- n_functions: List[Union[Tuple[int], int]]
Number of functions in the basis.
- argvals: Optional[List[DenseArgvals]]
The sampling points of the functional data.
- values: Optional[List[DenseValues]]
The values of the functional data. Only used if name=’given’.
- is_normalized: bool, default=False
Should we normalize the basis function?
- kwargs
Other keywords arguments are passed to the function:
representation.basis.Basis().
- Attributes:
add_interceptGetter for add_intercept.
is_normalizedGetter for is_normalized.
n_dimensionGet the number of input dimension of the functional data.
n_functionalGet the number of functional data with self.
n_functionsGetter for n_functions.
n_obsGet the number of observations of the functional data.
n_pointsGet the mean number of sampling points.
nameGetter for name.
Methods
append(item)Add an item to self.
center([mean, method_smoothing])Center the data.
clear()Remove all items from the list.
concatenate(*fdata)Concatenate MultivariateFunctionalData objects.
count(value)covariance([points, method_smoothing])Compute an estimate of the covariance.
extend(other)Extend the list of FunctionalData by appending from iterable.
index(value, [start, [stop]])Raises ValueError if the value is not present.
inner_product([method_integration, ...])Compute the inner product matrix of the data.
insert(i, item)Insert an item item at a given position i.
mean([points, method_smoothing])Compute an estimate of the mean.
noise_variance([order])Estimate the variance of the noise.
norm([squared, method_integration, ...])Norm of each observation of the data.
normalize(**kwargs)Normalize the data.
pop([i])Remove the item at the given position in the list, and return it.
remove(item)Remove the first item from self where value is item.
rescale([weights, method_integration, ...])Rescale the data.
reverse()Reserve the elements of the list in place.
smooth([points, method, bandwidth, penalty])Smooth the data.
standardize([center])Standardize the data.
to_basis(**kwargs)Convert the data to basis format.
to_grid()Convert the data to grid.
to_long([reindex])Convert the data to long format.
copy
sort
- property name: str | List[str]#
Getter for name.
- property n_functions: List[Tuple[int]]#
Getter for n_functions.
- property is_normalized: bool#
Getter for is_normalized.
- property add_intercept: bool#
Getter for add_intercept.