Random_state acceptable value

Course Name: Machine Learning for Options Trading, Section No: 5, Unit No: 6, Unit type: Exercise

clf = DecisionTreeClassifier(max_depth=5, min_samples_leaf=5, random_state=16)

If I change 16 to 42(system suggested) it accepts. random_state should accept any integer value, right? Why is it expecting only "42"?

Hi Srinivasa,



You are right. It should not matter that the random state value is 16 or 42, the strategy would run without any issues.

However, the idea of the interactive exercise is to get the learner to understand and recall important parts of the strategy code. Usually, we test the learner on the same line of code which was present in the notebook itself. And since the interactive exercise is checked in an automated fashion, it requires you to input the random_state value as 42 (system suggested) only.



Another point is that while you can input any number, the results might be slightly different from the ones shown in the strategy notebook. To make sure there is no confusion, the same parameter values are expected in the interactive exercises. Nevertheless, thank you for pointing it out and this unit will be checked for further improvement as well.



Hope this helps.