:robot::zap: 50 scikit-learn tips
# 🤖⚡ scikit-learn tips

New tips are posted on [LinkedIn](https://www.linkedin.com/in/justmarkham/), [Twitter](https://twitter.com/justmarkham), and [Facebook](https://www.facebook.com/DataScienceSchool/).

👉 [Sign up to receive 2 video tips by email every week!](https://scikit-learn.tips) 👈

## List of all tips

Click <img src="icons/in.svg" width="20px" align="top"> to discuss the tip on **LinkedIn**, click <img src="icons/nb.svg" width="20px" align="top"> to view the **Jupyter notebook** for a tip, or click <img src="icons/yt.svg" width="20px" align="top"> to watch the tip video on **YouTube:**

\# | Description | Links
--- | --- | ---
1 | Use `ColumnTransformer` to apply different preprocessing to different columns | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6645311881470885889-F-dm/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/01_column_transformer.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=NGq8wnH5VSo&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=1"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
2 | Seven ways to select columns using `ColumnTransformer` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6645666737507352576-J3fh/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/02_select_columns.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=sCt4LVD5hPc&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=2"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
3 | What is the difference between "fit" and "transform"? | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6646039996639825920-DwUd/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://www.youtube.com/watch?v=g2XsZdwbCCs&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=3"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
4 | Use "fit_transform" on training data, but "transform" (only) on testing/new data | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6646386464672272385-hGk2/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://www.youtube.com/watch?v=6as06vtXNL8&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=4"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
5 | Four reasons to use scikit-learn (not pandas) for ML preprocessing | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6646739773820059648-CfMc/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://www.youtube.com/watch?v=yv4adDGcFE8&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=5"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
6 | Encode categorical features using `OneHotEncoder` or `OrdinalEncoder` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6647897085251239936-w587/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/06_encode_categorical_features.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=0w78CHM_ubM&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=6"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
7 | Handle unknown categories with `OneHotEncoder` by encoding them as zeros | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6648203250950553600-IpGr/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/07_handle_unknown_categories.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=bA6mYC1a_Eg&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=7"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
8 | Use `Pipeline` to chain together multiple steps | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6648570918979325952-vrWw/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/08_pipeline.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=1Y6O9nCo0-I&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=8"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
9 | Add a missing indicator to encode "missingness" as a feature | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6648932419095322624-hH5F/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/09_add_missing_indicator.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=DKmDJJzayZw&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=9"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
10 | Set a "random_state" to make your code reproducible | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6649289189365989376-8QbM/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/10_random_state.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=WAdrXVnOTIM&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=10"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
11 | Impute missing values using `KNNImputer` or `IterativeImputer` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6650374643419090944-GHyR/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/11_new_imputers.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=m_qKhnaYZlc&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=11"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
12 | What is the difference between `Pipeline` and `make_pipeline`? | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6650753557052088320-cEJB/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/12_pipeline_vs_make_pipeline.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=lkFwwquv_ss&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=12"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
13 | Examine the intermediate steps in a `Pipeline` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6651109694704279553-K-xY/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/13_examine_pipeline_steps.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=UrV8PLm2Ynk&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=13"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
14 | `HistGradientBoostingClassifier` natively supports missing values | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6651478075181711360-oyoW/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/14_handle_missing_values.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=jbc6BPQEM3o&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=14"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
15 | Three reasons not to use drop='first' with `OneHotEncoder` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6651812212270788609-lhE1/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://www.youtube.com/watch?v=NYtwyvyvDEk&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=15"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
16 | Use `cross_val_score` and `GridSearchCV` on a `Pipeline` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6652964623681142786-x34T/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/16_pipeline_cross_validation.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=f_xB7kbZR_g&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=16"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
17 | Try `RandomizedSearchCV` if `GridSearchCV` is taking too long | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6653289531778887680-5YA1/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/17_randomized_search.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=Q5dH5mOQ_ik&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=17"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
18 | Display `GridSearchCV` or `RandomizedSearchCV` results in a DataFrame | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-pandas-machinelearning-activity-6653654769267208192-h5qv/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/18_hyperparameter_search_results.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=ct7W4Zs63VE&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=18"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
19 | Important tuning parameters for `LogisticRegression` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6654000730321534976-Um6C/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://www.youtube.com/watch?v=3LQbbvt5Ass&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=19"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
20 | Plot a confusion matrix | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6654398086783213568-fb8p/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/20_plot_confusion_matrix.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=QRFMgKdF-Ug&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=20"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
21 | Compare multiple ROC curves in a single plot | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6655489426082316288-yVzb/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/21_plot_roc_curve.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=Vc-qn5VcJmw&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=21"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
22 | Use the correct methods for each type of `Pipeline` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6655822391479980033-KUqD/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://www.youtube.com/watch?v=46ZiVrYeSTg&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=22"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
23 | Display the intercept and coefficients for a linear model | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6656171291986456576-4vSf/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/23_linear_model_coefficients.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=JmYR283vCdw&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=23"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
24 | Visualize a decision tree two different ways | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6656534743049392128-J7-r/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/24_decision_tree_visualization.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=EMcNjJ6Gj8w&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=24"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
25 | Prune a decision tree to avoid overfitting | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6656901820478210048-h2IN/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/25_decision_tree_pruning.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=ioQ2Ahi-I_M&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=25"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
26 | Use stratified sampling with `train_test_split` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6658009817619185665-hICv/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/26_stratified_train_test_split.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=Zcjl8xPLmPw&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=26"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
27 | Two ways to impute missing values for a categorical feature | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6658368383425347588-tiW-/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/27_impute_categorical_features.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=k3KrhjvaCq0&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=27"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
28 | Save a model or `Pipeline` using joblib | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6660528924725964800-U7I3/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/28_joblib.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=L5OVCoAemAk&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=28"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
29 | Vectorize two text columns in a `ColumnTransformer` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6661254380647440384-4maW/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/29_vectorize_two_columns.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=HyP5MvlmbRc&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=29"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
30 | Four ways to examine the steps of a `Pipeline` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6661979233897771009-sE0Q/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/30_examine_pipeline_steps.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=IhUID_sD3hE&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=30"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
31 | Shuffle your dataset when using `cross_val_score` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6663830752553250816-7Wf0/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/31_kfold_shuffle.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=Ld8-_WP0G90&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=31"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
32 | Use AUC to evaluate multiclass problems | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6665599921917353984-9Xda/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/32_multiclass_auc.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=-s-KdkYmCaA&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=32"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
33 | Use `FunctionTransformer` to convert functions into transformers | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6666323912193822721-Xzg3/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/33_function_transformer.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=s1gL82BxKos&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=33"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
34 | Add feature selection to a `Pipeline` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6666768001813110784-zX-i/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/34_feature_selection.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=BMBVwV8iarc&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=34"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
35 | Don't use `.values` when passing a pandas object to scikit-learn | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6667045088918597632-jUK2/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/35_pass_pandas_object.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=f3HIw8o21Ao&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=35"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
36 | Most parameters should be passed as keyword arguments | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6670749637198123008-7Syk/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/36_keyword_arguments.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=oIcS_pvNtpo&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=36"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
37 | Create an interactive diagram of a `Pipeline` in Jupyter | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6671044463227490304-bT0u/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/37_pipeline_diagram.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=_UKYxucD1Io&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=37"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
38 | Get the feature names output by a `ColumnTransformer` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6671411158060277760-Bg82/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/38_get_feature_names.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=NxLfpcfGzns&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=38"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
39 | Load a toy dataset into a DataFrame | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6671768842949283840-JkTU/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/39_toy_dataset.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=aMLLY9T3HPQ&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=39"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
40 | Estimators only print parameters that have been changed | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6672157401648631808-g85G/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/40_print_changed_only.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=9MW6Vpzbock&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=40"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
41 | Drop the first category from binary features (only) with `OneHotEncoder` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6675807352677117952-hhss/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/41_drop_if_binary.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=6EtfLjKhIec&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=41"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
42 | Passthrough some columns and drop others in a `ColumnTransformer` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6676145879545712640-BQAU/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/42_passthrough_or_drop.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=vHGRXuOtFnE&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=42"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
43 | Use `OrdinalEncoder` instead of `OneHotEncoder` with tree-based models | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6704054381291163648-pL-P/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/43_ordinal_encoding_for_trees.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=n_x40CdPZss&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=43"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
44 | Speed up `GridSearchCV` using parallel processing | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6704396461938933760-EdTH/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/44_parallel_processing.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=QqFGKVieywY&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=44"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
45 | Create feature interactions using `PolynomialFeatures` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6704770161905401856-iG8X/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/45_feature_interactions.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=unP3rCfzROk&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=45"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
46 | Ensemble multiple models using `VotingClassifer` or `VotingRegressor` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6706193770704175104-4W7e/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/46_ensembling.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=2lq2k6J3GW4&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=46"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
47 | Tune the parameters of a `VotingClassifer` or `VotingRegressor` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6706562127303442433-XSiW/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/47_ensemble_tuning.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=fvY3InlnOh8&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=47"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
48 | Access part of a `Pipeline` using slicing | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6706912855742140416-cDYz/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/48_pipeline_slicing.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=sMlsd2CnIf4&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=48"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
49 | Tune multiple models simultaneously with `GridSearchCV` | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6707287625881022465-UUwO/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/49_tune_multiple_models.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=v2QpvCJ1ar8&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=49"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>
50 | Adapt this pattern to solve many Machine Learning problems | <a href="https://www.linkedin.com/posts/justmarkham_sklearntips-machinelearning-python-activity-6707651810888421377-pTs8/"><img src="icons/in.svg" width="20px" align="top" title="Discuss"></a> <a href="https://nbviewer.jupyter.org/github/justmarkham/scikit-learn-tips/blob/master/notebooks/50_simple_ml_pattern.ipynb"><img src="icons/nb.svg" width="20px" align="top" title="View code"></a> <a href="https://www.youtube.com/watch?v=gd-TZut-oto&list=PL5-da3qGB5ID7YYAqireYEew2mWVvgmj6&index=50"><img src="icons/yt.svg" width="20px" align="top" title="Watch video"></a>

You can interact with all of these notebooks online using **Binder:** <a href="https://mybinder.org/v2/gh/justmarkham/scikit-learn-tips/master?filepath=notebooks%2F"><img src="icons/binder.svg" align="top"></a>

**Note:** Some of the tips do not include any code, and can only be viewed on LinkedIn.

## Who creates these tips?

Hi! I'm Kevin Markham, the founder of [Data School](https://www.dataschool.io). I've been teaching data science in Python since 2014. I create these tips because I love using scikit-learn and I want to help others use it more effectively.

## How can I get better at scikit-learn?

I teach three courses:

- **Course 1:** [Introduction to Machine Learning in Python with scikit-learn](https://courses.dataschool.io/introduction-to-machine-learning-with-scikit-learn) (4 hours, free)
- **Course 2:** [Building an Effective Machine Learning Workflow with scikit-learn](https://courses.dataschool.io/building-an-effective-machine-learning-workflow-with-scikit-learn) (8 hours, paid)
- **Course 3:** [Machine Learning with Text in Python](https://www.dataschool.io/learn/) (14 hours, paid)

👉 [Find out which course is right for you!](https://www.dataschool.io/ml-courses/) 👈

## Do you have any other tips?

Yes! In 2019, I posted [100 pandas tricks](https://www.dataschool.io/python-pandas-tips-and-tricks/). I also created a video featuring my [top 25 pandas tricks](https://www.dataschool.io/python-pandas-tricks/).

*© 2020-2021 [Data School](https://www.dataschool.io). All rights reserved.*
