{"id":2352,"date":"2022-04-17T06:00:48","date_gmt":"2022-04-17T06:00:48","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=2352"},"modified":"2022-04-17T06:00:48","modified_gmt":"2022-04-17T06:00:48","slug":"what-is-backward-elimination","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/04\/17\/what-is-backward-elimination\/","title":{"rendered":"What is Backward Elimination?"},"content":{"rendered":"\n<p>Backward elimination is a feature selection technique while building a machine learning model. It is used to remove those features that do not have a significant effect on the dependent variable or prediction of output. There are various ways to build a model in Machine Learning, which are:<\/p>\n\n\n\n<ol><li>All-in<\/li><li>Backward Elimination<\/li><li>Forward Selection<\/li><li>Bidirectional Elimination<\/li><li>Score Comparison<\/li><\/ol>\n\n\n\n<p>Above are the possible methods for building the model in Machine learning, but we will only use here the Backward Elimination process as it is the fastest method.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Steps of Backward Elimination<\/h3>\n\n\n\n<p>Below are some main steps which are used to apply backward elimination process:<\/p>\n\n\n\n<p><strong>Step-1:<\/strong>&nbsp;Firstly, We need to select a significance level to stay in the model. (SL=0.05)<\/p>\n\n\n\n<p><strong>Step-2:<\/strong>&nbsp;Fit the complete model with all possible predictors\/independent variables.<\/p>\n\n\n\n<p><strong>Step-3:<\/strong>&nbsp;Choose the predictor which has the highest P-value, such that.<\/p>\n\n\n\n<ol><li>If P-value &gt;SL, go to step 4.<\/li><li>Else Finish, and Our model is ready.<\/li><\/ol>\n\n\n\n<p><strong>Step-4:<\/strong>&nbsp;Remove that predictor.<\/p>\n\n\n\n<p><strong>Step-5:<\/strong>&nbsp;Rebuild and fit the model with the remaining variables.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Need for Backward Elimination: An optimal Multiple Linear Regression model:<\/h3>\n\n\n\n<p>In the previous chapter, we discussed and successfully created our Multiple Linear Regression model, where we took&nbsp;<strong>4 independent variables (R&amp;D spend, Administration spend, Marketing spend, and state (dummy variables)) and one dependent variable (Profit)<\/strong>. But that model is not optimal, as we have included all the independent variables and do not know which independent model is most affecting and which one is the least affecting for the prediction.<\/p>\n\n\n\n<p>Unnecessary features increase the complexity of the model. Hence it is good to have only the most significant features and keep our model simple to get the better result.<\/p>\n\n\n\n<p>So, in order to optimize the performance of the model, we will use the Backward Elimination method. This process is used to optimize the performance of the MLR model as it will only include the most affecting feature and remove the least affecting feature. Let&#8217;s start to apply it to our MLR model.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Steps for Backward Elimination method:<\/h3>\n\n\n\n<p>We will use the same model which we build in the previous chapter of MLR. Below is the complete code for it:<a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><\/p>\n\n\n\n<ol><li>#&nbsp;importing&nbsp;libraries&nbsp;&nbsp;<\/li><li class=\"\"><strong>import<\/strong>&nbsp;numpy&nbsp;as&nbsp;nm&nbsp;&nbsp;<\/li><li><strong>import<\/strong>&nbsp;matplotlib.pyplot&nbsp;as&nbsp;mtp&nbsp;&nbsp;<\/li><li class=\"\"><strong>import<\/strong>&nbsp;pandas&nbsp;as&nbsp;pd&nbsp;&nbsp;<\/li><li>&nbsp;&nbsp;<\/li><li class=\"\">#importing&nbsp;datasets&nbsp;&nbsp;<\/li><li>data_set=&nbsp;pd.read_csv(&#8217;50_CompList.csv&#8217;)&nbsp;&nbsp;<\/li><li class=\"\">&nbsp;&nbsp;<\/li><li>#Extracting&nbsp;Independent&nbsp;and&nbsp;dependent&nbsp;Variable&nbsp;&nbsp;<\/li><li class=\"\">x=&nbsp;data_set.iloc[:,&nbsp;:-1].values&nbsp;&nbsp;<\/li><li>y=&nbsp;data_set.iloc[:,&nbsp;4].values&nbsp;&nbsp;<\/li><li class=\"\">&nbsp;&nbsp;<\/li><li>#Catgorical&nbsp;data&nbsp;&nbsp;<\/li><li class=\"\">from&nbsp;sklearn.preprocessing&nbsp;<strong>import<\/strong>&nbsp;LabelEncoder,&nbsp;OneHotEncoder&nbsp;&nbsp;<\/li><li>labelencoder_x=&nbsp;LabelEncoder()&nbsp;&nbsp;<\/li><li class=\"\">x[:,&nbsp;3]=&nbsp;labelencoder_x.fit_transform(x[:,3])&nbsp;&nbsp;<\/li><li>onehotencoder=&nbsp;OneHotEncoder(categorical_features=&nbsp;[3])&nbsp;&nbsp;&nbsp;&nbsp;<\/li><li class=\"\">x=&nbsp;onehotencoder.fit_transform(x).toarray()&nbsp;&nbsp;<\/li><li>&nbsp;&nbsp;<\/li><li class=\"\">#Avoiding&nbsp;the&nbsp;dummy&nbsp;variable&nbsp;trap:&nbsp;&nbsp;<\/li><li>x&nbsp;=&nbsp;x[:,&nbsp;1:]&nbsp;&nbsp;<\/li><li class=\"\">&nbsp;&nbsp;<\/li><li>&nbsp;&nbsp;<\/li><li class=\"\">#&nbsp;Splitting&nbsp;the&nbsp;dataset&nbsp;into&nbsp;training&nbsp;and&nbsp;test&nbsp;set.&nbsp;&nbsp;<\/li><li>from&nbsp;sklearn.model_selection&nbsp;<strong>import<\/strong>&nbsp;train_test_split&nbsp;&nbsp;<\/li><li class=\"\">x_train,&nbsp;x_test,&nbsp;y_train,&nbsp;y_test=&nbsp;train_test_split(x,&nbsp;y,&nbsp;test_size=&nbsp;0.2,&nbsp;random_state=0)&nbsp;&nbsp;<\/li><li>&nbsp;&nbsp;<\/li><li class=\"\">#Fitting&nbsp;the&nbsp;MLR&nbsp;model&nbsp;to&nbsp;the&nbsp;training&nbsp;set:&nbsp;&nbsp;<\/li><li>from&nbsp;sklearn.linear_model&nbsp;<strong>import<\/strong>&nbsp;LinearRegression&nbsp;&nbsp;<\/li><li class=\"\">regressor=&nbsp;LinearRegression()&nbsp;&nbsp;<\/li><li>regressor.fit(x_train,&nbsp;y_train)&nbsp;&nbsp;<\/li><li class=\"\">&nbsp;&nbsp;<\/li><li>#Predicting&nbsp;the&nbsp;Test&nbsp;set&nbsp;result;&nbsp;&nbsp;<\/li><li class=\"\">y_pred=&nbsp;regressor.predict(x_test)&nbsp;&nbsp;<\/li><li>&nbsp;&nbsp;<\/li><li class=\"\">#Checking&nbsp;the&nbsp;score&nbsp;&nbsp;<\/li><li>print(&#8216;Train&nbsp;Score:&nbsp;&#8216;,&nbsp;regressor.score(x_train,&nbsp;y_train))&nbsp;&nbsp;<\/li><li class=\"\">print(&#8216;Test&nbsp;Score:&nbsp;&#8216;,&nbsp;regressor.score(x_test,&nbsp;y_test))&nbsp;&nbsp;<\/li><\/ol>\n\n\n\n<p><strong>From the above code, we got training and test set result as:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Train Score:  0.9501847627493607\nTest Score:  0.9347068473282446\n<\/pre>\n\n\n\n<p><strong>The difference between both scores is 0.0154.<\/strong><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Note: On the basis of this score, we will estimate the effect of features on our model after using the Backward elimination process.<\/h4>\n\n\n\n<p><strong>Step: 1- Preparation of Backward Elimination:<\/strong><\/p>\n\n\n\n<ul><li><strong>Importing the library:<\/strong>&nbsp;Firstly, we need to import the&nbsp;<strong>statsmodels.formula.api<\/strong>&nbsp;library, which is used for the estimation of various statistical models such as OLS(Ordinary Least Square). Below is the code for it:<\/li><\/ul>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><\/p>\n\n\n\n<ol><li><strong>import<\/strong>&nbsp;statsmodels.api&nbsp;as&nbsp;smf&nbsp;&nbsp;<\/li><\/ol>\n\n\n\n<ul><li><strong>Adding a column in matrix of features:<\/strong>&nbsp;As we can check in our MLR equation (a), there is one constant term b<sub>0<\/sub>, but this term is not present in our matrix of features, so we need to add it manually. We will add a column having values x<sub>0<\/sub>&nbsp;= 1 associated with the constant term b<sub>0<\/sub>.<br>To add this, we will use&nbsp;<strong>append<\/strong>&nbsp;function of&nbsp;<strong>Numpy<\/strong>&nbsp;library (nm which we have already imported into our code), and will assign a value of 1. Below is the code for it.<\/li><\/ul>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><\/p>\n\n\n\n<ol><li>x&nbsp;=&nbsp;nm.append(arr&nbsp;=&nbsp;nm.ones((50,1)).astype(<strong>int<\/strong>),&nbsp;values=x,&nbsp;axis=1)&nbsp;&nbsp;<\/li><\/ol>\n\n\n\n<p>Here we have used axis =1, as we wanted to add a column. For adding a row, we can use axis =0.<\/p>\n\n\n\n<p><strong>Output:<\/strong>&nbsp;By executing the above line of code, a new column will be added into our matrix of features, which will have all values equal to 1. We can check it by clicking on the x dataset under the variable explorer option.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static.javatpoint.com\/tutorial\/machine-learning\/images\/backward-elimination-in-machine-learning.png\" alt=\"Backward Elimination\"\/><\/figure>\n\n\n\n<p>As we can see in the above output image, the first column is added successfully, which corresponds to the constant term of the MLR equation.<\/p>\n\n\n\n<p><strong>Step: 2:<\/strong><\/p>\n\n\n\n<ul><li>Now, we are actually going to apply a backward elimination process. Firstly we will create a new feature vector&nbsp;<strong>x_opt<\/strong>, which will only contain a set of independent features that are significantly affecting the dependent variable.<\/li><li>Next, as per the Backward Elimination process, we need to choose a significant level(0.5), and then need to fit the model with all possible predictors. So for fitting the model, we will create a&nbsp;<strong>regressor_OLS<\/strong>&nbsp;object of new class&nbsp;<strong>OLS<\/strong>&nbsp;of&nbsp;<strong>statsmodels<\/strong>&nbsp;library. Then we will fit it by using the&nbsp;<strong>fit()<\/strong>&nbsp;method.<\/li><li>Next we need&nbsp;<strong>p-value<\/strong>&nbsp;to compare with SL value, so for this we will use&nbsp;<strong>summary()<\/strong>&nbsp;method to get the summary table of all the values. Below is the code for it:<\/li><\/ul>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><\/p>\n\n\n\n<ol><li>x_opt=x&nbsp;[:,&nbsp;[0,1,2,3,4,5]]&nbsp;&nbsp;<\/li><li class=\"\">regressor_OLS=sm.OLS(endog&nbsp;=&nbsp;y,&nbsp;exog=x_opt).fit()&nbsp;&nbsp;<\/li><li>regressor_OLS.summary()&nbsp;&nbsp;<\/li><\/ol>\n\n\n\n<p><strong>Output:<\/strong>&nbsp;By executing the above lines of code, we will get a summary table. Consider the below image:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static.javatpoint.com\/tutorial\/machine-learning\/images\/backward-elimination-in-machine-learning2.png\" alt=\"Backward Elimination\"\/><\/figure>\n\n\n\n<p>In the above image, we can clearly see the p-values of all the variables. Here&nbsp;<strong>x1, x2 are dummy variables, x3 is R&amp;D spend, x4 is Administration spend, and x5 is Marketing spend<\/strong>.<\/p>\n\n\n\n<p>From the table, we will choose the highest p-value, which is for x1=0.953 Now, we have the highest p-value which is greater than the SL value, so will remove the x1 variable (dummy variable) from the table and will refit the model. Below is the code for it:<a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><\/p>\n\n\n\n<ol><li>x_opt=x[:,&nbsp;[0,2,3,4,5]]&nbsp;&nbsp;<\/li><li class=\"\">regressor_OLS=sm.OLS(endog&nbsp;=&nbsp;y,&nbsp;exog=x_opt).fit()&nbsp;&nbsp;<\/li><li>regressor_OLS.summary()&nbsp;&nbsp;<\/li><\/ol>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static.javatpoint.com\/tutorial\/machine-learning\/images\/backward-elimination-in-machine-learning3.png\" alt=\"Backward Elimination\"\/><\/figure>\n\n\n\n<p>As we can see in the output image, now five variables remain. In these variables, the highest p-value is 0.961. So we will remove it in the next iteration.<\/p>\n\n\n\n<ul><li>Now the next highest value is 0.961 for x1 variable, which is another dummy variable. So we will remove it and refit the model. Below is the code for it:<\/li><\/ul>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><\/p>\n\n\n\n<ol><li>x_opt=&nbsp;x[:,&nbsp;[0,3,4,5]]&nbsp;&nbsp;<\/li><li class=\"\">regressor_OLS=sm.OLS(endog&nbsp;=&nbsp;y,&nbsp;exog=x_opt).fit()&nbsp;&nbsp;<\/li><li>regressor_OLS.summary()&nbsp;&nbsp;<\/li><\/ol>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static.javatpoint.com\/tutorial\/machine-learning\/images\/backward-elimination-in-machine-learning4.png\" alt=\"Backward Elimination\"\/><\/figure>\n\n\n\n<p>In the above output image, we can see the dummy variable(x2) has been removed. And the next highest value is .602, which is still greater than .5, so we need to remove it.<\/p>\n\n\n\n<ul><li>Now we will remove the Admin spend which is having .602 p-value and again refit the model.<\/li><\/ul>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><\/p>\n\n\n\n<ol><li>x_opt=x[:,&nbsp;[0,3,5]]&nbsp;&nbsp;<\/li><li class=\"\">regressor_OLS=sm.OLS(endog&nbsp;=&nbsp;y,&nbsp;exog=x_opt).fit()&nbsp;&nbsp;<\/li><li>regressor_OLS.summary()&nbsp;&nbsp;<\/li><\/ol>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static.javatpoint.com\/tutorial\/machine-learning\/images\/backward-elimination-in-machine-learning5.png\" alt=\"Backward Elimination\"\/><\/figure>\n\n\n\n<p>As we can see in the above output image, the variable (Admin spend) has been removed. But still, there is one variable left, which is&nbsp;<strong>marketing spend<\/strong>&nbsp;as it has a high p-value&nbsp;<strong>(0.60)<\/strong>. So we need to remove it.<\/p>\n\n\n\n<ul><li>Finally, we will remove one more variable, which has .60 p-value for marketing spend, which is more than a significant level.<br>Below is the code for it:<\/li><\/ul>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><\/p>\n\n\n\n<ol><li>x_opt=x[:,&nbsp;[0,3]]&nbsp;&nbsp;<\/li><li class=\"\">regressor_OLS=sm.OLS(endog&nbsp;=&nbsp;y,&nbsp;exog=x_opt).fit()&nbsp;&nbsp;<\/li><li>regressor_OLS.summary()&nbsp;&nbsp;<\/li><\/ol>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static.javatpoint.com\/tutorial\/machine-learning\/images\/backward-elimination-in-machine-learning6.png\" alt=\"Backward Elimination\"\/><\/figure>\n\n\n\n<p>As we can see in the above output image, only two variables are left. So only the&nbsp;<strong>R&amp;D independent variable<\/strong>&nbsp;is a significant variable for the prediction. So we can now predict efficiently using this variable.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Estimating the performance:<\/h3>\n\n\n\n<p>In the previous topic, we have calculated the train and test score of the model when we have used all the features variables. Now we will check the score with only one feature variable (R&amp;D spend). Our dataset now looks like:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static.javatpoint.com\/tutorial\/machine-learning\/images\/backward-elimination-in-machine-learning7.png\" alt=\"Backward Elimination\"\/><\/figure>\n\n\n\n<p><strong>Below is the code for Building Multiple Linear Regression model by only using R&amp;D spend:<\/strong><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/backward-elimination-in-machine-learning#\"><\/a><\/p>\n\n\n\n<ol><li>#&nbsp;importing&nbsp;libraries&nbsp;&nbsp;<\/li><li class=\"\"><strong>import<\/strong>&nbsp;numpy&nbsp;as&nbsp;nm&nbsp;&nbsp;<\/li><li><strong>import<\/strong>&nbsp;matplotlib.pyplot&nbsp;as&nbsp;mtp&nbsp;&nbsp;<\/li><li class=\"\"><strong>import<\/strong>&nbsp;pandas&nbsp;as&nbsp;pd&nbsp;&nbsp;<\/li><li>&nbsp;&nbsp;<\/li><li class=\"\">#importing&nbsp;datasets&nbsp;&nbsp;<\/li><li>data_set=&nbsp;pd.read_csv(&#8217;50_CompList1.csv&#8217;)&nbsp;&nbsp;<\/li><li class=\"\">&nbsp;&nbsp;<\/li><li>#Extracting&nbsp;Independent&nbsp;and&nbsp;dependent&nbsp;Variable&nbsp;&nbsp;<\/li><li class=\"\">x_BE=&nbsp;data_set.iloc[:,&nbsp;:-1].values&nbsp;&nbsp;<\/li><li>y_BE=&nbsp;data_set.iloc[:,&nbsp;1].values&nbsp;&nbsp;<\/li><li class=\"\">&nbsp;&nbsp;<\/li><li>&nbsp;&nbsp;<\/li><li class=\"\">#&nbsp;Splitting&nbsp;the&nbsp;dataset&nbsp;into&nbsp;training&nbsp;and&nbsp;test&nbsp;set.&nbsp;&nbsp;<\/li><li>from&nbsp;sklearn.model_selection&nbsp;<strong>import<\/strong>&nbsp;train_test_split&nbsp;&nbsp;<\/li><li class=\"\">x_BE_train,&nbsp;x_BE_test,&nbsp;y_BE_train,&nbsp;y_BE_test=&nbsp;train_test_split(x_BE,&nbsp;y_BE,&nbsp;test_size=&nbsp;0.2,&nbsp;random_state=0)&nbsp;&nbsp;<\/li><li>&nbsp;&nbsp;<\/li><li class=\"\">#Fitting&nbsp;the&nbsp;MLR&nbsp;model&nbsp;to&nbsp;the&nbsp;training&nbsp;set:&nbsp;&nbsp;<\/li><li>from&nbsp;sklearn.linear_model&nbsp;<strong>import<\/strong>&nbsp;LinearRegression&nbsp;&nbsp;<\/li><li class=\"\">regressor=&nbsp;LinearRegression()&nbsp;&nbsp;<\/li><li>regressor.fit(nm.array(x_BE_train).reshape(-1,1),&nbsp;y_BE_train)&nbsp;&nbsp;<\/li><li class=\"\">&nbsp;&nbsp;<\/li><li>#Predicting&nbsp;the&nbsp;Test&nbsp;set&nbsp;result;&nbsp;&nbsp;<\/li><li class=\"\">y_pred=&nbsp;regressor.predict(x_BE_test)&nbsp;&nbsp;<\/li><li>&nbsp;&nbsp;<\/li><li class=\"\">#Cheking&nbsp;the&nbsp;score&nbsp;&nbsp;<\/li><li>print(&#8216;Train&nbsp;Score:&nbsp;&#8216;,&nbsp;regressor.score(x_BE_train,&nbsp;y_BE_train))&nbsp;&nbsp;<\/li><li class=\"\">print(&#8216;Test&nbsp;Score:&nbsp;&#8216;,&nbsp;regressor.score(x_BE_test,&nbsp;y_BE_test))&nbsp;&nbsp;<\/li><\/ol>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<p>After executing the above code, we will get the Training and test scores as:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Train Score:  0.9449589778363044\nTest Score:  0.9464587607787219\n<\/pre>\n\n\n\n<p>As we can see, the training score is 94% accurate, and the test score is also 94% accurate. The difference between both scores is&nbsp;<strong>.00149<\/strong>. This score is very much close to the previous score, i.e.,&nbsp;<strong>0.0154<\/strong>, where we have included all the variables.<\/p>\n\n\n\n<p><strong>We got this result by using one independent variable (R&amp;D spend) only instead of four variables. Hence, now, our model is simple and accurate.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Backward elimination is a feature selection technique while building a machine learning model. It is used to remove those features that do not have a significant effect on the dependent variable or prediction of output. There are various ways to build a model in Machine Learning, which are: All-in Backward Elimination Forward Selection Bidirectional Elimination [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[816],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/2352"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=2352"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/2352\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=2352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=2352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=2352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}