Skip to content

Commit 9f81d75

Browse files
committedJun 20, 2019
Added "Recommended approach for testing train test splits" to glossary
1 parent 9bcc91c commit 9f81d75

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
 

‎docs/glossary.rst

+26
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,32 @@ Check Multiple Choice
225225
"That's a clown who likes burgers.",
226226
"Correct! Head over to the next exercise!"])
227227
228+
Recommended approach for testing train test splits
229+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
230+
231+
.. code::
232+
233+
# solution
234+
# Perform the train-test split
235+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
236+
237+
# sct
238+
Ex().check_correct(
239+
multi(
240+
check_object("X_train").has_equal_value(),
241+
check_object("X_test").has_equal_value(),
242+
check_object("y_train").has_equal_value(),
243+
check_object("y_test").has_equal_value()
244+
),
245+
check_function("sklearn.model_selection.train_test_split").multi(
246+
check_args(["arrays", 0]).has_equal_value("Did you correctly pass in the feature variable to `train_test_split()`?"),
247+
check_args(["arrays", 1]).has_equal_value("Did you correctly pass in the target variable to `train_test_split()`?"),
248+
check_args(["options", "test_size"]).has_equal_value("Did you specify the correct train test split?"),
249+
check_args(["options", "random_state"]).has_equal_value("Don't change the `random_state` argument we set for you.")
250+
)
251+
)
252+
253+
228254
Check import
229255
~~~~~~~~~~~~
230256

0 commit comments

Comments
 (0)
Please sign in to comment.