macrosynergy.learning.preprocessing.transformers#

class PanelPCA(n_components=None, kaiser_criterion=False, adjust_signs=False)[source]#

Bases: BaseEstimator, TransformerMixin

fit(X, y=None)[source]#

Fit method to determine an eigenbasis for the PCA.

Parameters:
  • X (pd.DataFrame) – Input feature matrix.

  • y (pd.DataFrame, pd.Series or np.ndarray, default=None) – Target variable.

Notes

The target variable y is only ever used to adjust the signs of the eigenvectors to ensure consistency of eigenvector signs when retrained over time. This does not affect the PCA itself.

transform(X)[source]#

Project input features onto the principal components.

Parameters:

X (pd.DataFrame) – Input feature matrix.

Returns:

Projected features.

Return type:

pd.DataFrame

get_feature_names_out(input_features=None)[source]#

Get output feature names produced by the transformation.

Parameters:

input_features (None) – This parameter has no effect and is included for compatibility with the scikit-learn API.

class ZnScoreAverager(neutral='zero', use_signs=False)[source]#

Bases: BaseEstimator, TransformerMixin

fit(X, y=None)[source]#

Extract relevant standardisation/normalisation statistics.

Parameters:
  • X (pd.DataFrame) – Input feature matrix.

  • y (Any, default=None) – Placeholder for scikit-learn compatibility.

transform(X)[source]#

Create an OOS conceptual parity signal by averaging PiT z-scores of features.

Parameters:

X (pd.DataFrame) – Input feature matrix.

Returns:

Output signal.

Return type:

pd.DataFrame

Submodules#