mlfinlab.features.kca
Module implements Kinetic Component Analysis (KCA) as presented by Marcos Lopez de Prado and Riccardo Rebonato in the following paper: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2422183
Module Contents
Classes
Kinetic Component Analysis (KCA), a state-space application that |
- class KCA(time_series: pandas.DataFrame, include_std: bool | None = False, sigma: int | None = 0, seed: int | None = 0.01)
-
Bases:
mlfinlab.features.base_noise_reduction.NoiseReductionMethod
Kinetic Component Analysis (KCA), a state-space application that extracts a signal from a series of noisy measurements by applying a Kalman Filter on a Taylor expansion of a stochastic process.
KCA decomposes the noisy signal in terms of three hidden components, which can be intuitively associated with position, velocity and acceleration.
- property seed: float
-
Returns the current seed value.
- Returns:
-
(float) Current seed value.
- property forecast_df: pandas.DataFrame
-
Returns DataFrame with forecast.
- Returns:
-
(pd.DataFrame) DataFrame with component forecasts.
- property dataframe: pandas.DataFrame
-
Returns dataframe with original time series and relevant signals generated by the noise reduction method.
- Returns:
-
(pd.DataFrame) Pandas DataFrame with relevant signals.
- property signal: numpy.array
-
Returns main signal generated from noise reduction method.
- Returns:
-
(np.array) Main signal generated from noise reduction method.
- __slots__ = ()
- update_seed(new_seed: float)
-
Update seed value.
- Parameters:
-
new_seed – (float) New seed value to set.
- get_position_signal() numpy.array
-
Returns KCA position component signal.
- Returns:
-
(np.array) Position signal.
- get_velocity_signal() numpy.array
-
Returns KCA velocity component signal.
- Returns:
-
(np.array) Velocity component signal.
- get_acceleration_signal() numpy.array
-
Returns KCA acceleration component signal.
- Returns:
-
(np.array) Acceleration component signal.
- generate_signal() numpy.array
-
Generates signal (position) and other components (velocity and acceleration) by running core KCA fit method.
- Returns:
-
(np.array) Main generated signal (position).
- generate_next_point_forecast() pandas.Series
-
Generate forecast for next point in signal (position).
- Returns:
-
(pd.Series) Next point forecast row with all components.
- generate_signal_forecast(num_to_forecast: float) numpy.array
-
Generate forecast of main signal (position) and its other components.
- Parameters:
-
num_to_forecast – (int) Number of points to forecast
- Returns:
-
(np.array) Main signal (position) forecast.
- generate_signal_with_forecast(num_to_forecast: int) numpy.array
-
Generate forecast of signal (plus components) and return main signal (position) with forecast included.
- Parameters:
-
num_to_forecast – (int) Number of points to forecast
- Returns:
-
(np.array) Main signal (position) with forecast included.