KaleLinear is a Python library for non-deep machine learning that learns transferable, shared, or group-specific models from data across multiple sources, groups, blocks, or views. It provides NumPy-based methods in linear or reproducing kernel Hilbert spaces (RKHS), including transfer learning, domain adaptation, manifold regularization, and group-aware learning, through a scikit-learn style API.
The package is part of the PyKale ecosystem and focuses on linear and kernel methods for data characterized by covariates (e.g., domain labels, group labels, side information), unlabeled target samples, or tensor structures.
Key features
- Feature transformation models for data embedding via
kalelinear.transformer (PyKale-style alias: kalelinear.embed):
- Dimension reduction for multiview tensor data:
- Multilinear Principal Component Analysis (
MPCA) [1]
- Transferable / generalizable feature extraction across domains or groups:
- Correlation Alignment (
CORAL) [13]
- Geodesic Flow Kernel (
GFK) [14]
- Transfer Component Analysis (
TCA) [2]
- Joint Distribution Adaptation (
JDA) [3]
- Balanced Distribution Adaptation (
BDA) [4]
- Maximum Independence Domain Adaptation (
MIDA) [5]
- Common (or shared or joint) and individual feature separation / extraction across groups or blocks:
- Common and Individual Feature Extraction (
CIFE) [11]
- Angle-based Joint and Individual Variation Explained (
AJIVE) [12]
- Estimator models for prediction via
kalelinear.estimator (PyKale-style alias: kalelinear.predict):
- Predictive models that generalize across domains or groups:
- Manifold Regularization Learning Framework (
LapSVM, LapRLS) [6]
- Adaptation Regularization Learning Framework (
ARSVM, ARRLS) [7]
- Covariate Independence Regularized Learning Framework (
CoIRSVM, CoIRLS) [8][9]
- Group-specific predictive models:
- Group-specific Discriminant Analysis (
GSDA) [9][10]
- Lightweight: plain NumPy array inputs and outputs — no deep-learning framework or GPU required.
- scikit-learn style
fit, transform, predict, fit_transform, and fit_predict workflows where applicable.
- Most methods accept additional
covariates — e.g., domain or group labels — alongside X and y, with optional one-hot encoding for categorical values; multiblock transformers (CIFE, AJIVE) take groups to specify block membership.
KaleLinear requires Python 3.10 or later. Core dependencies include:
Getting started
Installation
Install the released package from PyPI:
pip install kalelinear
Install from a local checkout for development:
pip install -e ".[dev]"
Development
From the root of the repository, run the following commands in your terminal:
Install pre-commit hooks (only required once):
pre-commit install
Run pre-commit checks for code style and formatting on all files:
pre-commit run --all-files
Run test cases to verify functionality:
pytest
Build the documentation:
pip install -r docs/requirements.txt
sphinx-build -b html docs/source docs/build/html
See CONTRIBUTING.md for detailed contribution guidelines.
Public API
from kalelinear.transformer import BDA, CORAL, JDA, MIDA, MPCA, TCA
from kalelinear.estimator import ARRLS, ARSVM, CoIRLS, CoIRSVM, GSDA, LapRLS, LapSVM
Worked examples for the main transformers and estimators are collected in
Tutorials:
- Learn a domain-invariant embedding with TCA
- Align source and target features with CORAL
- Use MIDA with categorical covariates
- Extract common and individual features across groups with CIFE or AJIVE
- Train a domain adaptation classifier (ARSVM, ARRLS)
- Train a manifold-regularized classifier (LapSVM, LapRLS)
References
[1] Lu, H., Plataniotis, K.N. and Venetsanopoulos, A.N., 2008. MPCA: Multilinear principal component analysis of tensor objects. IEEE Transactions on Neural Networks, 19(1), pp.18-39.
[2] Pan, S.J., Tsang, I.W., Kwok, J.T. and Yang, Q., 2011. Domain adaptation via transfer component analysis. IEEE Transactions on Neural Networks, 22(2), p.199-210.
[3] Long, M., Wang, J., Ding, G., Sun, J. and Yu, P.S., 2013. Transfer feature learning with joint distribution adaptation. In Proceedings of the IEEE International Conference on Computer Vision (pp. 2200-2207).
[4] Wang, J., Chen, Y., Hao, S., Feng, W. and Shen, Z., 2017, November. Balanced distribution adaptation for transfer learning. In 2017 IEEE International Conference on Data Mining (ICDM) (pp. 1129-1134). IEEE.
[5] Yan, K., Kou, L. and Zhang, D., 2017. Learning domain-invariant subspace using domain features and independence maximization. IEEE Transactions on Cybernetics, 48(1), pp.288-299.
[6] Belkin, M., Niyogi, P. and Sindhwani, V., 2006. Manifold regularization: A geometric framework for learning from labeled and unlabeled examples. Journal of Machine Learning Research, 7(11).
[7] Long, M., Wang, J., Ding, G., Pan, S.J. and Yu, P.S., 2013. Adaptation regularization: A general framework for transfer learning. IEEE Transactions on Knowledge and Data Engineering, 26(5), pp.1076-1089.
[8] Zhou, S., Li, W., Cox, C. and Lu, H., 2020, April. Side information dependence as a regularizer for analyzing human brain conditions across cognitive experiments. In Proceedings of the AAAI Conference on Artificial Intelligence (Vol. 34, No. 04, pp. 6957-6964).
[9] Zhou, S., 2022. Interpretable Domain-Aware Learning for Neuroimage Classification (Doctoral dissertation, University of Sheffield).
[10] Zhou, S., Luo, J., Jiang, Y., Wang, H., Lu, H. and Gong, G., 2025. Group-specific discriminant analysis enhances detection of sex differences in brain functional network lateralization. GigaScience, 14, p.giaf082.
[11] Zhou, G., Cichocki, A., Zhang, Y. and Mandic, D., 2016. Group component analysis for multiblock data: Common and individual feature extraction. IEEE Transactions on Neural Networks and Learning Systems, 27(11), pp.2426-2439.
[12] Feng, Q., Jiang, M., Hannig, J. and Marron, J.S., 2018. Angle-based joint and individual variation explained. Journal of Multivariate Analysis, 166, pp.241-265.
[13] Sun, B., Feng, J. and Saenko, K., 2016. Return of frustratingly easy domain adaptation. In Proceedings of the AAAI Conference on Artificial Intelligence (Vol. 30, No. 1, pp. 2058-2065).
[14] Gong, B., Shi, Y., Sha, F. and Grauman, K., 2012. Geodesic flow kernel for unsupervised domain adaptation. In IEEE Conference on Computer Vision and Pattern Recognition (pp. 2066-2073).
Other open domain adaptation repositories
License
KaleLinear is released under the MIT License. See LICENSE for details.