Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random numbers seed not working? #37

Closed
echo66 opened this issue Jul 3, 2018 · 3 comments
Closed

random numbers seed not working? #37

echo66 opened this issue Jul 3, 2018 · 3 comments

Comments

@echo66
Copy link

echo66 commented Jul 3, 2018

Greetings!

I have the following code:

feats_gen = FEW(
                ml=DecisionTreeClassifier(random_state=10, max_depth=None, min_samples_leaf=5), 
                population_size=100, tourn_size=2,                 
                mutation_rate=0.5, crossover_rate=0.5, 
                sel='epsilon_lexicase',   
                clean=True,                
                mdr=True, boolean=True, 
                random_state=10, verbosity=1, 
                scoring_function=roc_auc_score, 
                max_depth=10, min_depth=1, max_depth_init=1, 
                classification=True, 
                generations=50, max_stall=None, 
                names=list(X_train.select_dtypes(include=[np.number]).columns))

feats_gen.fit(X_train.select_dtypes(include=[np.number]).values, 
              y_train.astype(int).values)

test_ = preprocessing_pipeline.transform(e.test)

X_test = test_.X
y_test = test_[test_.target_name].astype(int)

roc_auc_score(y_test, feats_gen._best_estimator.predict_proba(feats_gen.transform(X_test.select_dtypes(include=[np.number]).values))[:, 1])

Everytime I run this code, I get different ROC AUC values in both training and test. I'm pretty sure preprocessing_pipeline is deterministic.

@echo66
Copy link
Author

echo66 commented Jul 12, 2018

I found out what the problem is: you are using numpy.random instead of a RandomState in several lines.

@lacava
Copy link
Owner

lacava commented Jul 14, 2018

thanks for raising this issue. I am on vacation at the moment. if you have a fix, could you make the changes and send a PR? I would appreciate it!

@lacava
Copy link
Owner

lacava commented Aug 3, 2018

looks like a couple np.random calls slipped into the code, as you mentioned. see PR #38

running docs/few_example.py seems to reproduce now.

lacava added a commit that referenced this issue Aug 3, 2018
replaces np.random calls with self.random_state (issue #37 )
@lacava lacava closed this as completed Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants