Skip to content

Instantly share code, notes, and snippets.

@letthedataconfess
Created December 18, 2021 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save letthedataconfess/2ff8a07a444eee8677a0af55a584da7a to your computer and use it in GitHub Desktop.
Save letthedataconfess/2ff8a07a444eee8677a0af55a584da7a to your computer and use it in GitHub Desktop.
from sklearn import linear_model
from sklearn.ensemble import RandomForestRegressor
from genetic_selection import GeneticSelectionCV
estimator = linear_model.LinearRegression()
selector = GeneticSelectionCV(estimator,cv=5,
verbose=1,
scoring="r2",
max_features=10,
n_population=50,
crossover_proba=0.5,
mutation_proba=0.2,
n_generations=40,
crossover_independent_proba=0.5,
mutation_independent_proba=0.05,
tournament_size=3,
n_gen_no_change=10,
caching=True,
n_jobs=-1)
selector = selector.fit(x_train, y_train)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment