11.04.2024 Views

Thinking-data-science-a-data-science-practitioners-guide

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

xiv

Contents

XGBoost . . . . . . . . . . ................................... 120

Implementation . . . . . . . . . . . . . . . . . . . ................... 121

XGBRegressor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

XGBClassifier....................................... 122

CatBoost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

Implementation . . . . . . . . . . . . . . . . . . . ................... 123

CatBoostRegressor .................................... 123

CatBoostClassifier.................................... 124

LightGBM ............................................ 125

Implementation . . . . . . . . . . . . . . . . . . . ................... 126

The LGBMRegressor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

The LGBMClassifier................................... 127

Performance Summary ................................... 128

Summary ............................................. 129

6 K-Nearest Neighbors .................................... 131

In a Nutshell ........................................... 131

K-Nearest Neighbors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

KNN Algorithm . . . . .................................... 132

KNN Working . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

Effect of K ............................................ 135

Advantages . ........................................... 135

Disadvantages of KNN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

Implementation . . . . . . . . . . . . . . . . . . . ................... 136

Project . . ............................................. 137

Loading Dataset ...................................... 137

Determining K Optimal ................................. 138

Model Training ...................................... 140

Model Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

When to Use? . . ........................................ 141

Summary ............................................. 141

7 Naive Bayes ........................................... 143

In a Nutshell ........................................... 143

When to Use? . . ........................................ 144

Naive Bayes Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

Applying the Theorem . ................................ 145

Advantages ......................................... 146

Disadvantages ....................................... 147

Improving Performance ................................. 147

Naive Bayes Types . ..................................... 148

Multinomial Naive Bayes ............................... 148

Bernoulli Naive Bayes ................................. 148

Gaussian Naive Bayes .................................. 148

Complement Naive Bayes . .............................. 149

Categorical Naive Bayes . . .............................. 149

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!