{"id":4831,"date":"2020-02-15T11:57:39","date_gmt":"2020-02-15T11:57:39","guid":{"rendered":"https:\/\/prwatech.in\/blog\/?p=4831"},"modified":"2024-03-15T11:43:38","modified_gmt":"2024-03-15T11:43:38","slug":"boosting-techniques-in-machine-learning","status":"publish","type":"post","link":"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/","title":{"rendered":"Boosting Techniques in Machine Learning"},"content":{"rendered":"<h1>Boosting Techniques in Machine Learning<\/h1>\n<p><strong>Boosting Techniques in Machine Learning<\/strong>, in this Tutorial one can learn the Boosting algorithm introduction. Are you the one who is looking for the best platform which provides information about different types of boosting algorithm? Or the one who is looking forward to taking the advanced <a href=\"https:\/\/prwatech.in\/data-science-certification-course-in-bangalore\/\" target=\"_blank\" rel=\"noopener noreferrer\">Data Science Certification Course<\/a> from India\u2019s Leading <a href=\"https:\/\/prwatech.in\/data-science-training-institutes-in-bangalore\/\" target=\"_blank\" rel=\"noopener noreferrer\">Data Science Training institute<\/a>? Then you\u2019ve landed on the Right Path.<\/p>\n<p>Machine learning is vital for many of the technologies that seek to provide intelligence to the data, and companies recognize the great value. Boosting is a meta-algorithm joint learning machine to mainly reduce bias, and also variation in supervised learning, and a family of machine learning algorithms that convert students&#8217; weaknesses to strengths.<\/p>\n<p>The Below mentioned Tutorial will help to Understand the detailed information about boosting techniques in machine learning, so Just follow all the tutorials of India\u2019s Leading <a href=\"https:\/\/prwatech.in\/data-science-training-institutes-in-bangalore\/\" target=\"_blank\" rel=\"noopener noreferrer\">Best Data Science Training institute in Bangalore<\/a> and Be a Pro <a href=\"https:\/\/prwatech.in\/data-science-training-institutes-in-bangalore\/\" target=\"_blank\" rel=\"noopener noreferrer\">Data Scientist<\/a> or Machine Learning Engineer.<\/p>\n<h3>Boosting Algorithm Introduction<\/h3>\n<p>As seen in the introduction part of ensemble methods, boosting is one of the advanced ensemble methods which improve overall performance by decreasing bias. Boosting is a consecutive process, where each succeeding model attempts to correct the errors of the preceding model.<\/p>\n<h2>Different Types of Boosting Algorithm<\/h2>\n<p>There are mainly five types of boosting techniques.<\/p>\n<p>AdaBoost<\/p>\n<p>Gradient Boosting (GBM)<\/p>\n<p>Light GBM<\/p>\n<p>XGBoost<\/p>\n<p>CatBoost<\/p>\n<p>Let\u2019s see more about these types.<\/p>\n<h3>AdaBoost Algorithm in Machine Learning<\/h3>\n<p><strong>Understanding AdaBoost Algorithm<\/strong><\/p>\n<p>AdaBoost, considered one of the simplest boosting algorithms, commonly utilizes decision trees for modeling. It follows a sequential approach, wherein multiple models are created successively. Each subsequent model aims to rectify the errors made by its predecessor.<\/p>\n<p>This correction process involves assigning higher weights to observations that were incorrectly predicted by the previous model. Consequently, in the subsequent iteration, the algorithm prioritizes the accurate prediction of these misclassified instances. This iterative refinement of models ensures progressive improvement in overall prediction accuracy.<\/p>\n<p>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-4832\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2020\/02\/boosting1.png\" alt=\"Boosting Techniques in Machine Learning\" width=\"850\" height=\"279\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2020\/02\/boosting1.png 320w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2020\/02\/boosting1-300x98.png 300w\" sizes=\"auto, (max-width: 850px) 100vw, 850px\" \/><\/p>\n<p>where<\/p>\n<p>f<sub>m\u00a0<\/sub>= m<sup>th<\/sup> weak classifier<\/p>\n<p><sub>m<\/sub>= corresponding weight.<\/p>\n<p><strong>Understanding AdaBoost Algorithm<\/strong><\/p>\n<p>AdaBoost, short for Adaptive Boosting, is precisely the weighted combination of multiple weak classifiers. The algorithm operates through the following steps:<\/p>\n<ol>\n<li><strong>Equal Weight Initialization:<\/strong> Initially, all data points in the dataset are assigned equal weights.<\/li>\n<li><strong>Model Building:<\/strong> A subset of the data is utilized to build a weak model.<\/li>\n<li><strong>Prediction:<\/strong> Predictions are made for the entire dataset based on this model.<\/li>\n<li><strong>Error Measurement:<\/strong> Errors are evaluated by comparing the predictions with the actual values.<\/li>\n<li><strong>Weight Adjustment:<\/strong> Data points that are incorrectly predicted are assigned higher weights in the creation of the next model.<\/li>\n<li><strong>Weight Calculation:<\/strong> The weights for data points are determined based on the magnitude of errors. Higher errors correspond to higher weights for the respective data points.<\/li>\n<li><strong>Iterative Process:<\/strong> This process is repeated until either the error function stabilizes or the maximum limit of estimators is reached.<\/li>\n<\/ol>\n<p>Let&#8217;s illustrate this process with an example of employee attrition.<\/p>\n<h4>Initializing and importing libraries<\/h4>\n<p>Import pandas as pd<\/p>\n<p>Import numpy as np<\/p>\n<h4>Reading File<\/h4>\n<p>df=pd.read_csv(<em>&#8220;Your File Path&#8221;<\/em>)<\/p>\n<p>df.head()<\/p>\n<h4>Splitting dataset into train and test<\/h4>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>train, test = train_test_split(df, test_size=0.3, random_state=0)<\/p>\n<p>x_train=train.drop(&#8216;status&#8217;,axis=1)<\/p>\n<p>y_train=train[&#8216;status&#8217;]<\/p>\n<p>x_test=test.drop(&#8216;status&#8217;,axis=1)<\/p>\n<p>y_test=test[&#8216;status&#8217;]<\/p>\n<h4>Applying AdaBoost:<\/h4>\n<p>from sklearn.ensemble import AdaBoostClassifier<\/p>\n<p>model = AdaBoostClassifier(random_state=1)<\/p>\n<p>model.fit(x_train, y_train)<\/p>\n<p>model.score(x_test,y_test)<\/p>\n<h4><strong>Output:<\/strong><\/h4>\n<p>0.9995555555555555<\/p>\n<p>Note: In the case of regression, the steps will be the same. Just we have to replace AdaBoostClassifier with AdaBoostRegressor.<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<h3>Gradient Boosting (GBM) in Machine Learning:<\/h3>\n<p>Gradient Boosting, or GBM, represents an ensemble machine learning algorithm applicable to both regression and classification problems. GBM combines numerous weak learners to construct a robust algorithm. Similar to other boosting methods, each subsequent tree in GBM is built based on the error calculation from the preceding trees. In GBM, regression trees serve as the base learner.<\/p>\n<table width=\"384\">\n<tbody>\n<tr>\n<td width=\"64\"><strong>Gender<\/strong><\/td>\n<td width=\"64\"><strong>Height<\/strong><\/td>\n<td width=\"64\"><strong>Weight<\/strong><\/td>\n<td width=\"64\"><strong>BMI<\/strong><\/td>\n<td width=\"64\"><strong>Physical Activity<\/strong><\/td>\n<td width=\"64\"><strong>Age<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>M<\/strong><\/td>\n<td width=\"64\">160<\/td>\n<td width=\"64\">85<\/td>\n<td width=\"64\">33.20<\/td>\n<td width=\"64\">1<\/td>\n<td width=\"64\">35<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">155<\/td>\n<td width=\"64\">64<\/td>\n<td width=\"64\">26.64<\/td>\n<td width=\"64\">0<\/td>\n<td width=\"64\">27<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>M<\/strong><\/td>\n<td width=\"64\">170.7<\/td>\n<td width=\"64\">95<\/td>\n<td width=\"64\">28.14<\/td>\n<td width=\"64\">0<\/td>\n<td width=\"64\">28<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">185.4<\/td>\n<td width=\"64\">65<\/td>\n<td width=\"64\">23.27<\/td>\n<td width=\"64\">1<\/td>\n<td width=\"64\">28<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">158<\/td>\n<td width=\"64\">70<\/td>\n<td width=\"64\">36.05<\/td>\n<td width=\"64\">1<\/td>\n<td width=\"64\">32<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">155<\/td>\n<td width=\"64\">90<\/td>\n<td width=\"64\">35.38<\/td>\n<td width=\"64\">0<\/td>\n<td width=\"64\">28<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>M<\/strong><\/td>\n<td width=\"64\">173.7<\/td>\n<td width=\"64\">72<\/td>\n<td width=\"64\">23.86<\/td>\n<td width=\"64\">1<\/td>\n<td width=\"64\">22<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">161.5<\/td>\n<td width=\"64\">74<\/td>\n<td width=\"64\">23.77<\/td>\n<td width=\"64\">0<\/td>\n<td width=\"64\">33<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The mean age is supposed to be the predicted value (which is indicated by\u2018Predicition1\u2019) for all observations in the dataset. The difference between mean age and actual values of age is considered as errors, which is indicated by \u2018 Error 1\u2019.<\/p>\n<h4>Prediction 1:<\/h4>\n<table width=\"512\">\n<tbody>\n<tr>\n<td width=\"64\"><strong>Gender<\/strong><\/td>\n<td width=\"64\"><strong>Height<\/strong><\/td>\n<td width=\"64\"><strong>Weight<\/strong><\/td>\n<td width=\"64\"><strong>BMI<\/strong><\/td>\n<td width=\"64\"><strong>Physical Activity<\/strong><\/td>\n<td width=\"64\"><strong>Age<\/strong><\/td>\n<td width=\"64\"><strong>Mean Age<\/strong><\/td>\n<td width=\"64\"><strong>Error<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>M<\/strong><\/td>\n<td width=\"64\">160<\/td>\n<td width=\"64\">85<\/td>\n<td width=\"64\">33.20<\/td>\n<td width=\"64\">1<\/td>\n<td width=\"64\">35<\/td>\n<td width=\"64\">29<\/td>\n<td width=\"64\">6<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">155<\/td>\n<td width=\"64\">64<\/td>\n<td width=\"64\">26.64<\/td>\n<td width=\"64\">0<\/td>\n<td width=\"64\">27<\/td>\n<td width=\"64\">29<\/td>\n<td width=\"64\">-2<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>M<\/strong><\/td>\n<td width=\"64\">170.7<\/td>\n<td width=\"64\">95<\/td>\n<td width=\"64\">28.14<\/td>\n<td width=\"64\">0<\/td>\n<td width=\"64\">28<\/td>\n<td width=\"64\">29<\/td>\n<td width=\"64\">-1<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">185.4<\/td>\n<td width=\"64\">65<\/td>\n<td width=\"64\">23.27<\/td>\n<td width=\"64\">1<\/td>\n<td width=\"64\">28<\/td>\n<td width=\"64\">29<\/td>\n<td width=\"64\">-1<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">158<\/td>\n<td width=\"64\">70<\/td>\n<td width=\"64\">36.05<\/td>\n<td width=\"64\">1<\/td>\n<td width=\"64\">32<\/td>\n<td width=\"64\">29<\/td>\n<td width=\"64\">3<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">155<\/td>\n<td width=\"64\">90<\/td>\n<td width=\"64\">35.38<\/td>\n<td width=\"64\">0<\/td>\n<td width=\"64\">28<\/td>\n<td width=\"64\">29<\/td>\n<td width=\"64\">-1<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>M<\/strong><\/td>\n<td width=\"64\">173.7<\/td>\n<td width=\"64\">72<\/td>\n<td width=\"64\">23.86<\/td>\n<td width=\"64\">1<\/td>\n<td width=\"64\">22<\/td>\n<td width=\"64\">29<\/td>\n<td width=\"64\">-7<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">161.5<\/td>\n<td width=\"64\">74<\/td>\n<td width=\"64\">23.77<\/td>\n<td width=\"64\">0<\/td>\n<td width=\"64\">33<\/td>\n<td width=\"64\">29<\/td>\n<td width=\"64\">4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Using Error 1 calculation, a tree model is designed. The purpose is to reduce that error to 0.<\/p>\n<h4>Prediction 2:<\/h4>\n<table width=\"523\">\n<tbody>\n<tr>\n<td width=\"64\"><strong>Gender<\/strong><\/td>\n<td width=\"64\"><strong>Physical Activity<\/strong><\/td>\n<td width=\"64\"><strong>Age<\/strong><\/td>\n<td width=\"117\"><b>Mean Age(prediction 1)<\/b><\/td>\n<td width=\"53\"><strong>Error1<\/strong><\/td>\n<td width=\"77\"><strong>Prediction 2<\/strong><\/td>\n<td width=\"84\"><b>Mean + prediction 2\u00a0<\/b><\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>M<\/strong><\/td>\n<td width=\"64\">1<\/td>\n<td width=\"64\">35<\/td>\n<td width=\"117\">29<\/td>\n<td width=\"53\">6<\/td>\n<td width=\"77\">4<\/td>\n<td width=\"84\">33<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">0<\/td>\n<td width=\"64\">27<\/td>\n<td width=\"117\">29<\/td>\n<td width=\"53\">-2<\/td>\n<td width=\"77\">-1<\/td>\n<td width=\"84\">28<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>M<\/strong><\/td>\n<td width=\"64\">0<\/td>\n<td width=\"64\">28<\/td>\n<td width=\"117\">29<\/td>\n<td width=\"53\">-1<\/td>\n<td width=\"77\">-1<\/td>\n<td width=\"84\">29<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">1<\/td>\n<td width=\"64\">28<\/td>\n<td width=\"117\">29<\/td>\n<td width=\"53\">-1<\/td>\n<td width=\"77\">0<\/td>\n<td width=\"84\">29<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">1<\/td>\n<td width=\"64\">32<\/td>\n<td width=\"117\">29<\/td>\n<td width=\"53\">3<\/td>\n<td width=\"77\">1<\/td>\n<td width=\"84\">30<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">0<\/td>\n<td width=\"64\">28<\/td>\n<td width=\"117\">29<\/td>\n<td width=\"53\">-1<\/td>\n<td width=\"77\">1<\/td>\n<td width=\"84\">30<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>M<\/strong><\/td>\n<td width=\"64\">1<\/td>\n<td width=\"64\">22<\/td>\n<td width=\"117\">29<\/td>\n<td width=\"53\">-7<\/td>\n<td width=\"77\">-2<\/td>\n<td width=\"84\">27<\/td>\n<\/tr>\n<tr>\n<td width=\"64\"><strong>F<\/strong><\/td>\n<td width=\"64\">0<\/td>\n<td width=\"64\">33<\/td>\n<td width=\"117\">29<\/td>\n<td width=\"53\">4<\/td>\n<td width=\"77\">3<\/td>\n<td width=\"84\">32<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"flex-1 overflow-hidden\">\n<div class=\"react-scroll-to-bottom--css-koqot-79elbk h-full\">\n<div class=\"react-scroll-to-bottom--css-koqot-1n7m0yu\">\n<div class=\"flex flex-col text-sm pb-9\">\n<div class=\"w-full text-token-text-primary\" data-testid=\"conversation-turn-13\">\n<div class=\"px-4 py-2 justify-center text-base md:gap-6 m-auto\">\n<div class=\"flex flex-1 text-base mx-auto gap-3 md:px-5 lg:px-1 xl:px-5 md:max-w-3xl lg:max-w-[40rem] xl:max-w-[48rem] group final-completion\">\n<div class=\"relative flex w-full flex-col agent-turn\">\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 overflow-x-auto\" data-message-author-role=\"assistant\" data-message-id=\"8f703d7c-4c26-4d5c-aff0-1bbcd79f14f6\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<p>Error values undergo adjustment with a new prediction, referred to as &#8216;Prediction 2&#8217;. By incorporating the previously calculated mean and &#8216;Prediction 2&#8217;, our aim is to approximate the actual age value. Consequently, the error or discrepancy between the actual and predicted values should diminish.<\/p>\n<p>Furthermore, this iterative process continues, with each iteration utilizing the residual from the current prediction to inform the output of the next stage. The iterative nature of this process enables continuous refinement of predictions, gradually reducing the error over successive iterations.<\/p>\n<p>Moreover, this iterative process persists until the maximum number of iterations is reached.<\/p>\n<p>Now, let&#8217;s delve into an example to illustrate this process.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"flex flex-col text-sm pb-9\"><span style=\"font-size: 19px; font-weight: 900; letter-spacing: 0.13333em; text-transform: uppercase;\">Example:<\/span><\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>We will take the same example as the AdaBoosting technique. We will apply GBM on training and testing sets of the dataset.<\/p>\n<p>from sklearn.ensemble import GradientBoostingClassifier<\/p>\n<p>model= GradientBoostingClassifier(learning_rate=0.01,random_state=1)<\/p>\n<p>model.fit(x_train, y_train)<\/p>\n<p>model.score(x_test,y_test)<\/p>\n<h4><strong>Output:<\/strong><\/h4>\n<p>accuracy_score on test dataset :\u00a0 0.7595555555555555<\/p>\n<p>Note: In the case of regression, the steps will be the same. Just we have to replace GradientBoostingClassifier with GradientBoostingRegressor.<\/p>\n<h3>Light GBM Machine Learning:<\/h3>\n<p><strong>Advantages of Light GBM for Large Datasets<\/strong><\/p>\n<p>When dealing with extremely large datasets, Light GBM emerges as a highly effective solution. This technique boasts superior speed when processing vast amounts of data compared to other algorithms. Unlike traditional level-wise approaches employed by certain algorithms, Light GBM utilizes a tree-based algorithm and adopts a leaf-wise approach.<\/p>\n<p><strong>Leaf-Wise Approach<\/strong><\/p>\n<p>In the leaf-wise approach, Light GBM constructs trees by splitting nodes based on the leaf that results in the maximum reduction of the loss function. This strategy enhances efficiency, particularly on large datasets, as it minimizes the number of levels in each tree.<\/p>\n<p>However, it&#8217;s worth noting that the leaf-wise approach may lead to overfitting, especially on smaller datasets. To mitigate this risk, Light GBM provides a parameter called &#8216;max_depth&#8217;, which enables control over the maximum depth of each tree.<\/p>\n<p>By leveraging these advantages and carefully tuning parameters like &#8216;max_depth&#8217;, Light GBM offers a powerful solution for handling large datasets efficiently while minimizing the risk of overfitting.<\/p>\n<h4>We will apply the Light GBM train data set and the model will predict for the test dataset.<\/h4>\n<p>First, install function<\/p>\n<p>pip install lightgbm<\/p>\n<h4>Applying the algorithm to data sets<\/h4>\n<p>import lightgbm as lgb<\/p>\n<p>train_data=lgb.Dataset(x_train,label=y_train)<\/p>\n<h4><strong>#defining parameters<\/strong><\/h4>\n<p>params = {&#8216;learning_rate&#8217;:0.001}<\/p>\n<p>model= lgb.train(params, train_data, 100)<\/p>\n<p>y_pred=model.predict(x_test)<\/p>\n<p>for i in range(0,4500):\u00a0\u00a0\u00a0 # 4500 is number of datapoints iy_pred<\/p>\n<p>if y_pred[i]&gt;=0.5:<\/p>\n<p>y_pred[i]=1<\/p>\n<p>else:<\/p>\n<p>y_pred[i]=0<\/p>\n<h4><strong># Accuracy Score on a test dataset<\/strong><\/h4>\n<p>acc_test = accuracy_score(y_test,y_pred)<\/p>\n<p>print(&#8216;\\naccuracy_score on test dataset : &#8216;, acc_test)<\/p>\n<h4><strong>Output:<\/strong><\/h4>\n<p>0.958<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<h3>XGBoost in Machine Learning:<\/h3>\n<p>XGBoost, short for Extreme Gradient Boosting, represents one of the most advanced implementations of the gradient boosting algorithm. Renowned for its exceptional speed and high predictive power, XGBoost offers significant advantages over other boosting techniques. Its efficiency is evident, as it is nearly 10 times faster compared to its counterparts, making it a preferred choice for large-scale datasets.<\/p>\n<p>Moreover, XGBoost addresses common issues such as overfitting by incorporating regularization techniques. By mitigating overfitting, XGBoost enhances the overall accuracy of the model, ensuring robust performance even on complex datasets. Its regularization properties have earned it the nickname &#8216;regularized boosting&#8217; technique.<\/p>\n<p>Now, let&#8217;s explore the application of the XGBoost technique on the same dataset to witness its effectiveness firsthand.<\/p>\n<h4><strong>Import that library<\/strong><\/h4>\n<p>pip install xgboost<\/p>\n<h4><b>Applying XGBoost on the next data set.<\/b><\/h4>\n<p>import xgboost as xgb<\/p>\n<p>model=xgb.XGBClassifier(random_state=1,learning_rate=0.01)<\/p>\n<p>model.fit(x_train, y_train)<\/p>\n<p>model.score(x_test,y_test)<\/p>\n<h4><strong>Output:<\/strong><\/h4>\n<p>0.9995555555555555<\/p>\n<h3>CatBoost in Machine Learning:<\/h3>\n<p>It is difficult to handle large amounts of labeled data in case of the categorical values. Means if data is having many categorical variables then it is difficult to process the label encoding operation. In that case, \u2018CatBoost\u2019 can handle categorical variables and does not require extensive data preprocessing like other ML models. Let\u2019s apply the technique to the same dataset.<\/p>\n<h3><strong>Import library<\/strong><\/h3>\n<p>&nbsp;<\/p>\n<p>pip install catboost<\/p>\n<h3><strong>Applying CatBoost<\/strong><\/h3>\n<p>from catboost import CatBoostClassifier<\/p>\n<p>model=CatBoostClassifier()<\/p>\n<p>categorical_features_indices = np.where(df.dtypes != np.float)[0]<\/p>\n<p>model.fit(x_train,y_train,cat_features=([0,1,2,3,4]),eval_set=(x_test, y_test))<\/p>\n<p>model.score(x_test,y_test)<\/p>\n<h4><strong>Output:<\/strong><\/h4>\n<p>0.9991111111111111<\/p>\n<p>We hope you understand the boosting techniques in machine learning. Get success in your career as a <a href=\"https:\/\/prwatech.in\/data-science-training-institutes-in-bangalore\/\" target=\"_blank\" rel=\"noopener noreferrer\">Data Scientist<\/a> by being a part of the <a href=\"https:\/\/prwatech.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Prwatech<\/a>, India&#8217;s leading <a href=\"https:\/\/prwatech.in\/data-science-training-institutes-in-bangalore\/\" target=\"_blank\" rel=\"noopener noreferrer\">Data Science training institute in Bangalore<\/a>.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/EGbyBqFlTcQ\" width=\"850\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Boosting Techniques in Machine Learning Boosting Techniques in Machine Learning, in this Tutorial one can learn the Boosting algorithm introduction. Are you the one who is looking for the best platform which provides information about different types of boosting algorithm? Or the one who is looking forward to taking the advanced Data Science Certification Course [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,1696],"tags":[448,447,445,452,446,449,450,451],"class_list":["post-4831","post","type-post","status-publish","format-standard","hentry","category-machine-learning","category-machine-learning-modules","tag-adaboost-algorithm-in-machine-learning","tag-boosting-algorithm-introduction","tag-boosting-techniques-in-machine-learning","tag-catboost-in-machine-learning","tag-different-types-of-boosting-algorithm","tag-gradient-boosting-in-machine-learning","tag-lightgbm-machine-learning","tag-xgboost-in-machine-learning"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>A Beginner&#039;s Guide to Boosting in Machine Learning - Prwatech<\/title>\n<meta name=\"description\" content=\"Explore Boosting techniques in Machine Learning tutorial &amp; learn Boosting Algorithm introduction, Different types of Boosting Algorithm.\" \/>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A Beginner&#039;s Guide to Boosting in Machine Learning - Prwatech\" \/>\n<meta property=\"og:description\" content=\"Explore Boosting techniques in Machine Learning tutorial &amp; learn Boosting Algorithm introduction, Different types of Boosting Algorithm.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/\" \/>\n<meta property=\"og:site_name\" content=\"Prwatech\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prwatech.in\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-15T11:57:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-15T11:43:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2020\/02\/boosting1.png\" \/>\n<meta name=\"author\" content=\"Prwatech\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:site\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prwatech\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/\",\"url\":\"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/\",\"name\":\"A Beginner's Guide to Boosting in Machine Learning - Prwatech\",\"isPartOf\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2020\/02\/boosting1.png\",\"datePublished\":\"2020-02-15T11:57:39+00:00\",\"dateModified\":\"2024-03-15T11:43:38+00:00\",\"author\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\"},\"description\":\"Explore Boosting techniques in Machine Learning tutorial & learn Boosting Algorithm introduction, Different types of Boosting Algorithm.\",\"breadcrumb\":{\"@id\":\"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/#primaryimage\",\"url\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2020\/02\/boosting1.png\",\"contentUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2020\/02\/boosting1.png\",\"width\":320,\"height\":105},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/prwatech.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Boosting Techniques in Machine Learning\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/prwatech.in\/blog\/#website\",\"url\":\"https:\/\/prwatech.in\/blog\/\",\"name\":\"Prwatech\",\"description\":\"Share Ideas, Start Something Good.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/prwatech.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\",\"name\":\"Prwatech\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"caption\":\"Prwatech\"},\"url\":\"https:\/\/prwatech.in\/blog\/author\/prwatech123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A Beginner's Guide to Boosting in Machine Learning - Prwatech","description":"Explore Boosting techniques in Machine Learning tutorial & learn Boosting Algorithm introduction, Different types of Boosting Algorithm.","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"A Beginner's Guide to Boosting in Machine Learning - Prwatech","og_description":"Explore Boosting techniques in Machine Learning tutorial & learn Boosting Algorithm introduction, Different types of Boosting Algorithm.","og_url":"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/","og_site_name":"Prwatech","article_publisher":"https:\/\/www.facebook.com\/prwatech.in\/","article_published_time":"2020-02-15T11:57:39+00:00","article_modified_time":"2024-03-15T11:43:38+00:00","og_image":[{"url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2020\/02\/boosting1.png","type":"","width":"","height":""}],"author":"Prwatech","twitter_card":"summary_large_image","twitter_creator":"@Eduprwatech","twitter_site":"@Eduprwatech","twitter_misc":{"Written by":"Prwatech","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/","url":"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/","name":"A Beginner's Guide to Boosting in Machine Learning - Prwatech","isPartOf":{"@id":"https:\/\/prwatech.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/#primaryimage"},"image":{"@id":"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/#primaryimage"},"thumbnailUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2020\/02\/boosting1.png","datePublished":"2020-02-15T11:57:39+00:00","dateModified":"2024-03-15T11:43:38+00:00","author":{"@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3"},"description":"Explore Boosting techniques in Machine Learning tutorial & learn Boosting Algorithm introduction, Different types of Boosting Algorithm.","breadcrumb":{"@id":"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/#primaryimage","url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2020\/02\/boosting1.png","contentUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2020\/02\/boosting1.png","width":320,"height":105},{"@type":"BreadcrumbList","@id":"https:\/\/prwatech.in\/blog\/machine-learning\/machine-learning-modules\/boosting-techniques-in-machine-learning\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/prwatech.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Boosting Techniques in Machine Learning"}]},{"@type":"WebSite","@id":"https:\/\/prwatech.in\/blog\/#website","url":"https:\/\/prwatech.in\/blog\/","name":"Prwatech","description":"Share Ideas, Start Something Good.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/prwatech.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3","name":"Prwatech","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","caption":"Prwatech"},"url":"https:\/\/prwatech.in\/blog\/author\/prwatech123\/"}]}},"_links":{"self":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/4831","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/comments?post=4831"}],"version-history":[{"count":11,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/4831\/revisions"}],"predecessor-version":[{"id":10914,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/4831\/revisions\/10914"}],"wp:attachment":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media?parent=4831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/categories?post=4831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/tags?post=4831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}