You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Common tests: Check that random_state is not altered #1108
Not sure this is what we want, but I think it is: fit should not change the random_state so that fitting twice on the same data set should produce the same result.
There was a comment by @ogrisel in #455 along these lines, I think.
and use that one instead in fit. That would also require pass random_state=0 (fixed seed) in the constructors of all the randomized estimators. Some people might not like it...
Why do you want to make random_state_ an attribute? It only needs to be local to fit. If you need another random state somewhere else, why not generate it again from the self.random_state?
Why do you want to make random_state_ an attribute? It only needs to be
local to fit. If you need another random state somewhere else, why not
generate it again from the self.random_state?
GMMs and HMMs can use it to sample observations from the model. People
expect that sampling twice will give them different observations.
I agree with @ogrisel on the hmm issue.
About self.random_state_: I don't like this duplication of attributes for the sake of not changing the model.
I think it becomes pretty confusing to distinguish the two. I know we use this in some places and it can not always be avoided, but I think we should try.
If you want idem potent fit calls you need to remember the original seed somewhere. But this is actually not the random_state itself that should be stored, but an integer seed. I think we should write a use case for the API caller point of view before moving on with this discussion.
To avoid confusion, we may rename random_state to seed in the constructors and then set random_state = check_random_state(self.seed) (or self.random_state_ = ... if it needs to be stored) in `fit? Too bad this would break the current API though... :(
Activity
ogrisel commentedon Sep 3, 2012
+1 but this will have a very wide impact.
amueller commentedon Sep 3, 2012
Yeah, this is gonna be real fun ^^
ogrisel commentedon Sep 3, 2012
We should probably change the current fit idiom:
to:
and use that one instead in fit. That would also require pass
random_state=0(fixed seed) in the constructors of all the randomized estimators. Some people might not like it...amueller commentedon Sep 3, 2012
Why do you want to make
random_state_an attribute? It only needs to be local tofit. If you need another random state somewhere else, why not generate it again from theself.random_state?I'm -1 on fixing seeds by default.
GaelVaroquaux commentedon Sep 3, 2012
+1
GaelVaroquaux commentedon Sep 3, 2012
GMMs and HMMs can use it to sample observations from the model. People
expect that sampling twice will give them different observations.
ogrisel commentedon Sep 3, 2012
Indeed, this is not a requirement.
I don't think so. The sampling method should have it's own
random_statekwargs to make that controllable.amueller commentedon Sep 3, 2012
I agree with @ogrisel on the hmm issue.
About
self.random_state_: I don't like this duplication of attributes for the sake of not changing the model.I think it becomes pretty confusing to distinguish the two. I know we use this in some places and it can not always be avoided, but I think we should try.
ogrisel commentedon Sep 3, 2012
If you want idem potent fit calls you need to remember the original seed somewhere. But this is actually not the random_state itself that should be stored, but an integer seed. I think we should write a use case for the API caller point of view before moving on with this discussion.
amueller commentedon Sep 3, 2012
agreed :)
glouppe commentedon Sep 4, 2012
To avoid confusion, we may rename
random_statetoseedin the constructors and then setrandom_state = check_random_state(self.seed)(orself.random_state_ = ...if it needs to be stored) in `fit? Too bad this would break the current API though... :(mblondel commentedon Oct 15, 2012
+1 for not overwriting
self.random_statePR #1200 had this problem too.
amueller commentedon Feb 13, 2013
Closed by #1518 and #1670.
DOC developer guidelines for unit tests and classes_