<jupyter_start><jupyter_text>Table of Contents1&nbsp;&nbsp;Using scikit-COSMO selectors with scikit-learn pipelines1.1&nbsp;&nbsp;Simple integration of scikit-COSMO selectors1.2&nbsp;&nbsp;Stacking selectors one after another Using scikit-COSMO selectors with scikit-learn pipelines========================================================<jupyter_code>import numpy as np
from matplotlib import pyplot as plt

from sklearn.pipeline import Pipeline
from sklearn.linear_model import RidgeCV
from sklearn.datasets import load_diabetes
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler

from skcosmo.feature_selection import FPS, CUR<jupyter_output><empty_output><jupyter_text>Simple integration of scikit-COSMO selectorsThis example shows how to use FPS to subselect features before training a RidgeCV.<jupyter_code>scaler = StandardScaler()
selector = FPS(n_to_select=4)
ridge = RidgeCV(cv=2, alphas=np.logspace(-8, 2, 10))

X, y = load_diabetes(return_X_y=True)

X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

pipe = Pipeline([("scaler", scaler), ("selector", selector), ("ridge", ridge)])
pipe.fit(X_train.copy(), y_train.copy())

plt.scatter(y_test, pipe.predict(X_test))
plt.gca().set_aspect("equal")
plt.plot(plt.xlim(), plt.xlim(), "r--")
plt.xlabel('True Values')
plt.ylabel('Predicted Values')
plt.show()<jupyter_output><empty_output><jupyter_text>Stacking selectors one after anotherThis example shows how to use an FPS, then CUR selectorto subselect features before training a RidgeCV.<jupyter_code>scaler = StandardScaler()
fps = FPS(n_to_select=8)
cur = CUR(n_to_select=4)
ridge = RidgeCV(cv=2, alphas=np.logspace(-8, 2, 10))

X, y = load_diabetes(return_X_y=True)

X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

pipe = Pipeline(
    [("scaler", scaler), ("selector1", fps), ("selector2", cur), ("ridge", ridge)]
)
pipe.fit(X_train.copy(), y_train.copy())

plt.scatter(y_test, pipe.predict(X_test))
plt.gca().set_aspect("equal")
plt.plot(plt.xlim(), plt.xlim(), "r--")
plt.xlabel('True Values')
plt.ylabel('Predicted Values')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1548327989005955, 'fraction_numerical': 0.010077874484654145, 'mean_word_length': 7.666666666666667, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '79283', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 809, 'n_tokens_neox': 777, 'n_words': 174, 'path': 'examples/Selectors-Pipelines.ipynb', 'repo_name': 'lab-cosmo/scikit-cosmo', 'size': '2183'}