feets.extractors package¶
Submodules¶
feets.extractors.ext_amplitude module¶
Amplitude extractor.
- class feets.extractors.ext_amplitude.Amplitude(**kwargs)[source]¶
Bases:
LightCurveExtractorHalf amplitude of magnitude.
Amplitude (\(A\))
\[A = \frac{\left( \max{(m)} - \min{(m)} \right)}{2}\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
See also
feets.extractors.MedianAmplitude
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_anderson_darling module¶
Anderson-Darling extractor.
- class feets.extractors.ext_anderson_darling.AndersonDarling(**kwargs)[source]¶
Bases:
LightCurveExtractorUnbiased Anderson-Darling normality test statistic.
AndersonDarling (\(A^2\))
\[\begin{split}A^2 = & \left(1 + \frac{4}{N} - \frac{25}{N^2}\right) \cdot \\ & \left(-N - \frac{1}{N} \sum_{i=0}^{N-1} (2i + 1)\ln\Phi_i + (2(N - i) - 1)\ln(1 - \Phi_i)\right)\end{split}\]where \(\Phi_i = \Phi((m_i - \langle m \rangle) / \sigma_m)\) is the standard cumulative distribution, \(N\) is the number of observations, \(\langle m \rangle\) is the mean magnitude and \(\sigma_m\) is the magnitude standard deviation:
\[\sigma_m = \sqrt{\frac{\sum_i (m_i - \langle m \rangle)^2}{N-1}}\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘lg’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_astropy_lomb_scargle module¶
Lomb-Scargle extractor.
- class feets.extractors.ext_astropy_lomb_scargle.AstropyLombScargle(**kwargs)[source]¶
Bases:
ExtractorLomb-Scargle extractor.
PeriodLS
The Lomb-Scargle (L-S) algorithm (Scargle, 1982) is a variation of the Discrete Fourier Transform (DFT), in which a time series is decomposed into a linear combination of sinusoidal functions. The basis of sinusoidal functions transforms the data from the time domain to the frequency domain. DFT techniques often assume evenly spaced data points in the time series, but this is rarely the case with astrophysical time-series data. Scargle has derived a formula for transform coefficients that is similiar to the DFT in the limit of evenly spaced observations. In addition, an adjustment of the values used to calculate the transform coefficients makes the transform invariant to time shifts.
The Lomb-Scargle periodogram is optimized to identify sinusoidal-shaped periodic signals in time-series data. Particular applications include radial velocity data and searches for pulsating variable stars. L-S is not optimal for detecting signals from transiting exoplanets, where the shape of the periodic light-curve is not sinusoidal.
Period_fit
The false alarm probability of the largest periodogram value.
Psi_CS (\(\Psi_{CS}\))
\(R_{CS}\) applied to the phase-folded light curve (generated using the period estimated from the Lomb-Scargle method).
Psi_eta (\(\Psi_{\eta}\))
\(\eta^e\) index calculated from the folded light curve.
- Parameters:
- lscargle_kwdsdict, optional
Keyword arguments for the Lomb-Scargle algorithm.
- fap_kwdsdict, optional
Keyword arguments for the false alarm probability calculation.
- nperiodsint, optional, default: 3
Number of periods to extract.
See also
feets.extractors.LightCurveLombScargle
References
[kim2011quasi]Kim, D. W., Protopapas, P., Byun, Y. I., Alcock, C., Khardon, R., & Trichas, M. (2011). Quasi-stellar object selection algorithm using time variability and machine learning: Selection of 1620 quasi-stellar object candidates from MACHO Large Magellanic Cloud database. The Astrophysical Journal, 735(2), 68. Doi:10.1088/0004-637X/735/2/68.
[kim2014epoch]Kim, D. W., Protopapas, P., Bailer-Jones, C. A., Byun, Y. I., Chang, S. W., Marquette, J. B., & Shin, M. S. (2014). The EPOCH Project: I. Periodic Variable Stars in the EROS-2 LMC Database. arXiv preprint Doi:10.1051/0004-6361/201323252.
Examples
>>> fs = feets.FeatureSpace(only=[ ... "PeriodLS", ... "Period_fit", ... "Psi_CS", ... "Psi_eta", ... ]) >>> features = fs.extract(**lc_periodic) >>> features[0] {'Psi_CS': array([0.23320451, 0.19688377, 0.23320451]), 'Psi_eta': array([0.11139146, 0.11139146, 0.11139146]), 'PeriodLS': array([0.02085484, 0.0204288 , 0.02001982]), 'Period_fit': array([6.30747594e-24, 4.58745915e-24, 3.32221561e-24])}
- feets.extractors.ext_astropy_lomb_scargle.lscargle(time, magnitude, nfrequencies, error=None, model_kwds=None, autopower_kwds=None, fap_kwds=None)[source]¶
Calculate Lomb-Scargle periodogram.
- Parameters:
- timearray-like
Time values of the light curve.
- magnitudearray-like
Magnitude values of the light curve.
- nfrequenciesint
Number of frequencies to extract.
- errorarray-like, optional
Error values of the light curve.
- model_kwdsdict, optional
Keyword arguments for the Lomb-Scargle model.
- autopower_kwdsdict, optional
Keyword arguments for the autopower method.
- fap_kwdsdict, optional
Keyword arguments for the false alarm probability calculation.
- Returns:
- frequencyarray-like
Frequency values.
- fmaxarray-like
Indexes of the nfrequencies largest power values.
- faparray-like
False alarm probability values.
feets.extractors.ext_autocor_length module¶
Auto-correlation length extractor.
- class feets.extractors.ext_autocor_length.AutocorLength(**kwargs)[source]¶
Bases:
ExtractorAuto-correlation length extractor.
Autocor_length
The autocorrelation, also known as serial correlation, is the cross-correlation of a signal with itself. Informally, it is the similarity between observations as a function of the time lag between them. It is a mathematical tool for finding repeating patterns, such as the presence of a periodic signal obscured by noise, or identifying the missing fundamental frequency in a signal implied by its harmonic frequencies.
For an observed series \(y_1, y_2,\dots,y_T\) with sample mean \(\bar{y}\), the sample lag-\(h\) autocorrelation is given by:
\[\rho_h = \frac{\sum_{t=h+1}^T (y_t - \bar{y})(y_{t-h}-\bar{y})} {\sum_{t=1}^T (y_t - \bar{y})^2}\]Since the autocorrelation fuction of a light curve is given by a vector and we can only return one value as a feature, we define the length of the autocorrelation function where its value is smaller than \(e^{-1}\) .
References
[kim2011quasi]Kim, D. W., Protopapas, P., Byun, Y. I., Alcock, C., Khardon, R., & Trichas, M. (2011). Quasi-stellar object selection algorithm using time variability and machine learning: Selection of 1620 quasi-stellar object candidates from MACHO Large Magellanic Cloud database. The Astrophysical Journal, 735(2), 68. Doi:10.1088/0004-637X/735/2/68.
feets.extractors.ext_bazin_fit module¶
Bazin fit extractor.
- class feets.extractors.ext_bazin_fit.BazinFit(**kwargs)[source]¶
Bases:
LightCurveExtractorBazin function fit.
Five fit parameters and goodness of fit (reduced \(\chi^2\)) of the Bazin function developed for core-collapsed supernovae:
\[f(t) = A \frac{ \mathrm{e}^{ -(t-t_0)/\tau_\mathrm{fall} } }{ 1 + \mathrm{e}^{ -(t - t_0)/\tau_\mathrm{rise} } } + B.\]Note, that the Bazin function is developed to be used with fluxes, not magnitudes. Also note a typo in the Eq. (1) of the original paper ([bazin2009supernova]), the minus sign is missed in the “rise” exponent.
BazinFit_Amplitude (\(A\))
Half amplitude of the Bazin function.
BazinFit_Baseline (\(B\))
Baseline of the Bazin function.
BazinFit_ReferenceTime (\(t_0\))
Reference time of the Bazin fit.
BazinFit_RiseTime (\(\tau_\mathrm{rise}\))
Rise time of the Bazin function.
BazinFit_FallTime (\(\tau_\mathrm{fall}\))
Fall time of the Bazin function.
BazinFit_ReducedChi2 (reduced \(\chi^2\))
Bazin fit quality.
- Parameters:
- algorithmstr
Non-linear least-square algorithm, supported values are: ‘mcmc’, ‘ceres’, ‘mcmc-ceres’, ‘lmsder’, ‘mcmc-lmsder’.
- mcmc_niterint, optional
Number of MCMC iterations, default is 128
- ceres_niterint, optional
Number of Ceres iterations, default is 10
- ceres_loss_regfloat, optional
Ceres loss regularization, default is to use square norm as is, if set to a number, the loss function is regularized to discriminate outlier residuals larger than this value. Default is None which means no regularization.
- lmsder_niterint, optional
Number of LMSDER iterations, default is 10
- initlist or None, optional
Initial conditions, must be None or a list of float`s or `None`s. The length of the list must be 5, `None values will be replaced with some default values. It is supported by MCMC only
- boundslist of tuples or None, optional
Boundary conditions, must be None or a list of tuple`s of `float`s or `None`s. The length of the list must be 5, boundary conditions must include initial conditions, `None values will be replaced with some broad defaults. It is supported by MCMC only
- ln_priorstr or list of ln_prior.LnPrior1D or None, optional
Prior for MCMC, None means no prior. It is specified by a string literal or a list of 5 light_curve.ln_prior.LnPrior1D objects, see light_curve.ln_prior submodule for corresponding functions. Available string literals are:
‘no’: no prior
- transformstr or bool or None, optional
If False or None (default) output is not transformed. If True output is transformed as following:
Half-amplitude A is transformed as \(zp - 2.5 lg(2*A)\), \(zp = 8.9\), so that the amplitude is assumed to be the object peak flux in Jy.
baseline flux is normalised by \(A: baseline -> baseline / A\)
reference time is removed
goodness of fit is transformed as \(ln(reduced chi^2 + 1)\) to reduce its spread
other parameters are not transformed
References
[bazin2009supernova]Bazin, G., Palanque-Delabrouille, N., Rich, J., Ruhlmann-Kleider, V., Aubourg, E., Le Guillou, L., … & Walker, E. S. (2009). The core-collapse rate from the Supernova Legacy Survey. Astronomy & Astrophysics, 499(3), 653-660.
- extract(time, flux, flux_error)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- fluxarray-like
- flux_errorarray-like
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_beyond_n_std module¶
Beyond-N-standard-deviation extractor.
- class feets.extractors.ext_beyond_n_std.BeyondNStd(**kwargs)[source]¶
Bases:
LightCurveExtractorBeyond-N-standard-deviation extractor.
BeyondNStd
Fraction of observations beyond \(N\,\sigma_m\) from the mean magnitude \(\langle m \rangle\).
\[\mathrm{beyond}~n\,\sigma_m = \frac{ \sum_i I_{|m - \langle m \rangle| > n\,\sigma_m}(m_i) }{N}\]where \(I\) is the indicator function, \(N\) is the number of observations, \(\langle m \rangle\) is the mean magnitude and \(\sigma_m = \sqrt{\sum_i (m_i - \langle m \rangle)^2 / (N-1)}\) is the magnitude standard deviation.
- Parameters:
- nstdpositive float, default=1
N, default is 1.0
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
See also
feets.extractors.WeightedBeyondNStd
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
- flatten_feature(feature, value)[source]¶
Normalize a feature value into a dictionary of scalars.
This method is called internally to better represent the returned features of the extract() method.
- Parameters:
- featurestr
The name of the feature.
- valueobject
The raw value as received by the extract() method.
- Returns:
- dict
A dictionary of scalars representing the flattened feature.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_car module¶
CAR extractor.
- class feets.extractors.ext_car.CAR(**kwargs)[source]¶
Bases:
ExtractorCAR extractor.
In order to model the irregular sampled times series we use CAR (Brockwell and Davis, 2002), a continious time auto regressive model.
CAR process has three parameters, it provides a natural and consistent way of estimating a characteristic time scale and variance of light-curves. CAR process is described by the following stochastic differential equation:
\[\begin{split}dX(t) = - \frac{1}{\tau} X(t)dt + \sigma_C \sqrt{dt} \epsilon(t) + bdt, \\ for \: \tau, \sigma_C, t \geq 0\end{split}\]where the mean value of the lightcurve \(X(t)\) is \(b\tau\) and the variance is \(\frac{\tau\sigma_C^2}{2}\). \(\tau\) is the relaxation time of the process \(X(t)\), it can be interpreted as describing the variability amplitude of the time series. \(\sigma_C\) can be interpreted as describing the variability of the time series on time scales shorter than \(\tau\). \(\epsilon(t)\) is a white noise process with zero mean and variance equal to one.
The likelihood function of a CAR model for a light-curve with observations \(x - \{x_1, \dots, x_n\}\) observed at times \(\{t_1, \dots, t_n\}\) with measurements error variances \(\{\delta_1^2, \dots, \delta_n^2\}\) is:
\[ \begin{align}\begin{aligned}\begin{split}p (x|b,\sigma_C,\tau) = \prod_{i=1}^n \frac{1}{ [2 \pi (\Omega_i + \delta_i^2 )]^{1/2}} exp \{-\frac{1}{2} \frac{(\hat{x}_i - x^*_i )^2}{\Omega_i + \delta^2_i}\} \\\end{split}\\\begin{split}x_i^* = x_i - b\tau \\\end{split}\\\begin{split}\hat{x}_0 = 0 \\\end{split}\\\begin{split}\Omega_0 = \frac{\tau \sigma^2_C}{2} \\\end{split}\\\begin{split}\hat{x}_i = a_i\hat{x}_{i-1} + \frac{a_i \Omega_{i-1}}{\Omega_{i-1} + \delta^2_{i-1}} (x^*_{i-1} + \hat{x}_{i-1}) \\\end{split}\\\Omega_i = \Omega_0 (1- a_i^2 ) + a_i^2 \Omega_{i-1} (1 - \frac{\Omega_{i-1}}{\Omega_{i-1} + \delta^2_{i-1}} )\end{aligned}\end{align} \]To find the optimal parameters we maximize the likelihood with respect to \(\sigma_C\) and \(\tau\) and calculate \(b\) as the mean magnitude of the light-curve divided by \(\tau\).
- Parameters:
- minimize_methodstr, default=”nelder-mead”
Method to use in the minimization. See scipy.optimize.minimize documentation for more details.
See also
scipy.optimize.minimize
References
[brockwell2002introduction]Brockwell, P. J., & Davis, R. A. (2002). Introduction toTime Seriesand Forecasting.
[pichara2012improved]Pichara, K., Protopapas, P., Kim, D. W., Marquette, J. B., & Tisserand, P. (2012). An improved quasar detection method in EROS-2 and MACHO LMC data sets. Monthly Notices of the Royal Astronomical Society, 427(2), 1284-1297. Doi:10.1111/j.1365-2966.2012.22061.x.
Examples
>>> fs = feets.FeatureSpace(only=["CAR_sigma", "CAR_tau", "CAR_mean"]) >>> features = fs.extract(**lc_periodic) >>> features[0] {'CAR_tau': np.float64(5.845296631165712), 'CAR_sigma': np.float64(0.15595686709560483), 'CAR_mean': np.float64(-0.020044718150113303)}
- extract(magnitude, time, error)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray_like
- timearray_like
- errorarray_like
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_color module¶
Color extractor.
- class feets.extractors.ext_color.Color(**kwargs)[source]¶
Bases:
ExtractorColor extractor.
Color
The color is defined as the difference between the average magnitude of two different bands observations.
References
[kim2011quasi]Kim, D. W., Protopapas, P., Byun, Y. I., Alcock, C., Khardon, R., & Trichas, M. (2011). Quasi-stellar object selection algorithm using time variability and machine learning: Selection of 1620 quasi-stellar object candidates from MACHO Large Magellanic Cloud database. The Astrophysical Journal, 735(2), 68. Doi:10.1088/0004-637X/735/2/68.
Examples
>>> fs = feets.FeatureSpace(only=["Color"]) >>> features = fs.extract(**lc_normal) >>> features[0] {'Color': np.float64(-0.07991933970739044)}
- extract(magnitude, magnitude2)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray_like
- magnitude2array_like
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_con module¶
Con extractor.
- class feets.extractors.ext_con.Con(**kwargs)[source]¶
Bases:
ExtractorCon extractor.
Con
Index introduced for the selection of variable stars from the OGLE database (Wozniak 2000). To calculate Con, we count the number of three consecutive data points that are brighter or fainter than \(2\sigma\) and normalize the number by \(N-2\).
For a normal distribution and by considering just one star, Con should take values close to \(0.045\).
- Parameters:
- consecutive_starint, optional (default=3)
Number of consecutive data points to consider.
References
[kim2011quasi]Kim, D. W., Protopapas, P., Byun, Y. I., Alcock, C., Khardon, R., & Trichas, M. (2011). Quasi-stellar object selection algorithm using time variability and machine learning: Selection of 1620 quasi-stellar object candidates from MACHO Large Magellanic Cloud database. The Astrophysical Journal, 735(2), 68. Doi:10.1088/0004-637X/735/2/68.
Examples
Con of a normal time series:
>>> fs = feets.FeatureSpace(only=["Con"], consecutive_star=1) >>> features = fs.extract(**lc_normal) >>> features[0] {'Con': 0.042}
feets.extractors.ext_cusum module¶
Cumulative sum (CUSUM) extractor.
- class feets.extractors.ext_cusum.Cusum(**kwargs)[source]¶
Bases:
LightCurveExtractorCusum — a range of cumulative sums.
Cusum = \(\max(S) - \min(S)\)
where \(S_j = \frac1{N\sigma_m} \sum_{i=0}^j{\left(m\_i - \langle m \rangle\right)}\), \(N\) is the number of observations, \(\langle m \rangle\) is the mean magnitude and \(\sigma_m = \sqrt{\sum_i (m_i - \langle m \rangle)^2 / (N-1)}\) is the magnitude standard deviation.
- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
References
[kim2014epoch]Kim, D. W., Protopapas, P., Bailer-Jones, C. A., Byun, Y. I., Chang, S. W., Marquette, J. B., & Shin, M. S. (2014). The EPOCH Project: I. Periodic Variable Stars in the EROS-2 LMC Database. arXiv preprint Doi:10.1051/0004-6361/201323252.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_dmdt module¶
Delta m and Delta t extractor.
- class feets.extractors.ext_dmdt.DeltamDeltat(**kwargs)[source]¶
Bases:
ExtractorDelta m and Delta t extractor.
DeltamDeltat
The 2D histogram of the differences in magnitude (Delta m) and time (Delta t) between all pairs of observations in a light curve.
- Parameters:
- dt_binsarray-like, optional
The bins for the time differences.
- dm_binsarray-like, optional
The bins for the magnitude differences.
References
[astro-ph.IM]Mahabal, A. A., Sheth, K., Gieseke, F., Pai, A., Djorgovski, S. G., Drake, A. J., & Graham, M. J. (2017). Deep-learnt classification of light curves. 2017 IEEE Symposium Series on Computational Intelligence (SSCI), 1-8.
Examples
>>> fs = feets.FeatureSpace(only=["DeltamDeltat"]) >>> features = fs.extract(**lc_normal) >>> features[0] {'DeltamDeltat': {'dt_0_dm_0': np.int64(0), 'dt_1_dm_0': np.int64(0), ... 'dt_22_dm_23': np.int64(0)}}
feets.extractors.ext_duration module¶
Time duration extractor.
- class feets.extractors.ext_duration.Duration(**kwargs)[source]¶
Bases:
LightCurveExtractorTime-series duration.
\[t_{N-1} - t_0\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(time, magnitude=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- magnitudearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_eta module¶
Eta extractor.
- class feets.extractors.ext_eta.Eta(**kwargs)[source]¶
Bases:
LightCurveExtractorVon Neummann Eta.
Eta (\(\eta\))
\[\eta = \frac1{(N - 1)\,\sigma_m^2} \sum_{i=0}^{N-2}(m_{i+1} - m_i)^2\]where \(N\) is the number of observations, \(\sigma_m = \sqrt{\sum_i (m_i - \langle m \rangle)^2 / (N-1)}\) is the magnitude standard deviation.
- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
References
[kim2014epoch]Kim, D. W., Protopapas, P., Bailer-Jones, C. A., Byun, Y. I., Chang, S. W., Marquette, J. B., & Shin, M. S. (2014). The EPOCH Project: I. Periodic Variable Stars in the EROS-2 LMC Database. arXiv preprint Doi:10.1051/0004-6361/201323252.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_eta_color module¶
Color Eta_e extractor.
- class feets.extractors.ext_eta_color.EtaColor(**kwargs)[source]¶
Bases:
ExtractorColor Eta_e extractor.
Eta_color (\(\eta_{color}\))
Variability index Eta_e (\(\eta^e\)) calculated from the color light-curve.
References
[kim2014epoch]Kim, D. W., Protopapas, P., Bailer-Jones, C. A., Byun, Y. I., Chang, S. W., Marquette, J. B., & Shin, M. S. (2014). The EPOCH Project: I. Periodic Variable Stars in the EROS-2 LMC Database. arXiv preprint Doi:10.1051/0004-6361/201323252.
Examples
>>> fs = feets.FeatureSpace(only=["Eta_color"]) >>> features = fs.extract(**lc_normal) >>> features[0] {'Eta_color': np.float64(0.0007871260219202687)}
- extract(aligned_magnitude, aligned_time, aligned_magnitude2)[source]¶
Extract features from time series data vectors.
- Parameters:
- aligned_magnitudearray-like
- aligned_timearray-like
- aligned_magnitude2array-like
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_eta_e module¶
Eta-E extractor.
- class feets.extractors.ext_eta_e.EtaE(**kwargs)[source]¶
Bases:
LightCurveExtractorEtaE extractor.
EtaE (\(\eta^e\))
Modification of Eta for unevenly time series.
\[\eta^e = \frac{(t_{N-1} - t_0)^2}{(N - 1)^3} \frac{\sum_{i=0}^{N-2} \left(\frac{m_{i+1} - m_i}{t_{i+1} - t_i}\right)^2}{\sigma_m^2}\]where \(N\) is the number of observations, \(\sigma_m = \sqrt{\sum_i (m_i - \langle m \rangle)^2 / (N-1)}\) is the magnitude standard deviation.
Note that this definition is a bit different from [kim2014epoch]
- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘lg’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
See also
feets.extractors.Eta
References
[kim2014epoch]Kim, D. W., Protopapas, P., Bailer-Jones, C. A., Byun, Y. I., Chang, S. W., Marquette, J. B., & Shin, M. S. (2014). The EPOCH Project: I. Periodic Variable Stars in the EROS-2 LMC Database. arXiv preprint Doi:10.1051/0004-6361/201323252.
- extract(time, magnitude, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- magnitudearray-like
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_excess_variance module¶
Excess variance extractor.
- class feets.extractors.ext_excess_variance.ExcessVariance(**kwargs)[source]¶
Bases:
LightCurveExtractorExcess variance extractor.
ExcessVariance
Measure of the variability amplitude
\[\frac{\sigma_m^2 - \langle \delta^2 \rangle}{\langle m \rangle^2},\]Note that this definition differs from [sanchez2017infrared].
- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
References
[sanchez2017infrared]Sánchez, P., Lira, P., Cartier, R., Pérez, V., Miranda, N., Yovaniniz, C., … & Marchesi, S. (2017). Near-infrared variability of obscured and unobscured X-ray-selected AGNs in the COSMOS field. The Astrophysical Journal, 849(2), 110.
- extract(magnitude, error, time=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- errorarray-like
- timearray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_fourier_components module¶
Fourier components extractor.
- class feets.extractors.ext_fourier_components.FourierComponents(**kwargs)[source]¶
Bases:
ExtractorFourier components extractor.
Periodic features extracted from light-curves using Lomb–Scargle (Richards et al., 2011)
Here, we adopt a model where the time series of the photometric magnitudes of variable stars is modeled as a superposition of sines and cosines:
\[y_i(t|f_i) = a_i\sin(2\pi f_i t) + b_i\cos(2\pi f_i t) + b_{i,\circ}\]where \(a\) and \(b\) are normalization constants for the sinusoids of frequency \(f_i\) and \(b_{i,\circ}\) is the magnitude offset.
To find periodic variations in the data, we fit the equation above by minimizing the sum of squares, which we denote \(\chi^2\):
\[\chi^2 = \sum_k \frac{(d_k - y_i(t_k))^2}{\sigma_k^2}\]where \(\sigma_k\) is the measurement uncertainty in data point \(d_k\). We allow the mean to float, leading to more robust period estimates in the case where the periodic phase is not uniformly sampled; in these cases, the model light curve has a non-zero mean. This can be important when searching for periods on the order of the data span \(T_{tot}\). Now, define
\[\chi^2_{\circ} = \sum_k \frac{(d_k - \mu)^2}{\sigma_k^2}\]where \(\mu\) is the weighted mean
\[\mu = \frac{\sum_k d_k / \sigma_k^2}{\sum_k 1/\sigma_k^2}\]Then, the generalized Lomb-Scargle periodogram is:
\[P_f(f) = \frac{(N-1)}{2} \frac{\chi_{\circ}^2 - \chi_m^2(f)} {\chi_{\circ}^2}\]where \(\chi_m^2(f)\) is \(\chi^2\) minimized with respect to \(a, b\) and \(b_{\circ}\).
Following Debosscher et al. (2007), we fit each light curve with a linear term plus a harmonic sum of sinusoids:
\[y(t) = ct + \sum_{i=1}^{3}\sum_{j=1}^{4} y_i(t|jf_i)\]where each of the three test frequencies \(f_i\) is allowed to have four harmonics at frequencies \(f_{i,j} = jf_i\). The three test frequencies \(f_i\) are found iteratively, by successfully finding and removing periodic signal producing a peak in \(P_f(f)\) , where \(P_f(f)\) is the Lomb-Scargle periodogram as defined above.
Given a peak in \(P_f(f)\), we whiten the data with respect to that frequency by fitting away a model containing that frequency as well as components with frequencies at 2, 3, and 4 times that fundamental frequency (harmonics). Then, we subtract that model from the data, update \(\chi_{\circ}^2\), and recalculate \(P_f(f)\) to find more periodic components.
Algorithm:
For \(i = {1, 2, 3}\)
Calculate Lomb-Scargle periodogram \(P_f(f)\) for light curve.
Find peak in \(P_f(f)\), subtract that model from data.
Update \(\chi_{\circ}^2\), return to Step 1.
Then, the features extracted are given as an amplitude and a phase:
\[\begin{split}A_{i,j} = \sqrt{a_{i,j}^2 + b_{i,j}^2}\\ \textrm{PH}_{i,j} = \arctan(\frac{b_{i,j}}{a_{i,j}})\end{split}\]where \(A_{i,j}\) is the amplitude of the \(j-th\) harmonic of the \(i-th\) frequency component and \(\textrm{PH}_{i,j}\) is the phase component, which we then correct to a relative phase with respect to the phase of the first component:
\[\textrm{PH}'_{i,j} = \textrm{PH}_{i,j} - \textrm{PH}_{00}\]and remapped to \(|-\pi, +\pi|\)
- Parameters:
- lscargle_kwdsdict, optional
Keyword arguments to pass to the Lomb-Scargle periodogram function.
References
[richards2011machine]Richards, J. W., Starr, D. L., Butler, N. R., Bloom, J. S., Brewer, J. M., Crellin-Quick, A., … & Rischard, M. (2011). On machine-learned classification of variable stars with sparse and noisy time-series data. The Astrophysical Journal, 733(1), 10. Doi:10.1088/0004-637X/733/1/10.
feets.extractors.ext_gskew module¶
Gskew extractor.
- class feets.extractors.ext_gskew.Gskew(**kwargs)[source]¶
Bases:
ExtractorGskew extractor.
Gskew
Median-of-magnitudes based measure of the skew.
\[Gskew = m_{q3} + m_{q97} - 2m\]Where:
\(m_{q3}\) is the median of magnitudes lesser or equal than the quantile 3.
\(m_{q97}\) is the median of magnitudes greater or equal than the quantile 97.
\(m\) is the median of magnitudes.
feets.extractors.ext_inter_percentile_range module¶
Inter-percentile range extractor.
- class feets.extractors.ext_inter_percentile_range.InterPercentileRange(**kwargs)[source]¶
Bases:
LightCurveExtractorInter-percentile range.
\[Q(1 - p) - Q(p)\]where \(Q(p)\) is the \(p\)-th quantile of the magnitude distribution.
Special cases are the interquartile range which is inter-percentile range for \(p = 0.25\), and the interdecile range, which is inter-percentile range for \(p = 0.1\).
- Parameters:
- quantilepositive float, default=0.25
Range is \((100%% * quantile, 100%% * (1 - quantile))\). Default quantile is 0.25
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
- flatten_feature(feature, value)[source]¶
Normalize a feature value into a dictionary of scalars.
This method is called internally to better represent the returned features of the extract() method.
- Parameters:
- featurestr
The name of the feature.
- valueobject
The raw value as received by the extract() method.
- Returns:
- dict
A dictionary of scalars representing the flattened feature.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_light_curve_lomb_scargle module¶
Lomb-Scargle extractor.
- class feets.extractors.ext_light_curve_lomb_scargle.LightCurveLombScargle(**kwargs)[source]¶
Bases:
LightCurveExtractorPeaks of Lomb-Scargle periodogram.
Periodogram \(P(\omega)\) is an estimate of spectral density of unevenly time series.
The peaks argument corresponds to a number of the most significant spectral density peaks to return.
For each peak its period and “signal to noise” ratio is returned:
\[\mathrm{signal~to~noise~of~peak} = \frac{P(\omega_\mathrm{peak}) - \langle P(\omega) \rangle} {\sigma_{P(\omega)}}\]- Parameters:
- peaksint or None, default=3
Number of peaks to find, default is 3.
- resolutionfloat or None, default=10
Resolution of frequency grid, default is 10.
- max_freq_factorfloat or None, default=1
Multiplier for Nyquist frequency, default is 1.
- nyquiststr or float or None, default=’average’
Type of Nyquist frequency. Could be one of:
‘average’: “Average” Nyquist frequency.
‘median’: Nyquist frequency is defined by median time interval between observations.
float: Nyquist frequency is defined by given quantile of time intervals between observations.
Default is ‘average’.
- fastbool or None, default=True
Use “Fast” (approximate and FFT-based) or direct periodogram algorithm, default is True.
- extract(time, magnitude, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- magnitudearray-like
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_linear_fit module¶
Linear fit extractor.
- class feets.extractors.ext_linear_fit.LinearFit(**kwargs)[source]¶
Bases:
LightCurveExtractorLinear fit extractor.
The slope, its error and reduced chi-squared of the light curve in the linear fit.
Least squares fit of the linear stochastic model with Gaussian noise described by observation errors \(\{\delta_i\}\):
\[m_i = c + \mathrm{slope} t_i + \delta_i \varepsilon_i\]where \(c\) is a constant, \(\{\varepsilon_i\}\) are standard distributed random variables.
Feature values are \(\mathrm{slope}\), \(\sigma_\mathrm{slope}\) and \(\frac{\sum{((m_i - c - \mathrm{slope} t_i) / \delta_i)^2}}{N - 2}\).
- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(time, magnitude, error)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- magnitudearray-like
- errorarray-like
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_linear_trend module¶
Linear trend extractor.
- class feets.extractors.ext_linear_trend.LinearTrend(**kwargs)[source]¶
Bases:
LightCurveExtractorLinear trend extractor.
The slope, its error and noise level of the light curve in the linear fit
Least squares fit of the linear stochastic model with constant Gaussian noise \(\Sigma\) assuming observation errors to be zero:
\[m_i = c + \mathrm{slope} t_i + \Sigma \varepsilon_i,\]where \(c\) is a constant, \(\{\varepsilon_i\}\) are standard distributed random variables.
\(\mathrm{slope}\), \(\sigma_\mathrm{slope}\) and \(\Sigma\) are returned.
- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(time, magnitude, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- magnitudearray-like
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_linexp_fit module¶
Linear exponential fit extractor.
- class feets.extractors.ext_linexp_fit.LinexpFit(**kwargs)[source]¶
Bases:
LightCurveExtractorLinexp function fit.
Four fit parameters and goodness of fit (reduced \(\chi^2\)) of the Linexp function developed for core-collapsed supernovae:
\[f(t) = A \frac{(t-t_0)}{\tau} \times \exp{\left(\frac{(t-t_0)}{\tau}\right)} + B.\]Note, that the Linexp function is developed to be used with fluxes, not magnitudes.
LinexpFit_Amplitude (\(A\))
Amplitude of the Linexp function
LinexpFit_ReferenceTime (\(t_0\))
Reference time of the Linexp fit
LinexpFit_FallTime (\(\tau\))
Fall time of the Linexp function
LinexpFit_Baseline (\(B\))
Baseline of the Linexp function
LinexpFit_ReducedChi2 (reduced \(\chi^2\))
Linexp fit quality
- Parameters:
- algorithmstr
Non-linear least-square algorithm, supported values are: ‘mcmc’, ‘ceres’, ‘mcmc-ceres’, ‘lmsder’, ‘mcmc-lmsder’.
- mcmc_niterint, optional
Number of MCMC iterations, default is 128.
- ceres_niterint, optional
Number of Ceres iterations, default is 10.
- ceres_loss_regfloat, optional
Ceres loss regularization, default is to use square norm as is, if set to a number, the loss function is regularized to discriminate outlier residuals larger than this value. Default is None which means no regularization.
- lmsder_niterint, optional
Number of LMSDER iterations, default is 10.
- initlist or None, optional
Initial conditions, must be None or a list of float`s or `None`s. The length of the list must be 4, `None values will be replaced with some default values. It is supported by MCMC only.
- boundslist of tuples or None, optional
Boundary conditions, must be None or a list of tuple`s of `float`s or `None`s. The length of the list must be 4, boundary conditions must include initial conditions, `None values will be replaced with some broad defaults. It is supported by MCMC only.
- ln_priorstr or list of ln_prior.LnPrior1D or None, optional
Prior for MCMC, None means no prior. It is specified by a string literal or a list of 5 light_curve.ln_prior.LnPrior1D objects, see light_curve.ln_prior submodule for corresponding functions. Available string literals are:
‘no’: no prior
- transformbool or None, optional
If False or None (default) output is not transformed. If True output is transformed as following:
Half-amplitude A is transformed as \(zp - 2.5 lg(2*A)\), \(zp = 8.9\), so that the amplitude is assumed to be the object peak flux in Jy.
baseline flux is normalised by \(A: baseline -> baseline / A\)
reference time is removed
goodness of fit is transformed as \(ln(reduced chi^2 + 1)\) to reduce its spread
other parameters are not transformed
- extract(time, flux, flux_error)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- fluxarray-like
- flux_errorarray-like
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_max_slope module¶
Maximum slope extractor.
- class feets.extractors.ext_max_slope.MaxSlope(**kwargs)[source]¶
Bases:
LightCurveExtractorMaximum slope between two sub-sequential observations.
\[\max_{i=0..N-2}\left|\frac{m_{i+1} - m_i}{t_{i+1} - t_i}\right|\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘clipped_lg’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
References
[disanto2016feature]D’Isanto, A., Cavuoti, S., Brescia, M., Donalek, C., Longo, G., Riccio, G., & Djorgovski, S. G. (2016). An analysis of feature relevance in the classification of astronomical transients with machine learning methods. Monthly Notices of the Royal Astronomical Society, 457(3), 3119-3132.
- extract(time, magnitude, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- magnitudearray-like
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_max_time_interval module¶
Maximum time interval extractor.
- class feets.extractors.ext_max_time_interval.MaxTimeInterval(**kwargs)[source]¶
Bases:
LightCurveExtractorMaximum time interval between consequent observations.
\[\max{(t_{i+1} - t_i)}\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
See also
feets.extractors.MinTimeInterval
- extract(time, magnitude=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- magnitudearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_mean module¶
Mean extractor.
- class feets.extractors.ext_mean.Mean(**kwargs)[source]¶
Bases:
LightCurveExtractorMean magnitude.
\[\frac1{N} \sum_i m_i.\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
See also
feets.extractors.WeightedMean
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_mean_variance module¶
Mean variance extractor.
- class feets.extractors.ext_mean_variance.MeanVariance(**kwargs)[source]¶
Bases:
LightCurveExtractorStandard deviation to mean ratio.
\[\frac{\sigma_m}{\langle m \rangle}\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_median module¶
Median extractor.
- class feets.extractors.ext_median.Median(**kwargs)[source]¶
Bases:
LightCurveExtractorMedian magnitude.
\[\mathrm{Median}(m_i)\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_median_abs_dev module¶
Median absolute deviation extractor.
- class feets.extractors.ext_median_abs_dev.MedianAbsDev(**kwargs)[source]¶
Bases:
LightCurveExtractorMedian absolute deviation.
Median of the absolute value of the difference between magnitude and its median.
\[\mathrm{Median}\left(|m_i - \mathrm{Median}(m)|\right)\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
References
[disanto2016feature]D’Isanto, A., Cavuoti, S., Brescia, M., Donalek, C., Longo, G., Riccio, G., & Djorgovski, S. G. (2016). An analysis of feature relevance in the classification of astronomical transients with machine learning methods. Monthly Notices of the Royal Astronomical Society, 457(3), 3119-3132.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_median_amplitude module¶
Median amplitude extractor.
- class feets.extractors.ext_median_amplitude.MedianAmplitude(**kwargs)[source]¶
Bases:
ExtractorMedian amplitude extractor.
MedianAmplitude
This amplitude is defined as the half of the difference between the median of the maximum \(5%%\) and the median of the minimum \(5%%\) magnitudes. For a sequence of numbers from \(0\) to \(1000\) the amplitude should be equal to \(475.0\).
See also
feets.extractors.Amplitude
References
[richards2011machine]Richards, J. W., Starr, D. L., Butler, N. R., Bloom, J. S., Brewer, J. M., Crellin-Quick, A., … & Rischard, M. (2011). On machine-learned classification of variable stars with sparse and noisy time-series data. The Astrophysical Journal, 733(1), 10. Doi:10.1088/0004-637X/733/1/10.
Examples
Median amplitude of increasing magnitudes from \(0\) to \(1000\):
>>> fs = feets.FeatureSpace(only=['MedianAmplitude']) >>> features = fs.extract(**lc_incremental) >>> features[0] {'MedianAmplitude': np.float64(475.0)}
feets.extractors.ext_median_brp module¶
Median buffer range percentage extractor.
- class feets.extractors.ext_median_brp.MedianBRP(**kwargs)[source]¶
Bases:
LightCurveExtractorMedian buffer range percentage.
Fraction of observations inside the \(\mathrm{Median}(m) \pm q \times (\max(m) - \min(m)) / 2\) interval.
- Parameters:
- quantilepositive float, default=0.10
Relative range size, default is 0.10
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
References
[disanto2016feature]D’Isanto, A., Cavuoti, S., Brescia, M., Donalek, C., Longo, G., Riccio, G., & Djorgovski, S. G. (2016). An analysis of feature relevance in the classification of astronomical transients with machine learning methods. Monthly Notices of the Royal Astronomical Society, 457(3), 3119-3132.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
- flatten_feature(feature, value)[source]¶
Normalize a feature value into a dictionary of scalars.
This method is called internally to better represent the returned features of the extract() method.
- Parameters:
- featurestr
The name of the feature.
- valueobject
The raw value as received by the extract() method.
- Returns:
- dict
A dictionary of scalars representing the flattened feature.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_min_time_interval module¶
Minimum time interval extractor.
- class feets.extractors.ext_min_time_interval.MinTimeInterval(**kwargs)[source]¶
Bases:
LightCurveExtractorMinimum time interval between consequent observations.
\[\min{(t_{i+1} - t_i)}\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
See also
feets.extractors.MaxTimeInterval
- extract(time, magnitude=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- magnitudearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_otsu_split module¶
Otsu split extractor.
- class feets.extractors.ext_otsu_split.OtsuSplit(**kwargs)[source]¶
Bases:
LightCurveExtractorOtsu threshholding algorithm.
Difference of subset means, standard deviation of the lower subset, standard deviation of the upper subset and lower-to-all observation count ratio for two subsets of magnitudes obtained by Otsu’s method split.
Otsu’s method is used to perform automatic thresholding. The algorithm returns a single threshold that separate values into two classes. This threshold is determined by minimizing intra-class intensity variance, or equivalently, by maximizing inter-class variance.
The algorithm returns the minimum threshold which corresponds to the absolute maximum of the inter-class variance.
References
[otsu1979glh]Otsu, N. (1979). A Threshold Selection Method from Gray-Level Histograms. IEEE Transactions on Systems, Man and Cybernetics, 9, 62–66. doi: 10.1109/TSMC.1979.4310076
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_pair_slope_trend module¶
Pair slope trend extractor.
- class feets.extractors.ext_pair_slope_trend.PairSlopeTrend(**kwargs)[source]¶
Bases:
ExtractorPair slope trend extractor.
PairSlopeTrend
Considering the last \(30\) (time-sorted) measurements of source magnitude, the fraction of increasing first differences minus the fraction of decreasing first differences.
References
[richards2011machine]Richards, J. W., Starr, D. L., Butler, N. R., Bloom, J. S., Brewer, J. M., Crellin-Quick, A., … & Rischard, M. (2011). On machine-learned classification of variable stars with sparse and noisy time-series data. The Astrophysical Journal, 733(1), 10. Doi:10.1088/0004-637X/733/1/10.
Examples
>>> fs = feets.FeatureSpace(only=['PairSlopeTrend']) >>> features = fs.extract(**lc_normal) >>> features[0] {'PairSlopeTrend': -0.0021333333333333343}
feets.extractors.ext_percent_amplitude module¶
Percent amplitude extractor.
- class feets.extractors.ext_percent_amplitude.PercentAmplitude(**kwargs)[source]¶
Bases:
LightCurveExtractorMaximum deviation of magnitude from its median.
\[\max_i\left|m_i - \mathrm{Median}(m)\right| = \max(\max(m) - \mathrm{Median}(m), \mathrm{Median}(m) - \min(m))\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
References
[disanto2016feature]D’Isanto, A., Cavuoti, S., Brescia, M., Donalek, C., Longo, G., Riccio, G., & Djorgovski, S. G. (2016). An analysis of feature relevance in the classification of astronomical transients with machine learning methods. Monthly Notices of the Royal Astronomical Society, 457(3), 3119-3132.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_percent_diff_percentile module¶
Percent difference magnitude percentile extractor.
- class feets.extractors.ext_percent_diff_percentile.PercentDiffPercentile(**kwargs)[source]¶
Bases:
LightCurveExtractorRatio of p-th inter-percentile range to the median.
\[p\mathrm{~percent~difference~magnitude~percentile} = \frac{Q(1-p) - Q(p)}{\mathrm{Median}(m)}.\]- Parameters:
- quantilepositive float, default=0.05
Relative range size, default is 0.05
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘clipped_lg’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
f bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
References
[disanto2016feature]D’Isanto, A., Cavuoti, S., Brescia, M., Donalek, C., Longo, G., Riccio, G., & Djorgovski, S. G. (2016). An analysis of feature relevance in the classification of astronomical transients with machine learning methods. Monthly Notices of the Royal Astronomical Society, 457(3), 3119-3132.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
- flatten_feature(feature, value)[source]¶
Normalize a feature value into a dictionary of scalars.
This method is called internally to better represent the returned features of the extract() method.
- Parameters:
- featurestr
The name of the feature.
- valueobject
The raw value as received by the extract() method.
- Returns:
- dict
A dictionary of scalars representing the flattened feature.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_percentage_ratio module¶
Percentage ratio extractor.
- class feets.extractors.ext_percentage_ratio.PercentageRatio(**kwargs)[source]¶
Bases:
LightCurveExtractorMagnitude percentage ratio.
\[\mathrm{magnitude~}q\mathrm{~to~}n\mathrm{~ratio} = \frac{Q(1-n) - Q(n)}{Q(1-d) - Q(d)}\]where \(n\) and \(d\) denotes user defined percentage, \(Q\) is the quantile function of magnitude distribution.
- Parameters:
- quantile_numerator: positive float, default=0.40
Numerator is inter-percentile range \((100%% * q, 100%% (1 - q))\). Default value is 0.40
- quantile_denominator: positive float, default=0.05
Denominator is inter-percentile range \((100%% * q, 100%% (1 - q))\). Default value is 0.05
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
References
[disanto2016feature]D’Isanto, A., Cavuoti, S., Brescia, M., Donalek, C., Longo, G., Riccio, G., & Djorgovski, S. G. (2016). An analysis of feature relevance in the classification of astronomical transients with machine learning methods. Monthly Notices of the Royal Astronomical Society, 457(3), 3119-3132.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
- flatten_feature(feature, value)[source]¶
Normalize a feature value into a dictionary of scalars.
This method is called internally to better represent the returned features of the extract() method.
- Parameters:
- featurestr
The name of the feature.
- valueobject
The raw value as received by the extract() method.
- Returns:
- dict
A dictionary of scalars representing the flattened feature.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_q31 module¶
Q31 related extractors.
- class feets.extractors.ext_q31.Q31(**kwargs)[source]¶
Bases:
ExtractorQ31 extractor.
Q31 (\(Q_{3-1}\))
\(Q_{3-1}\) is the difference between the third quartile, \(Q_3\), and the first quartile, \(Q_1\), of a raw light curve. \(Q_1\) is a split between the lowest 25% and the highest 75% of data. \(Q_3\) is a split between the lowest 75% and the highest 25% of data.
References
[kim2014epoch]Kim, D. W., Protopapas, P., Bailer-Jones, C. A., Byun, Y. I., Chang, S. W., Marquette, J. B., & Shin, M. S. (2014). The EPOCH Project: I. Periodic Variable Stars in the EROS-2 LMC Database. arXiv preprint Doi:10.1051/0004-6361/201323252.
Examples
>>> fs = feets.FeatureSpace(only=['Q31']) >>> features = fs.extract(**lc_normal) >>> features[0] {'Q31': np.float64(1.3329778116209337)}
- class feets.extractors.ext_q31.Q31Color(**kwargs)[source]¶
Bases:
ExtractorQ31 color extractor.
Q31_color (\(Q_{3-1|B-R}\))
\(Q_{3-1}\) applied to the difference between both bands of a light curve (B-R)
References
[kim2014epoch]Kim, D. W., Protopapas, P., Bailer-Jones, C. A., Byun, Y. I., Chang, S. W., Marquette, J. B., & Shin, M. S. (2014). The EPOCH Project: I. Periodic Variable Stars in the EROS-2 LMC Database. arXiv preprint Doi:10.1051/0004-6361/201323252.
Examples
>>> fs = feets.FeatureSpace(only=['Q31_color']) >>> features = fs.extract(**lc_normal) >>> features[0] {'Q31_color': 1.9517477838539978}
- extract(aligned_magnitude, aligned_magnitude2)[source]¶
Extract features from time series data vectors.
- Parameters:
- aligned_magnitudearray-like
- aligned_magnitude2array-like
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_rcs module¶
Range of cumulative sum extractor.
- class feets.extractors.ext_rcs.RCS(**kwargs)[source]¶
Bases:
ExtractorRange of cumulative sum extractor.
Rcs - Range of cumulative sum (\(R_{cs}\))
\(R_{cs}\) is the range of a cumulative sum (Ellaway 1978) of each light-curve and is defined as:
\[\begin{split}R_{cs} = max(S) - min(S) \\ S = \frac{1}{N \sigma} \sum_{i=1}^l (m_i - \bar{m})\end{split}\]where \(max`(:math:`min\)) is the maximum (minimum) value of \(S\) and \(l=1,2, \dots, N\).
\(R_{cs}\) should take a value close to zero for any symmetric distribution.
References
[kim2011quasi]Kim, D. W., Protopapas, P., Byun, Y. I., Alcock, C., Khardon, R., & Trichas, M. (2011). Quasi-stellar object selection algorithm using time variability and machine learning: Selection of 1620 quasi-stellar object candidates from MACHO Large Magellanic Cloud database. The Astrophysical Journal, 735(2), 68. Doi:10.1088/0004-637X/735/2/68.
Examples
>>> fs = feets.FeatureSpace(only=['Rcs']) >>> features = fs.extract(**lc_normal) >>> features[0] {'Rcs': np.float64(0.04951776697391974)}
feets.extractors.ext_reduced_chi2 module¶
Reduced chi-squared extractor.
- class feets.extractors.ext_reduced_chi2.ReducedChi2(**kwargs)[source]¶
Bases:
LightCurveExtractorReduced chi-squared of magnitude measurements.
\[\mathrm{reduced~}\chi^2 = \frac1{N-1} \sum_i\left(\frac{m_i - \bar{m}}{\delta\_i}\right)^2\]where \(N\) is the number of observations, and \(\bar{m}\) is the weighted mean magnitude.
This is a good measure of variability which takes into account observations uncertainties.
- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘ln1p’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(magnitude, error, time=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- errorarray-like
- timearray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_roms module¶
Roms extractor.
- class feets.extractors.ext_roms.Roms(**kwargs)[source]¶
Bases:
LightCurveExtractorRobust median statistic.
\[\text{Roms} = \frac{1}{N-1} \sum_{i=0}^{N-1} \frac{|m_i - \mathrm{median}(m_i)|}{\sigma_i}\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
References
[enoch2003photometric]Enoch, M. L., Brown, M. E., & Burgasser, A. J. (2003). Photometric variability at the L/T dwarf boundary. The Astronomical Journal, 126(2), 1006.
- extract(magnitude, error, time=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- errorarray-like
- timearray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_signature module¶
Signature extractor.
- class feets.extractors.ext_signature.Signature(**kwargs)[source]¶
Bases:
ExtractorSignature extractor.
Signature
The signature is a 2D histogram of the light-curve in the phase-magnitude space. The phase is calculated as the time modulo the period, and the magnitude is normalized by the amplitude.
- Parameters:
- phase_binsint, optional, default: 18
Number of phase bins.
- mag_binsint, optional, default: 12
Number of magnitude bins.
Examples
>>> fs = feets.FeatureSpace(only=["Signature"]) >>> features = fs.extract(**lc_periodic) >>> features[0] {'Signature': array([{'ph_0_mag_0': np.float64(3.273060645417755), ..., 'ph_17_mag_11': np.float64(0.0)}, {'ph_0_mag_0': np.float64(6.546121290835849), ..., 'ph_17_mag_11': np.float64(0.0)}, {'ph_0_mag_0': np.float64(3.273060645418243), ..., 'ph_17_mag_11': np.float64(0.0)}], dtype=object)}
- extract(magnitude, time, PeriodLS, MedianAmplitude)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like
- PeriodLSarray-like
- MedianAmplitudefloat
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_skew module¶
Skew extractor.
- class feets.extractors.ext_skew.Skew(**kwargs)[source]¶
Bases:
LightCurveExtractorSkewness of the magnitude distribution.
\[G_1 = \frac{N}{(N - 1)(N - 2)} \frac{\sum_i(m_i - \langle m \rangle)^3}{\sigma_m^3}\]where \(N\) is the number of observations, \(\langle m \rangle\) is the mean magnitude, \(\sigma_m = \sqrt{\sum_i (m_i - \langle m \rangle)^2 / (N-1)}\) is the magnitude standard deviation.
- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘arcsinh’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_slotted_a_length module¶
Slotted autocorrelation extractor.
- class feets.extractors.ext_slotted_a_length.SlottedALength(**kwargs)[source]¶
Bases:
ExtractorSlotted autocorrelation extractor.
SlottedALength
In slotted autocorrelation, time lags are defined as intervals or slots instead of single values. The slotted autocorrelation function at a certain time lag slot is computed by averaging the cross product between samples whose time differences fall in the given slot.
\[\hat{\rho}(\tau=kh) = \frac {1}{\hat{\rho}(0)\,N_\tau} \sum_{t_i}\sum_{t_j= t_i+(k-1/2)h }^{t_i+(k+1/2)h} \bar{y}_i(t_i)\,\, \bar{y}_j(t_j)\]Where \(h\) is the slot size, \(\bar{y}\) is the normalized magnitude, \(\hat{\rho}(0)\) is the slotted autocorrelation for the first lag, and \(N_\tau\) is the number of pairs that fall in the given slot.
- Parameters:
- Tint, optional, default: 1
\(tau\) - slot size in days.
References
[huijse2012information]Huijse, P., Estevez, P. A., Protopapas, P., Zegers, P., & Principe, J. C. (2012). An information theoretic algorithm for finding periodicities in stellar light curves. IEEE Transactions on Signal Processing, 60(10), 5135-5145.
Examples
>>> fs = feets.FeatureSpace(only=["SlottedALength"]) >>> features = fs.extract(**lc) >>> features[0] {'SlottedALength': np.int64(1)}
- feets.extractors.ext_slotted_a_length.slotted_autocorrelation(data, time, T, K, second_round=False, K1=100)[source]¶
Calculate slotted autocorrelation.
- Parameters:
- dataarray-like
- timearray-like
- Tfloat
- Kint
- second_roundbool, default=False
- K1int, default=100
- Returns:
- tuple
(normalized slotted autocorrelation, slots)
feets.extractors.ext_small_kurtosis module¶
Small kurtosis extractor.
- class feets.extractors.ext_small_kurtosis.SmallKurtosis(**kwargs)[source]¶
Bases:
LightCurveExtractorExcess kurtosis of magnitude.
\[G_2 = \frac{N\,(N + 1)}{(N - 1)(N - 2)(N - 3)} \frac{\sum_i(m_i - \langle m \rangle)^4}{\sigma_m^4} - 3\frac{(N - 1)^2}{(N - 2)(N - 3)}\]where \(N\) is the number of observations, \(\langle m \rangle\) is the mean magnitude, \(\sigma_m = \sqrt{\sum_i (m_i - \langle m \rangle)^2 / (N-1)}\) is the magnitude standard deviation.
- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘arcsinh’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_std module¶
Standard deviation extractor.
- class feets.extractors.ext_std.Std(**kwargs)[source]¶
Bases:
LightCurveExtractorStandard deviation of magnitude.
Std (\(\sigma_m\))
\[\sigma_m = \sqrt{\sum_i (m_i - \langle m \rangle)^2 / (N-1)}\]where \(N\) is the number of observations and \(\langle m \rangle\) is the mean magnitude.
- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(magnitude, time=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- timearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_stetson module¶
Stetson variability index extractors.
- class feets.extractors.ext_stetson.StetsonJ(**kwargs)[source]¶
Bases:
ExtractorStetson J variability index extractor.
StetsonJ
Stetson J is a robust version of the variability index. It is calculated based on two simultaneous light curves of a same star and is defined as:
\[J = \sum_{k=1}^n sgn(P_k) \sqrt{|P_k|}\]with \(P_k = \delta_{i_k} \delta_{j_k}\)
For a Gaussian magnitude distribution, \(J\) should take a value close to zero.
Notes
This feature is based on the Welch/Stetson variability index \(I\) (Stetson, 1996) defined by the equation:
\[I = \sqrt{\frac{1}{n(n-1)}} \sum_{i=1}^n { (\frac{b_i-\hat{b}}{\sigma_{b,i}}) (\frac{v_i - \hat{v}}{\sigma_{v,i}})}\]where \(b_i\) and \(v_i\) are the apparent magnitudes obtained for the candidate star in two observations closely spaced in time on some occasion \(i\), \(\sigma_{b, i}\) and \(\sigma_{v, i}\) are the standard errors of those magnitudes, \(\hat{b}\) and hat{v} are the weighted mean magnitudes in the two filters, and \(n\) is the number of observation pairs.
Since a given frame pair may include data from two filters which did not have equal numbers of observations overall, the “relative error” is calculated as follows:
\[\delta = \sqrt{\frac{n}{n-1}} \frac{v-\hat{v}}{\sigma_v}\]allowing all residuals to be compared on an equal basis.
References
[richards2011machine]Richards, J. W., Starr, D. L., Butler, N. R., Bloom, J. S., Brewer, J. M., Crellin-Quick, A., … & Rischard, M. (2011). On machine-learned classification of variable stars with sparse and noisy time-series data. The Astrophysical Journal, 733(1), 10. Doi:10.1088/0004-637X/733/1/10.
Examples
>>> fs = feets.FeatureSpace(only=['StetsonJ']) >>> features = fs.extract(**lc_normal) >>> features[0] {'StetsonJ': np.float64(0.01823276018663087)}
- extract(aligned_magnitude, aligned_magnitude2, aligned_error, aligned_error2)[source]¶
Extract features from time series data vectors.
- Parameters:
- aligned_magnitudearray-like
- aligned_magnitude2array-like
- aligned_errorarray-like
- aligned_error2array-like
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
- class feets.extractors.ext_stetson.StetsonKAC(**kwargs)[source]¶
Bases:
ExtractorStetson K to slotted autocorrelation extractor.
StetsonK_AC
Stetson K applied to the slotted autocorrelation function of the light-curve.
- Parameters:
- Tint, optional, default: 1
- :math:`tau` - slot size in days.
Notes
This feature is based on the Welch/Stetson variability index \(I\) (Stetson, 1996) defined by the equation:
\[I = \sqrt{\frac{1}{n(n-1)}} \sum_{i=1}^n { (\frac{b_i-\hat{b}}{\sigma_{b,i}}) (\frac{v_i - \hat{v}}{\sigma_{v,i}})}\]where \(b_i\) and \(v_i\) are the apparent magnitudes obtained for the candidate star in two observations closely spaced in time on some occasion \(i\), \(\sigma_{b, i}\) and \(\sigma_{v, i}\) are the standard errors of those magnitudes, \(\hat{b}\) and hat{v} are the weighted mean magnitudes in the two filters, and \(n\) is the number of observation pairs.
Since a given frame pair may include data from two filters which did not have equal numbers of observations overall, the “relative error” is calculated as follows:
\[\delta = \sqrt{\frac{n}{n-1}} \frac{v-\hat{v}}{\sigma_v}\]allowing all residuals to be compared on an equal basis.
References
[richards2011machine]Richards, J. W., Starr, D. L., Butler, N. R., Bloom, J. S., Brewer, J. M., Crellin-Quick, A., … & Rischard, M. (2011). On machine-learned classification of variable stars with sparse and noisy time-series data. The Astrophysical Journal, 733(1), 10. Doi:10.1088/0004-637X/733/1/10.
Examples
>>> fs = feets.FeatureSpace(only=['SlottedALength','StetsonK_AC']) >>> features = fs.extract(**lc_normal) >>> features[0] {'SlottedALength': np.int64(1), 'StetsonK_AC': np.float64(0.6440898442951952)}
- class feets.extractors.ext_stetson.StetsonL(**kwargs)[source]¶
Bases:
ExtractorStetson L variability index extractor.
StetsonL
Stetson L variability index describes the synchronous variability of different bands and is defined as:
\[L = \frac{JK}{0.798}\]Again, for a Gaussian magnitude distribution, \(L\) should take a value close to zero.
Notes
This feature is based on the Welch/Stetson variability index \(I\) (Stetson, 1996) defined by the equation:
\[I = \sqrt{\frac{1}{n(n-1)}} \sum_{i=1}^n { (\frac{b_i-\hat{b}}{\sigma_{b,i}}) (\frac{v_i - \hat{v}}{\sigma_{v,i}})}\]where \(b_i\) and \(v_i\) are the apparent magnitudes obtained for the candidate star in two observations closely spaced in time on some occasion \(i\), \(\sigma_{b, i}\) and \(\sigma_{v, i}\) are the standard errors of those magnitudes, \(\hat{b}\) and hat{v} are the weighted mean magnitudes in the two filters, and \(n\) is the number of observation pairs.
Since a given frame pair may include data from two filters which did not have equal numbers of observations overall, the “relative error” is calculated as follows:
\[\delta = \sqrt{\frac{n}{n-1}} \frac{v-\hat{v}}{\sigma_v}\]allowing all residuals to be compared on an equal basis.
References
[richards2011machine]Richards, J. W., Starr, D. L., Butler, N. R., Bloom, J. S., Brewer, J. M., Crellin-Quick, A., … & Rischard, M. (2011). On machine-learned classification of variable stars with sparse and noisy time-series data. The Astrophysical Journal, 733(1), 10. Doi:10.1088/0004-637X/733/1/10.
Examples
>>> fs = feets.FeatureSpace(only=['StetsonL']) >>> features = fs.extract(**lc_normal) >>> features[0] {'StetsonL': np.float64(0.0015499030048823923)}
- extract(aligned_magnitude, aligned_magnitude2, aligned_error, aligned_error2)[source]¶
Extract features from time series data vectors.
- Parameters:
- aligned_magnitudearray-like
- aligned_magnitude2array-like
- aligned_errorarray-like
- aligned_error2array-like
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_stetson_k module¶
Stetson K extractor.
- class feets.extractors.ext_stetson_k.StetsonK(**kwargs)[source]¶
Bases:
LightCurveExtractorStetson K coefficient described light curve shape.
\[\mathrm{Stetson}~K = \frac{ \sum_i\left|\frac{m_i - \bar{m} }{ \delta_i}\right|}{\sqrt{N\,\chi^2} }\]where \(N\) is the number of observations, \(\bar{m}\) is the weighted mean magnitude, and
\[\chi^2 = \sum_i\left( \frac{m_i - \langle m \rangle}{\delta_i}\right )^2\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
References
[stetson1996automatic]Stetson, P. B. (1996). On the Automatic Determination of Light-Curve Parameters for Cepheid Variables. Publications of the Astronomical Society of the Pacific, 108(728), 851-876. http://www.jstor.org/stable/40680814
- extract(magnitude, error, time=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- errorarray-like
- timearray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_structure_functions module¶
Structure functions extractor.
- class feets.extractors.ext_structure_functions.StructureFunctions(**kwargs)[source]¶
Bases:
ExtractorTStructure functions extractor.
The structure function of rotation measures (RMs) contains information on electron density and magnetic field fluctuations.
References
[simonetti1984small]Simonetti, J. H., Cordes, J. M., & Spangler, S. R. (1984). Small-scale variations in the galactic magnetic field-The rotation measure structure function and birefringence in interstellar scintillations. The Astrophysical Journal, 284, 126-134.
Examples
>>> fs = feets.FeatureSpace(only=[ ... 'StructureFunction_index_21', ... 'StructureFunction_index_31', ... 'StructureFunction_index_32', ... ]) >>> features = fs.extract(**lc_normal) >>> features[0] {'StructureFunction_index_21': np.float64(1.6029987396657115), 'StructureFunction_index_31': np.float64(2.050072565193364), 'StructureFunction_index_32': np.float64(1.4137753817054497)}
feets.extractors.ext_time_mean module¶
Time mean extractor.
- class feets.extractors.ext_time_mean.TimeMean(**kwargs)[source]¶
Bases:
LightCurveExtractorMean time.
\[\frac1{N} \sum_i {t_i}\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(time, magnitude=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- magnitudearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_time_std module¶
Time standard deviation extractor.
- class feets.extractors.ext_time_std.TimeStd(**kwargs)[source]¶
Bases:
LightCurveExtractorStandard deviation of time moments.
TimeStd (\(\sigma_t\))
\[\sigma_t = \frac{\sum_i {(t_i - \langle t \rangle)^2}}{N - 1}\]where \(N\) is the number of observations and \(\langle m \rangle\) is the mean magnitude.
- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
- extract(time, magnitude=None, error=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- magnitudearray-like, optional
- errorarray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_villar_fit module¶
Villar fit extractor.
- class feets.extractors.ext_villar_fit.VillarFit(**kwargs)[source]¶
Bases:
LightCurveExtractorVillar function fit.
Seven fit parameters and goodness of fit (reduced \(\chi^2\)) of the Villar function developed for supernovae classification:
\[\begin{split}f(t) = c + \frac{A}{1 + \exp{\frac{-(t-t_0)}{\tau_\mathrm{rise}}}} \left\{ \begin{array}{ll} 1 - \frac{\nu (t - t_0)}{\gamma}, &t < t_0 + \gamma \\ (1 - \nu) \exp{\frac{-(t-t_0-\gamma)}{\tau_\mathrm{fall} }}, &t \geq t_0 + \gamma \end{array} \right.\end{split}\]where \(A, \gamma, \tau_\mathrm{rise}, \tau_\mathrm{fall} > 0\), \(\nu \in [0; 1)\).
Here we introduce a new dimensionless parameter \(\nu\) instead of the plateau slope \(\beta\) from the original paper:
\[\nu \equiv -\beta \gamma / A\]Note, that the Villar function is developed to be used with fluxes, not magnitudes.
VillarFit_Amplitude (\(A\))
Half amplitude of the Villar function
VillarFit_Baseline (\(c\))
Baseline of the Villar function
VillarFit_ReferenceTime (\(t_0\))
Reference time of the Villar function
VillarFit_RiseTime (\(\tau_\mathrm{rise}\))
Rise time of the Villar function
VillarFit_FallTime (\(\tau_\mathrm{fall}\))
Decline time of the Villar function
VillarFit_PlateauRelAmplitude (\(\nu = -\beta \gamma / A\))
Relative plateau amplitude of the Villar function
VillarFit_PlateauDuration (\(\gamma\))
Plateau duration of the Villar function
VillarFit_ReducedChi2 (reduced \(\chi^2\))
Villar fit quality
- Parameters:
- algorithmstr
Non-linear least-square algorithm, supported values are: ‘mcmc’, ‘ceres’, ‘mcmc-ceres’, ‘lmsder’, ‘mcmc-lmsder’.
- mcmc_niterint, default=128
Number of MCMC iterations.
- ceres_niterint, default=10
Number of Ceres iterations.
- ceres_loss_regfloat, optional
Ceres loss regularization, default is to use square norm as is, if set to a number, the loss function is regularized to discriminate outlier residuals larger than this value. Default is None which means no regularization.
- lmsder_niterint, default=10
Number of LMSDER iterations.
- initlist or None, optional
Initial conditions, must be None or a list of float`s or `None`s. The length of the list must be 7, `None values will be replaced with some default values. It is supported by MCMC only
- boundslist of tuples or None, optional
Boundary conditions, must be None or a list of tuple`s of `float`s or `None`s. The length of the list must be 7, boundary conditions must include initial conditions, `None values will be replaced with some broad defaults. It is supported by MCMC only
- ln_priorstr or list of ln_prior.LnPrior1D or None, optional
Prior for MCMC, None means no prior. It is specified by a string literal or a list of 7 light_curve.ln_prior.LnPrior1D objects, see light_curve.ln_prior submodule for corresponding functions. Available string literals are:
‘no’: no prior
‘hosseinzadeh2020’: prior adopted from Hosseinzadeh et al. 2020, it assumes that t is in days
- transformstr or bool or None, optional
If False or None (default) output is not transformed. If True output is transformed as following:
Half-amplitude A is transformed as \(zp - 2.5 lg(2*A)\), \(zp = 8.9\), so that the amplitude is assumed to be the object peak flux in Jy.
baseline flux is normalised by \(A: baseline -> baseline / A\)
reference time is removed
goodness of fit is transformed as \(ln(reduced chi^2 + 1)\) to reduce its spread
other parameters are not transformed
- extract(time, flux, flux_error)[source]¶
Extract features from time series data vectors.
- Parameters:
- timearray-like
- fluxarray-like
- flux_errorarray-like
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_weighted_beyond_n_std module¶
Weighted beyond-N-standard-deviations extractor.
- class feets.extractors.ext_weighted_beyond_n_std.WeightedBeyondNStd(**kwargs)[source]¶
Bases:
ExtractorWeighted beyond-N-standard-deviation extractor.
WeightedBeyondNStd
Percentage of points beyond \(N\) standard deviations from the weighted mean. For a normal distribution with \(N=1\), it should take a value close to \(0.32\).
- Parameters:
- nstdint, default=1
Number of standard deviations. Default is 1.
See also
feets.extractors.BeyondNStd
References
[richards2011machine]Richards, J. W., Starr, D. L., Butler, N. R., Bloom, J. S., Brewer, J. M., Crellin-Quick, A., … & Rischard, M. (2011). On machine-learned classification of variable stars with sparse and noisy time-series data. The Astrophysical Journal, 733(1), 10. Doi:10.1088/0004-637X/733/1/10.
Examples
>>> fs = feets.FeatureSpace(only=['WeightedBeyondNStd']) >>> features = fs.extract(**lc_normal) >>> features[0] {'WeightedBeyondNStd': 0.327}
- extract(magnitude, error)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- errorarray-like
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
- flatten_feature(feature, value)[source]¶
Normalize a feature value into a dictionary of scalars.
This method is called internally to better represent the returned features of the extract() method.
- Parameters:
- featurestr
The name of the feature.
- valueobject
The raw value as received by the extract() method.
- Returns:
- dict
A dictionary of scalars representing the flattened feature.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.ext_weighted_mean module¶
Weighted mean extractor.
- class feets.extractors.ext_weighted_mean.WeightedMean(**kwargs)[source]¶
Bases:
LightCurveExtractorWeighted mean magnitude.
WeightedMean (\(\bar{m}\))
\[\bar{m} = \frac{\sum_i m_i / \delta_i^2}{\sum_i 1 / \delta_i^2}.\]- Parameters:
- transformstr or bool or None, optional
Transformer to apply to the feature values. If str, must be one of:
‘default’ - use default transformer for the feature, it same as giving True. The default for this feature is ‘identity’
‘arcsinh’ - Hyperbolic arcsine feature transformer
‘clipped_lg’ - Decimal logarithm of a value clipped to a minimum value
‘identity’ - Identity feature transformer
‘lg’ - Decimal logarithm feature transformer
‘ln1p’ - \(ln(1+x)\) feature transformer
‘sqrt’ - Square root feature transformer
If bool, must be True to use default transformer or False to disable. If None, no transformation is applied.
See also
feets.extractors.Mean
- extract(magnitude, error, time=None)[source]¶
Extract features from time series data vectors.
- Parameters:
- magnitudearray-like
- errorarray-like
- timearray-like, optional
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.extractors.extractor module¶
Feature extractor base classes.
- class feets.extractors.extractor.Extractor[source]¶
Bases:
ABCAbstract base class for feature extractors.
To create a feature extractor, define a subclass of the Extractor class that defines a features attribute with the names of the new features, and implement the extract() method with the logic needed to compute them.
Once defined, the new extractor class must be registered in the extractor registry to make it available to new FeatureSpace instances for automatic discovery and usage.
A feature extractor may also expose optional parameters to customize its behavior. To add such parameters, implement the __init__() method and specify them as keyword arguments.
For representation purposes, the features returned by the extract() method must be normalizable into a flat dictionary of scalar values. This is internally accomplished by the flatten_feature() method, which can be extended to add support for custom formats.
- Parameters:
- **kwargs
Optional parameters to change the behavior of the extractor.
- Attributes:
- featuresarray_like of str
The features that can be computed with the extract() method.
Methods
extract(**kwargs)
Implement this method in a subclass such that it returns a dictionary containing the computed values for all of the features defined in the features attribute.
flatten_feature(feature, value)
By default, it handles the normalization of scalars, sequences and dictionaries. Extend this method to add support to more complex formats.
See also
feets.FeatureSpaceClass to select and extract features from a time series.
feets.extractor_registryExtractor registry of available feature extractors.
Examples
Extractor that computes the sum of the magnitude data vector:
>>> magnitude = [1, 2, 3, 4] ... >>> class SumExtractor(Extractor): ... features = ["Sum"] ... ... def extract(self, magnitude): ... return {"Sum": sum(magnitude)} ... >>> sum_ext = SumExtractor() >>> sum_results = ext.extract(magnitude) >>> sum_results {'Sum': 10}
Extractor that depends on the previously computed Sum feature to compute the mean of the magnitude data vector:
>>> class MeanExtractor(Extractor): ... features = ["Mean"] ... ... def extract(self, magnitude, Sum): ... return {"Mean": Sum / len(magnitude)} ... >>> mean_ext = MeanExtractor() >>> mean_results = mean_ext.extract(magnitude, sum_results['Sum']) >>> mean_results {'Mean': 2.5}
Extractor that implements normalization for custom feature formats:
>>> class CustomFormatExtractor(Extractor): ... features = ["Min", "Parity", "NoDuplicates", "Squared"] ... ... def extract(self, magnitude): ... return { ... "Min": min(magnitude), # number ... "Parity": { ... "even": [x for x in magnitude if int(x) % 2 == 0], ... "odd": [x for x in magnitude if int(x) % 2 != 0] ... }, # dict[string, list of number] ... "NoDuplicates": set(magnitude), # set of number ... "Squared": map(lambda x: x**2, magnitude) # map of number ... } ... ... def flatten_feature(self, feature, value): ... if feature in ("NoDuplicates", "Squared"): ... # add support for sets and maps ... return { ... f"{feature}_{i}": item for i, item in enumerate(value) ... } ... else: ... # fallback to default behavior ... return super().flatten_feature(feature, value) ... >>> custom_format_ext = CustomFormatExtractor() >>> custom_format_results = custom_format_ext.extract(magnitude) >>> custom_format_results { 'Min': 1, 'Parity': {'even': [2, 4], 'odd': [1, 3]}, 'NoDuplicates': {1, 2, 3, 4}, 'Squared': <map object at 0x7fc9c3d7a350> } >>> custom_format_ext.flatten_feature( ... "Min", custom_format_results['Min'] ... ) {'Min': 1} >>> custom_format_ext.flatten_feature( ... "Parity", custom_format_results['Parity'] ... ) { 'Parity_even_0': 2, 'Parity_even_1': 4, 'Parity_odd_0': 1, 'Parity_odd_1': 3 } >>> custom_format_ext.flatten_feature( ... "NoDuplicates", custom_format_results['NoDuplicates'] ... ) { 'NoDuplicates_0': 1, 'NoDuplicates_1': 2, 'NoDuplicates_2': 3, 'NoDuplicates_3': 4 } >>> custom_format_ext.flatten_feature( ... "Squared", custom_format_results['Squared'] ... ) { 'Squared_0': 1, 'Squared_1': 4, 'Squared_2': 9, 'Squared_3': 16 }
- abstract extract(*args, **kwargs)[source]¶
Extract features from time series data vectors.
- Parameters:
- *args
Includes the time series data vectors that are required as inputs for the extraction, as well as the necessary feature dependencies.
- **kwargs
Additional time series data vectors that can be used as optional inputs for the extraction.
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
- flatten_feature(feature, value)[source]¶
Normalize a feature value into a dictionary of scalars.
This method is called internally to better represent the returned features of the extract() method.
- Parameters:
- featurestr
The name of the feature.
- valueobject
The raw value as received by the extract() method.
- Returns:
- dict
A dictionary of scalars representing the flattened feature.
See also
feets.ExtractorAbstract base class for feature extractors.
- classmethod get_data()[source]¶
Get the data vectors that can be used by the feature extractor.
The result is the union of the required and optional data vectors.
- Returns:
- frozenset
Time series data vectors that the extract() method can use to compute the features.
See also
- classmethod get_default_params()[source]¶
Get the default values for the feature extractor parameters.
- Returns:
- dict
The default values for the parameters defined by the __init__() method.
See also
- classmethod get_dependencies()[source]¶
Get the feature dependencies required by the feature extractor.
- Returns:
- frozenset
Features that should be previously computed by other extractors, and are required for the extract() method to compute its own features.
See also
- classmethod get_features()[source]¶
Get the features that can be computed by the feature extractor.
- Returns:
- frozenset
The features that the extract() method can compute.
See also
- classmethod get_optional_data()[source]¶
Get the data vectors optionally used by the feature extractor.
- Returns:
- frozenset
Time series data vectors that can be optionally passed to the extract() method to compute the features.
See also
- classmethod get_required_data()[source]¶
Get the data vectors required by the feature extractor.
- Returns:
- frozenset
Time series data vectors that are required for the extract() method to compute the features.
See also
- property params¶
Feature extractor initial parameters.
- Returns:
- dict
The parameters passed to the __init__() method.
See also
- classmethod prepare_extract(data, dependencies)[source]¶
Build keyword arguments for the extract() method.
Combine the required features from dependencies and the data vectors from data into the dictionary of keyword arguments that should be passed to the extract() method.
- Parameters:
- datadict
The available time series data vectors.
- dependenciesdict
The available features computed by other extractors.
- Returns:
- dict
The keyword arguments for the extract() method.
- Raises:
- ExtractorValidationError
A required data vector or feature dependency is missing from the provided values.
- to_dict()[source]¶
Convert the Extractor object to a dictionary representation.
- Returns:
- dict
A dictionary representation of the Extractor, including the values of the parameters.
- classmethod validate_extract(features)[source]¶
Validate the results of the extract() method.
Validate that the extracted features match the features attribute.
- Parameters:
- featuresdict
The results extracted with the extract() method.
- Raises:
- ExtractorValidationError
If the extracted features don’t match the ones defined in the features attribute.
- exception feets.extractors.extractor.ExtractorBadDefinedError[source]¶
Bases:
TypeErrorThe extractor class is not defined properly.
- exception feets.extractors.extractor.ExtractorValidationError[source]¶
Bases:
ValueErrorSome value used by the extractor is missing or invalid.
- exception feets.extractors.extractor.ExtractorWarning[source]¶
Bases:
UserWarningWarn about the Extractor behavior.
- exception feets.extractors.extractor.FeatureExtractionWarning[source]¶
Bases:
UserWarningWarn about the calculation of some feature.
feets.extractors.light_curve_extractor module¶
Abstract class for light_curve compatible extractors.
- class feets.extractors.light_curve_extractor.LightCurveExtractor[source]¶
Bases:
ExtractorAbstract class for light_curve compatible extractors.
- classmethod prepare_extract(data, dependencies)[source]¶
Build keyword arguments for the extract() method.
Combine the required features from dependencies and the data vectors from data into the dictionary of keyword arguments that should be passed to the extract() method.
- Parameters:
- datadict
The available time series data vectors.
- dependenciesdict
The available features computed by other extractors.
- Returns:
- dict
The keyword arguments for the extract() method.
- Raises:
- ExtractorValidationError
A required data vector or feature dependency is missing from the provided values.
feets.extractors.registry module¶
Manage the available feature extractors.
- exception feets.extractors.registry.EntityNotFoundError[source]¶
Bases:
RegistryErrorAn extractor or feature is not available in the registry.
- class feets.extractors.registry.ExtractorRegistry[source]¶
Bases:
objectExtractor registry of available feature extractors.
The ExtractorRegistry class is responsible for managing the available feature extractors. It ensures that all dependencies are met before registering an extractor and prevents duplicate features.
It also provides methods to check if a feature or extractor is registered, retrieve the extractor for a specific feature, and generate an execution plan for extractors based on provided data and feature constraints.
See also
feets.ExtractorAbstract base class for feature extractors.
feets.FeatureSpaceClass to select and extract features from a time series.
Examples
Add a custom extractor to the existing feature extractor registry:
>>> from feets.extractors import Extractor, extractor_registry
>>> class CustomSumExtractor(Extractor): ... features = ["CustomSum"] ... ... def extract(self, magnitude): ... return {"CustomSum": sum(magnitude)} ... >>> extractor_registry.register_extractor(CustomSumExtractor)
Check if a feature is available:
>>> extractor_registry.is_feature_registered("CustomSum") True
- extractor_of(feature)[source]¶
Get the extractor that can extract a given feature.
- Parameters:
- featurestr
The name of the feature to get the extractor of.
- Returns:
- Extractor
The feature extractor that can extract the given feature.
- Raises:
- EntityNotFoundError
If the feature is not registered.
- extractors_from_data(data)[source]¶
Get the extractors that can be executed from the available data.
- Parameters:
- dataiterable of str
The data vectors to filter extractors by.
- Returns:
- set of Extractor
The feature extractors that can be executed from the available data vectors.
- Raises:
- RegistryValidationError
If any of the specified data vectors is invalid.
- extractors_from_features(features)[source]¶
Get the extractors that can compute the given features.
- Parameters:
- featuresiterable of str
The features to filter extractors by.
- Returns:
- set of Extractor
The feature extractors that can compute the given features.
- Raises:
- EntityNotFoundError
If any of the specified features is not registered.
- get_execution_plan(*, data=None, only=None, exclude=None)[source]¶
Generate an execution plan for feature extractors.
- Parameters:
- dataiterable of str, optional
The required data for the extractors.
- onlyiterable of str, optional
The features to include in the execution plan.
- excludeiterable of str, optional
The features to exclude from the execution plan.
- Returns:
- tuple of Extractor
The feature extractors that match the provided filters, in the order they should be executed to ensure all their dependencies are met.
- Raises:
- RegistryValidationError
If the same feature is passed in both only and exclude or if any of the specified data vectors in data is not valid.
- EntityNotFoundError
If any of the features passed in only or exclude is not registered.
- is_extractor_registered(extractor)[source]¶
Check if an extractor is available in the registry.
- Parameters:
- extractorclass
The feature extractor class to check.
- Returns:
- bool
True if the feature extractor is already registered.
- is_feature_registered(feature)[source]¶
Check if a feature is extracted by any registered extractor.
- Parameters:
- featurestr
The name of the feature to check.
- Returns:
- bool
True if the feature is computed by any of the registered feature extractors.
- register_extractor(cls)[source]¶
Add a feature extractor to the registry.
Ensure that all dependencies are met before registering the extractor.
- Parameters:
- clsclass
The feature extractor class to register.
- Returns:
- Extractor
The registered feature extractor class.
- Raises:
- EntityNotFoundError
If one of the dependencies of the extractor is not registered.
- RegistryConflictError
If one of the features of the extractor is already registered.
- property registered_extractors¶
frozenset: The extractors that are available in the registry.
- property registered_features¶
frozenset: The features that are available in the registry.
- sort_extractors_by_dependencies(extractors)[source]¶
Compute the feature extractor dependency resolution order.
This method determines the order in which feature extractors should be executed to ensure all their dependencies are met. It may introduce additional extractors if their outputs are required by other extractors.
- Parameters:
- extractorsiterable of Extractor
The extractors to sort.
- Returns:
- tuple of Extractor
The feature extractors sorted by their dependencies.
- Raises:
- EntityNotFoundError
If any of the specified extractors is not registered.
- exception feets.extractors.registry.RegistryConflictError[source]¶
Bases:
RegistryErrorA conflict occurred during registration or unregistration.
- exception feets.extractors.registry.RegistryError[source]¶
Bases:
ExceptionBase class for all registry-related errors.
- exception feets.extractors.registry.RegistryValidationError[source]¶
Bases:
RegistryErrorAn error occurred due to invalid parameters.
Module contents¶
Features extractors classes and register utilities.
- class feets.extractors.Extractor[source]¶
Bases:
ABCAbstract base class for feature extractors.
To create a feature extractor, define a subclass of the Extractor class that defines a features attribute with the names of the new features, and implement the extract() method with the logic needed to compute them.
Once defined, the new extractor class must be registered in the extractor registry to make it available to new FeatureSpace instances for automatic discovery and usage.
A feature extractor may also expose optional parameters to customize its behavior. To add such parameters, implement the __init__() method and specify them as keyword arguments.
For representation purposes, the features returned by the extract() method must be normalizable into a flat dictionary of scalar values. This is internally accomplished by the flatten_feature() method, which can be extended to add support for custom formats.
- Parameters:
- **kwargs
Optional parameters to change the behavior of the extractor.
- Attributes:
- featuresarray_like of str
The features that can be computed with the extract() method.
Methods
extract(**kwargs)
Implement this method in a subclass such that it returns a dictionary containing the computed values for all of the features defined in the features attribute.
flatten_feature(feature, value)
By default, it handles the normalization of scalars, sequences and dictionaries. Extend this method to add support to more complex formats.
See also
feets.FeatureSpaceClass to select and extract features from a time series.
feets.extractor_registryExtractor registry of available feature extractors.
Examples
Extractor that computes the sum of the magnitude data vector:
>>> magnitude = [1, 2, 3, 4] ... >>> class SumExtractor(Extractor): ... features = ["Sum"] ... ... def extract(self, magnitude): ... return {"Sum": sum(magnitude)} ... >>> sum_ext = SumExtractor() >>> sum_results = ext.extract(magnitude) >>> sum_results {'Sum': 10}
Extractor that depends on the previously computed Sum feature to compute the mean of the magnitude data vector:
>>> class MeanExtractor(Extractor): ... features = ["Mean"] ... ... def extract(self, magnitude, Sum): ... return {"Mean": Sum / len(magnitude)} ... >>> mean_ext = MeanExtractor() >>> mean_results = mean_ext.extract(magnitude, sum_results['Sum']) >>> mean_results {'Mean': 2.5}
Extractor that implements normalization for custom feature formats:
>>> class CustomFormatExtractor(Extractor): ... features = ["Min", "Parity", "NoDuplicates", "Squared"] ... ... def extract(self, magnitude): ... return { ... "Min": min(magnitude), # number ... "Parity": { ... "even": [x for x in magnitude if int(x) % 2 == 0], ... "odd": [x for x in magnitude if int(x) % 2 != 0] ... }, # dict[string, list of number] ... "NoDuplicates": set(magnitude), # set of number ... "Squared": map(lambda x: x**2, magnitude) # map of number ... } ... ... def flatten_feature(self, feature, value): ... if feature in ("NoDuplicates", "Squared"): ... # add support for sets and maps ... return { ... f"{feature}_{i}": item for i, item in enumerate(value) ... } ... else: ... # fallback to default behavior ... return super().flatten_feature(feature, value) ... >>> custom_format_ext = CustomFormatExtractor() >>> custom_format_results = custom_format_ext.extract(magnitude) >>> custom_format_results { 'Min': 1, 'Parity': {'even': [2, 4], 'odd': [1, 3]}, 'NoDuplicates': {1, 2, 3, 4}, 'Squared': <map object at 0x7fc9c3d7a350> } >>> custom_format_ext.flatten_feature( ... "Min", custom_format_results['Min'] ... ) {'Min': 1} >>> custom_format_ext.flatten_feature( ... "Parity", custom_format_results['Parity'] ... ) { 'Parity_even_0': 2, 'Parity_even_1': 4, 'Parity_odd_0': 1, 'Parity_odd_1': 3 } >>> custom_format_ext.flatten_feature( ... "NoDuplicates", custom_format_results['NoDuplicates'] ... ) { 'NoDuplicates_0': 1, 'NoDuplicates_1': 2, 'NoDuplicates_2': 3, 'NoDuplicates_3': 4 } >>> custom_format_ext.flatten_feature( ... "Squared", custom_format_results['Squared'] ... ) { 'Squared_0': 1, 'Squared_1': 4, 'Squared_2': 9, 'Squared_3': 16 }
- abstract extract(*args, **kwargs)[source]¶
Extract features from time series data vectors.
- Parameters:
- *args
Includes the time series data vectors that are required as inputs for the extraction, as well as the necessary feature dependencies.
- **kwargs
Additional time series data vectors that can be used as optional inputs for the extraction.
- Returns:
- dict
The computed values for all of the features defined in the features attribute.
See also
feets.ExtractorAbstract base class for feature extractors.
- flatten_feature(feature, value)[source]¶
Normalize a feature value into a dictionary of scalars.
This method is called internally to better represent the returned features of the extract() method.
- Parameters:
- featurestr
The name of the feature.
- valueobject
The raw value as received by the extract() method.
- Returns:
- dict
A dictionary of scalars representing the flattened feature.
See also
feets.ExtractorAbstract base class for feature extractors.
- classmethod get_data()[source]¶
Get the data vectors that can be used by the feature extractor.
The result is the union of the required and optional data vectors.
- Returns:
- frozenset
Time series data vectors that the extract() method can use to compute the features.
See also
- classmethod get_default_params()[source]¶
Get the default values for the feature extractor parameters.
- Returns:
- dict
The default values for the parameters defined by the __init__() method.
See also
- classmethod get_dependencies()[source]¶
Get the feature dependencies required by the feature extractor.
- Returns:
- frozenset
Features that should be previously computed by other extractors, and are required for the extract() method to compute its own features.
See also
- classmethod get_features()[source]¶
Get the features that can be computed by the feature extractor.
- Returns:
- frozenset
The features that the extract() method can compute.
See also
- classmethod get_optional_data()[source]¶
Get the data vectors optionally used by the feature extractor.
- Returns:
- frozenset
Time series data vectors that can be optionally passed to the extract() method to compute the features.
See also
- classmethod get_required_data()[source]¶
Get the data vectors required by the feature extractor.
- Returns:
- frozenset
Time series data vectors that are required for the extract() method to compute the features.
See also
- property params¶
Feature extractor initial parameters.
- Returns:
- dict
The parameters passed to the __init__() method.
See also
- classmethod prepare_extract(data, dependencies)[source]¶
Build keyword arguments for the extract() method.
Combine the required features from dependencies and the data vectors from data into the dictionary of keyword arguments that should be passed to the extract() method.
- Parameters:
- datadict
The available time series data vectors.
- dependenciesdict
The available features computed by other extractors.
- Returns:
- dict
The keyword arguments for the extract() method.
- Raises:
- ExtractorValidationError
A required data vector or feature dependency is missing from the provided values.
- to_dict()[source]¶
Convert the Extractor object to a dictionary representation.
- Returns:
- dict
A dictionary representation of the Extractor, including the values of the parameters.
- classmethod validate_extract(features)[source]¶
Validate the results of the extract() method.
Validate that the extracted features match the features attribute.
- Parameters:
- featuresdict
The results extracted with the extract() method.
- Raises:
- ExtractorValidationError
If the extracted features don’t match the ones defined in the features attribute.
- exception feets.extractors.ExtractorBadDefinedError[source]¶
Bases:
TypeErrorThe extractor class is not defined properly.
- exception feets.extractors.ExtractorValidationError[source]¶
Bases:
ValueErrorSome value used by the extractor is missing or invalid.
- exception feets.extractors.ExtractorWarning[source]¶
Bases:
UserWarningWarn about the Extractor behavior.