Skip to content

Commit a83bd91

Browse files
committed
Added "Recommended approach for testing train test splits" to glossary
1 parent 9bcc91c commit a83bd91

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/glossary.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,31 @@ 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+
# sct
237+
Ex().check_correct(
238+
multi(
239+
check_object("X_train").has_equal_value(),
240+
check_object("X_test").has_equal_value(),
241+
check_object("y_train").has_equal_value(),
242+
check_object("y_test").has_equal_value()
243+
),
244+
check_function("sklearn.model_selection.train_test_split").multi(
245+
check_args(["arrays", 0]).has_equal_value("Did you correctly pass in the feature variable to `train_test_split()`?"),
246+
check_args(["arrays", 1]).has_equal_value("Did you correctly pass in the target variable to `train_test_split()`?"),
247+
check_args(["options", "test_size"]).has_equal_value("Did you specify the correct train test split?"),
248+
check_args(["options", "random_state"]).has_equal_value("Don't change the `random_state` argument we set for you.")
249+
)
250+
)
251+
252+
228253
Check import
229254
~~~~~~~~~~~~
230255

0 commit comments

Comments
 (0)