<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to adjust probability predicted using logistic regression after oversampling in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787511#M9007</link>
    <description>&lt;P&gt;I have created a logistic regression model using the E-Miner tool where event probability in population base was 0.06, after oversampling I created a base where event probability is 0.2. Now how can I adjust the probabilities according to the population base using SAS code in Enterprise Guide?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found below mentioned formula in another post from the SAS community-&lt;A href="https://communities.sas.com/t5/SAS-Data-Mining-and-Machine/Urgent-how-to-adjust-probabilities-after-oversampling-Please/m-p/170809#M1938" target="_blank" rel="noopener"&gt;how-to-adjust-probabilities-after-oversampling&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P_i** = ( P_i*&amp;nbsp; x&amp;nbsp; &lt;EM&gt;R_0 &lt;/EM&gt;x&amp;nbsp; &lt;EM&gt;P_1) / &lt;/EM&gt;( (1-P_i*) (&lt;EM&gt;R_1)(P_0)&amp;nbsp; +&amp;nbsp; &lt;/EM&gt;(P_i*)(&lt;EM&gt;R_0)(P_1) )&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;where:&lt;/P&gt;
&lt;P&gt;P_i* is the unadjusted probability you get from your model&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;R_0 &lt;/EM&gt;and R&lt;EM&gt;_1 &lt;/EM&gt;are the sample proportions of 1 and 0 respectively&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;P_0 &lt;/EM&gt;and P&lt;EM&gt;_1 &lt;/EM&gt;are the original event and non_event rates (population rates)&lt;/P&gt;
&lt;P&gt;P_i** is the true probability&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But using this formula I am getting adjusted probability to be higher than actual probability.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Dec 2021 11:13:53 GMT</pubDate>
    <dc:creator>Saurabh_Rana</dc:creator>
    <dc:date>2021-12-28T11:13:53Z</dc:date>
    <item>
      <title>How to adjust probability predicted using logistic regression after oversampling</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787511#M9007</link>
      <description>&lt;P&gt;I have created a logistic regression model using the E-Miner tool where event probability in population base was 0.06, after oversampling I created a base where event probability is 0.2. Now how can I adjust the probabilities according to the population base using SAS code in Enterprise Guide?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found below mentioned formula in another post from the SAS community-&lt;A href="https://communities.sas.com/t5/SAS-Data-Mining-and-Machine/Urgent-how-to-adjust-probabilities-after-oversampling-Please/m-p/170809#M1938" target="_blank" rel="noopener"&gt;how-to-adjust-probabilities-after-oversampling&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P_i** = ( P_i*&amp;nbsp; x&amp;nbsp; &lt;EM&gt;R_0 &lt;/EM&gt;x&amp;nbsp; &lt;EM&gt;P_1) / &lt;/EM&gt;( (1-P_i*) (&lt;EM&gt;R_1)(P_0)&amp;nbsp; +&amp;nbsp; &lt;/EM&gt;(P_i*)(&lt;EM&gt;R_0)(P_1) )&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;where:&lt;/P&gt;
&lt;P&gt;P_i* is the unadjusted probability you get from your model&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;R_0 &lt;/EM&gt;and R&lt;EM&gt;_1 &lt;/EM&gt;are the sample proportions of 1 and 0 respectively&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;P_0 &lt;/EM&gt;and P&lt;EM&gt;_1 &lt;/EM&gt;are the original event and non_event rates (population rates)&lt;/P&gt;
&lt;P&gt;P_i** is the true probability&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But using this formula I am getting adjusted probability to be higher than actual probability.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Dec 2021 11:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787511#M9007</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2021-12-28T11:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to adjust probability predicted using logistic regression after oversampling</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787518#M9008</link>
      <description>&lt;P&gt;Check SCORE statment of PROC LOGISTIC :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1640693727034.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66975i0F90B71EACA8A821/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1640693727034.png" alt="Ksharp_0-1640693727034.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Dec 2021 12:16:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787518#M9008</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-12-28T12:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to adjust probability predicted using logistic regression after oversampling</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787521#M9009</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First of all : Make sure you are not mixing up the (#2) target levels.&lt;/P&gt;
&lt;P&gt;And check what the target level is that you are predicting : is you model giving probabilities for level_1 or for level_2?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the above is OK, here's how you adjust :&lt;/P&gt;
&lt;P&gt;Usage Note 22601: Adjusting for oversampling the event level in a binary logistic model&lt;BR /&gt;&lt;A href="https://support.sas.com/kb/22/601.html" target="_blank"&gt;https://support.sas.com/kb/22/601.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And from the Enterprise Miner documentation :&lt;BR /&gt;SAS® Enterprise Miner™ 15.1 Extension Nodes: Developer’s Guide&lt;BR /&gt;&lt;A href="https://go.documentation.sas.com/doc/en/emxndg/15.1/p1vqpbjwoo4bv7n1sw77e0z64xxs.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/emxndg/15.1/p1vqpbjwoo4bv7n1sw77e0z64xxs.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sbxkoenk_0-1640696004691.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66976i2ED78C0957946C74/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sbxkoenk_0-1640696004691.png" alt="sbxkoenk_0-1640696004691.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Tue, 28 Dec 2021 12:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787521#M9009</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-12-28T12:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to adjust probability predicted using logistic regression after oversampling</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787532#M9010</link>
      <description>&lt;P&gt;Let me show you the calculation for an example where &lt;STRONG&gt;Predicted Probability is 0.6&lt;/STRONG&gt;:-&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Predicted Probability=0.6&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Sample Event Proportion=0.2&lt;/P&gt;
&lt;P&gt;Sample Non Event Proportion=0.8&lt;/P&gt;
&lt;P&gt;Population Event Proportion=0.06&lt;/P&gt;
&lt;P&gt;Population Non Event Proportion=0.94&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adjusted Probability=(0.6*0.2*0.94)/[(0.4*0.8*0.06)+(0.6*0.2*0.94)] = &lt;STRONG&gt;0.8545&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Adjusted Probability( 0.8545 ) &amp;gt;&amp;nbsp;Predicted Probability(0.6)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please tell me where I am making a mistake while calculating adjusted probability?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Dec 2021 18:08:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787532#M9010</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2021-12-28T18:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to adjust probability predicted using logistic regression after oversampling</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787555#M9011</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
*Predicted Probability=0.6              ; *OldPost(i,t);
*Sample Event Proportion=0.2            ; *OldPrior(t) ;
*Sample Non Event Proportion=0.8        ; 
*Population Event Proportion=0.06       ; *Prior(t)    ;
*Population Non Event Proportion=0.94   ; 

Post_i_t = (0.6 * 0.06 / 0.2) / ( (0.6 * 0.06 / 0.2) + (0.4 * 0.94 / 0.8) );
put Post_i_t=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Post_i_t = 0.2769230769&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Tue, 28 Dec 2021 22:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787555#M9011</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-12-28T22:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to adjust probability predicted using logistic regression after oversampling</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787585#M9013</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Using this method adjusting probability is coming out to be lower than predicted probability but when I take the mean of all the adjusted probabilities it is not coming out to be 0.06, ideally, the mean of adjusted probability should be equal to event probability in the population base. Like if I take the mean of predicted probability it is coming out to be 0.2 as expected which is the event probability in the sample base.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 06:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787585#M9013</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2021-12-29T06:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to adjust probability predicted using logistic regression after oversampling</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787655#M9014</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are right in expecting the mean of all adjusted probabilities to be (approximately) the event rate in the population base.&lt;/P&gt;
&lt;P&gt;I do not know why that's not the case with your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, why are you adjusting these probabilities "manually"?&lt;/P&gt;
&lt;P&gt;If you use the Enterprise Miner target profiler, then the correct posterior probabilities (adjusted for the real priors) are automatically returned by the software.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See here :&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SAS® Enterprise Miner™ 15.1: Reference Help&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Predictive Modeling :&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/emref/15.1/p0qiq0a4vnebuzn16v8fzossk4gp.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/emref/15.1/p0qiq0a4vnebuzn16v8fzossk4gp.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Enterprise Miner Target Profiler :&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/emref/15.1/n0z1mtvsscypjqn1ediv223jq5iy.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/emref/15.1/n0z1mtvsscypjqn1ediv223jq5iy.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Koen&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 17:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/787655#M9014</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-12-29T17:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to adjust probability predicted using logistic regression after oversampling</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/788039#M9018</link>
      <description>&lt;P&gt;I will try to adjust probability using the E-Miner method but is there no mathematical formula through which I could adjust probability?&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jan 2022 20:02:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/788039#M9018</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2022-01-02T20:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to adjust probability predicted using logistic regression after oversampling</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/788040#M9019</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The mathematical formula is in one of my posts above.&lt;/P&gt;
&lt;P&gt;(and in the doc :&amp;nbsp;&lt;SPAN&gt;SAS® Enterprise Miner™ 15.1 Extension Nodes: Developer’s Guide&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://go.documentation.sas.com/doc/en/emxndg/15.1/p1vqpbjwoo4bv7n1sw77e0z64xxs.htm" target="_blank" rel="nofollow noopener noreferrer"&gt;https://go.documentation.sas.com/doc/en/emxndg/15.1/p1vqpbjwoo4bv7n1sw77e0z64xxs.htm&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The formula is also here (marked as solution).&lt;BR /&gt;&lt;SPAN&gt;Subject : Urgent, how to adjust probabilities after oversampling? Please Help, Thank you&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Data-Mining-and-Machine/Urgent-how-to-adjust-probabilities-after-oversampling-Please/td-p/170809" target="_blank"&gt;https://communities.sas.com/t5/SAS-Data-Mining-and-Machine/Urgent-how-to-adjust-probabilities-after-oversampling-Please/td-p/170809&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have successfully done it the formula-way myself several times, but cannot locate these programs any more.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jan 2022 20:26:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-adjust-probability-predicted-using-logistic-regression/m-p/788040#M9019</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-01-02T20:26:50Z</dc:date>
    </item>
  </channel>
</rss>

