.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_FOCISelector_progression.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_FOCISelector_progression.py: ============================= FOCISelector: T_n progression ============================= This example fits the FOCISelector on synthetic data and plots the cumulative T_n values along the selection path. .. GENERATED FROM PYTHON SOURCE LINES 9-48 .. image-sg:: /auto_examples/images/sphx_glr_plot_FOCISelector_progression_001.png :alt: FOCISelector: cumulative T_n over selection steps :srcset: /auto_examples/images/sphx_glr_plot_FOCISelector_progression_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from pyFOCI import FOCISelector random_state = np.random.RandomState(0) n, p = 1000, 30 X = random_state.normal(size=(n, p)) # Additive signal across multiple features # -> incremental improvements with each addition y = ( np.sin(2.0 * X[:, 0]) + X[:, 1] + (X[:, 2] ** 2 - 1.0) + np.tanh(X[:, 3]) + (X[:, 4] > 0).astype(float) + 0.1 * random_state.normal(size=n) # small noise ) selector = FOCISelector(max_features=6, random_state=0) selector.fit(X, y) feat_idx = list(selector.selected_indices_) Tn_vals = list(selector.Tn_path_) # Labels: directly prepend "x" to the indices labels = [f"step {i+1}: x{j}" for i, j in enumerate(feat_idx)] m = len(Tn_vals) plt.figure(figsize=(8, 4)) plt.bar(range(m), Tn_vals, color="tab:orange", edgecolor="black", linewidth=0.5) plt.title("FOCISelector: cumulative T_n over selection steps") plt.ylabel("T_n(S_k)") plt.xlabel("Selection steps") plt.xticks(ticks=range(m), labels=labels, rotation=45, ha="right", fontsize=9) plt.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.775 seconds) .. _sphx_glr_download_auto_examples_plot_FOCISelector_progression.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_FOCISelector_progression.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_FOCISelector_progression.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_FOCISelector_progression.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_