venumML.time_series.Phineus.phineus_timeseries
def
phineus_predict( ctx, data, forecast_periods=30, frequency='D', window_size=30, smoothing=False):
Predicts future values using an encrypted trend and seasonality model.
Parameters
- ctx (EncryptionContext): The encryption context used for encrypting data.
- data (pd.DataFrame): Input data containing a 'ds' column for dates and 'y' column for target values.
- forecast_periods (int, optional, default=30): Number of future periods to forecast.
- frequency (str, optional, default='D'): Frequency of the data (e.g., 'D' for daily).
- window_size (int, optional, default=30): Window size for rolling average smoothing.
- smoothing (bool, optional, default=False): Whether to apply a rolling average to smooth the data.
Returns
- fft_values (list of tuple): FFT of the detrended data as tuples of (real, imaginary).
- frequencies (np.ndarray): Frequencies corresponding to the FFT values.
- total_t (np.ndarray): Normalised time points for the forecast period.
- trend_predictions (np.ndarray): Forecasted trend values for the total period.
Notes
This function models the trend using encrypted linear regression and detrends the data for seasonal analysis with FFT. It can optionally apply a rolling average for smoothing.
def
reconstruct_signal(amplitudes, phases, frequencies, t, number_of_frequencies=10):
Reconstructs a signal from its Fourier components using the largest frequencies.
Parameters
- amplitudes (np.ndarray): Array of amplitude values from the FFT.
- phases (np.ndarray): Array of phase values corresponding to the FFT frequencies.
- frequencies (np.ndarray): Array of frequencies corresponding to the FFT values.
- t (np.ndarray): Time points for reconstructing the signal.
- number_of_frequencies (int, optional, default=10): Number of largest frequency components to use for reconstruction.
Returns
- np.ndarray: Reconstructed signal values for each time point in t.
def
extend_date_column(data, date_column, extension_count, frequency='D'):
Extends a date column by a specified number of periods.
Parameters
- data (pd.DataFrame): DataFrame containing the original date column.
- date_column (str): Name of the date column in the DataFrame.
- extension_count (int): Number of periods to extend the date column by.
- frequency (str, optional, default='D'): Frequency of the dates to be generated (e.g., 'D' for daily).
Returns
- pd.DataFrame: A new DataFrame with the extended date column.