Quickstart

Quickstart#

This notebook shows the smallest end-to-end iTuna workflow.

import numpy as np
from sklearn.decomposition import FastICA

import ituna

X = np.random.randn(1000, 64)

ensemble = ituna.ConsistencyEnsemble(
    estimator=FastICA(n_components=16, random_state=0, max_iter=2000),
    consistency_transform=ituna.metrics.PairwiseConsistency(
        indeterminacy=ituna.metrics.Permutation(),
        symmetric=False,
        include_diagonal=True,
    ),
    random_states=5,
)

ensemble.fit(X)
print("Consistency score:", ensemble.score(X))
emb = ensemble.transform(X)
print("Embedding shape:", emb.shape)
print("Scores:\n", ituna.utils.sparse_to_dense(*emb.scores, shape=(5, 5)))
/home/hgf_hmgu/hgf_sfs7789/miniconda3/envs/ituna/lib/python3.10/site-packages/sklearn/decomposition/_fastica.py:127: ConvergenceWarning: FastICA did not converge. Consider increasing tolerance or the maximum number of iterations.
  warnings.warn(
/home/hgf_hmgu/hgf_sfs7789/miniconda3/envs/ituna/lib/python3.10/site-packages/sklearn/decomposition/_fastica.py:127: ConvergenceWarning: FastICA did not converge. Consider increasing tolerance or the maximum number of iterations.
  warnings.warn(
/home/hgf_hmgu/hgf_sfs7789/miniconda3/envs/ituna/lib/python3.10/site-packages/sklearn/decomposition/_fastica.py:127: ConvergenceWarning: FastICA did not converge. Consider increasing tolerance or the maximum number of iterations.
  warnings.warn(
/home/hgf_hmgu/hgf_sfs7789/miniconda3/envs/ituna/lib/python3.10/site-packages/sklearn/decomposition/_fastica.py:127: ConvergenceWarning: FastICA did not converge. Consider increasing tolerance or the maximum number of iterations.
  warnings.warn(
/home/hgf_hmgu/hgf_sfs7789/miniconda3/envs/ituna/lib/python3.10/site-packages/sklearn/decomposition/_fastica.py:127: ConvergenceWarning: FastICA did not converge. Consider increasing tolerance or the maximum number of iterations.
  warnings.warn(
Consistency score: 0.413662638435334
Embedding shape: (1000, 16)
Scores:
 [[1.         0.21720489 0.39027938 0.19145318 0.32692556]
 [0.21720489 1.         0.15710815 0.38241257 0.14474775]
 [0.39027938 0.15710815 1.         0.25456576 0.32374832]
 [0.19145318 0.38241257 0.25456576 1.         0.28233742]
 [0.32692556 0.14474775 0.32374832 0.28233742 1.        ]]