preprocessing.repeating_basis_function
preprocessing.repeating_basis_function
Repeating Basis Function transformer for cyclical features.
Classes
RepeatingBasisFunction
preprocessing.repeating_basis_function.RepeatingBasisFunction(
n_periods,
column,
input_range,
remainder= 'drop' ,
)
Transformer that encodes cyclical features using repeating radial basis functions.
This transformer places Gaussian basis functions across the specified input range and wraps them around to handle periodicity (e.g., day of year, hour of day). It is a simplified implementation to avoid external dependencies like scikit-lego.
Attributes
n_periods
int
Number of basis functions to place.
column
str
Name of the column in the input DataFrame/Series to transform.
input_range
Tuple [int , int ]
The range of the input values (min, max).
remainder
str
Policy for remaining columns (currently only ‘drop’ is supported).
Examples
>>> import pandas as pd
>>> import numpy as np
>>> from spotforecast2_safe.preprocessing.repeating_basis_function import RepeatingBasisFunction
>>> X = pd.DataFrame({"hour" : [0 , 6 , 12 , 18 , 23 ]})
>>> rbf = RepeatingBasisFunction(n_periods= 4 , column= "hour" , input_range= (0 , 23 ))
>>> features = rbf.fit_transform(X)
>>> features.shape
(5 , 4 )
Methods
fit
Fitted transformer (no-op).
transform
Transform the input data into RBF features.
fit
preprocessing.repeating_basis_function.RepeatingBasisFunction.fit(X, y= None )
Fitted transformer (no-op).
Parameters
X
Any
Input data.
required
y
Any
Ignored.
None