Reader small image

You're reading from  Machine Learning for Imbalanced Data

Product typeBook
Published inNov 2023
Reading LevelBeginner
PublisherPackt
ISBN-139781801070836
Edition1st Edition
Languages
Concepts
Right arrow
Authors (2):
Kumar Abhishek
Kumar Abhishek
author image
Kumar Abhishek

Kumar Abhishek is a seasoned Senior Machine Learning Engineer at Expedia Group, US, specializing in risk analysis and fraud detection for Expedia brands. With over a decade of experience at companies such as Microsoft, Amazon, and a Bay Area startup, Kumar holds an MS in Computer Science from the University of Florida.
Read more about Kumar Abhishek

Dr. Mounir Abdelaziz
Dr. Mounir Abdelaziz
author image
Dr. Mounir Abdelaziz

Dr. Mounir Abdelaziz is a deep learning researcher specializing in computer vision applications. He holds a Ph.D. in computer science and technology from Central South University, China. During his Ph.D. journey, he developed innovative algorithms to address practical computer vision challenges. He has also authored numerous research articles in the field of few-shot learning for image classification.
Read more about Dr. Mounir Abdelaziz

View More author details
Right arrow

Cost-Sensitive Learning using scikit-learn and XGBoost models

scikit-learn provides a class_weight hyperparameter to adjust the weights of various classes for most models. This parameter can be specified in various ways for different learning algorithms in scikit-learn. However, the main idea is that this parameter specifies the weights to use for each class in the loss calculation formula. For example, this parameter specifies the values of weight FP and weight FN mentioned previously for logistic regression.

Similar to the LogisticRegression function, for DecisionTreeClassifier, we could use DecisionTreeClassifier(class_weight='balanced') or DecisionTreeClassifier(class_weight={0: 0.5, 1: 0.5}).

Regarding SVM, it can even be extended to multi-class classification by specifying a weight value for each class label:

svm.SVC(class_weight= {-1: 1.0, 0: 1.0, 1: 1.0})

The general guidance about coming up with the class_weight values is to use the inverse of...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Machine Learning for Imbalanced Data
Published in: Nov 2023Publisher: PacktISBN-13: 9781801070836

Authors (2)

author image
Kumar Abhishek

Kumar Abhishek is a seasoned Senior Machine Learning Engineer at Expedia Group, US, specializing in risk analysis and fraud detection for Expedia brands. With over a decade of experience at companies such as Microsoft, Amazon, and a Bay Area startup, Kumar holds an MS in Computer Science from the University of Florida.
Read more about Kumar Abhishek

author image
Dr. Mounir Abdelaziz

Dr. Mounir Abdelaziz is a deep learning researcher specializing in computer vision applications. He holds a Ph.D. in computer science and technology from Central South University, China. During his Ph.D. journey, he developed innovative algorithms to address practical computer vision challenges. He has also authored numerous research articles in the field of few-shot learning for image classification.
Read more about Dr. Mounir Abdelaziz