<?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 Re: MAX IV Value for a continuous variable in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/MAX-IV-Value-for-a-continuous-variable/m-p/960210#M4295</link>
    <description>&lt;P&gt;RobPratt,&lt;/P&gt;
&lt;P&gt;Unfortunately,&amp;nbsp;&lt;SPAN&gt;The OPTBINNING procedure&amp;nbsp; is running under SAS/Viya , I don't have it. My sas is a stand-alone PC version.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And it looks like PROC OPTBINNING need set up some parameters(cutpoints ,woe,lower bound, upper bound, and WOE trend &amp;lt;-- what does it mean? ) firstly .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I need the code like your posted before for binning categroy variable .Like smoothing and flexibility.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2025 06:25:00 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2025-02-26T06:25:00Z</dc:date>
    <item>
      <title>MAX IV Value for a continuous variable</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/MAX-IV-Value-for-a-continuous-variable/m-p/960128#M4291</link>
      <description>&lt;P&gt;I have a continuous variable like : INCOME or DURATION.&lt;/P&gt;
&lt;P&gt;I need to split it into several groups by using several cutpoints.&lt;/P&gt;
&lt;P&gt;two cutpoints would yield three groups, three would be four groups .............&lt;/P&gt;
&lt;P&gt;Attachment is a test data/excel.&lt;/P&gt;
&lt;PRE&gt;Data looks like this,I want to generate a GROUP variable:
Here I have a cutpoint &lt;STRONG&gt;DURATION=12&lt;/STRONG&gt; ,that could split&lt;STRONG&gt; DURATION (a continuous variable)&lt;/STRONG&gt; into TWO groups.
But if you have &lt;STRONG&gt;TWO cutpoints&lt;/STRONG&gt;,you would yield &lt;STRONG&gt;THREE groups&lt;/STRONG&gt;, &lt;STRONG&gt;THREE cutpoints&lt;/STRONG&gt; yield &lt;STRONG&gt;FOUR groups&lt;/STRONG&gt;........


good_bad  group  duration
good        1     2
bad         1     4
good        1     5
good        1     6
bad         1     8
good        1     10

good        2     18
good        2     28
bad         2     30
bad         2     32






total_n_bad=4   total_n_good=6

group=1
--------
n_bad=2 n_good=4 
bad_dist=n_bad/total_n_bad=2/4=0.5 
good_dist=n_good/total_n_good=4/6=0.667
woe=(Bad_Dist-Good_Dist)*log(Bad_Dist/Good_Dist)=(0.5-0.667)*log(0.5/0.667)=0.048


group=2 
--------
n_bad=2 n_good=2
bad_dist=n_bad/total_n_bad=2/4=0.5 
good_dist=n_good/total_n_good=2/6=0.333
woe=(Bad_Dist-Good_Dist)*log(Bad_Dist/Good_Dist)=(0.5-0.333)*log(0.5/0.333)=0.068


iv=0.048 + 0.068 = 0.116  &lt;STRONG&gt; &amp;lt;----- I want to maximize this iv .&lt;/STRONG&gt;



And I also have &lt;STRONG&gt;THREE constraints&lt;/STRONG&gt;:
group=1
--------
&lt;STRONG&gt;Bad_Dist&amp;gt;0.05 and Good_Dist&amp;gt;0.05&lt;/STRONG&gt;

group=2
--------
&lt;STRONG&gt;Bad_Dist&amp;gt;0.05 and Good_Dist&amp;gt;0.05&lt;/STRONG&gt;

to avoid "If n_good[g] = 0, then good_dist[g] = 0, yielding a division by zero"



&lt;STRONG&gt;woe[1]&amp;lt;woe[2]&amp;lt;woe[3]&amp;lt;woe[4]...........
or
woe[1]&amp;gt;woe[2]&amp;gt;woe[3]&amp;gt;woe[4]...........
a.k.a &lt;FONT color="#FF0000"&gt;woe is monotonic&lt;/FONT&gt; .&lt;/STRONG&gt;




P.S.
The group could be 3,4,5,6,7,8,9,10.....
and pick up the max IV from these group.
E.X.  group=8 have the max IV when group in (2 3 4 5 6 7 8 9 10).&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Here is an example used by my GA code for the test data(attachment):&lt;/SPAN&gt;&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-1740448604991.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104914iE5A391986B67CA7E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1740448604991.png" alt="Ksharp_0-1740448604991.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 01:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/MAX-IV-Value-for-a-continuous-variable/m-p/960128#M4291</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-02-25T01:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: MAX IV Value for a continuous variable</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/MAX-IV-Value-for-a-continuous-variable/m-p/960192#M4293</link>
      <description>&lt;P&gt;The OPTBINNING procedure solves this problem:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_060/casml/casml_optbinning_toc.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/v_060/casml/casml_optbinning_toc.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As the Overview section mentions, a shortest path approach is used under the hood, but I cannot share the details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are a couple of related posts, each of which has links to others:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://communities.sas.com/t5/Mathematical-Optimization/Trying-to-use-PROC-OPTMODEL-for-monotonic-supervised-optimal/td-p/553822" target="_blank"&gt;https://communities.sas.com/t5/Mathematical-Optimization/Trying-to-use-PROC-OPTMODEL-for-monotonic-supervised-optimal/td-p/553822&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Binning-categorize-continuous-var-into-categories/td-p/936719" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Binning-categorize-continuous-var-into-categories/td-p/936719&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 25 Feb 2025 21:44:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/MAX-IV-Value-for-a-continuous-variable/m-p/960192#M4293</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2025-02-25T21:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: MAX IV Value for a continuous variable</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/MAX-IV-Value-for-a-continuous-variable/m-p/960210#M4295</link>
      <description>&lt;P&gt;RobPratt,&lt;/P&gt;
&lt;P&gt;Unfortunately,&amp;nbsp;&lt;SPAN&gt;The OPTBINNING procedure&amp;nbsp; is running under SAS/Viya , I don't have it. My sas is a stand-alone PC version.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And it looks like PROC OPTBINNING need set up some parameters(cutpoints ,woe,lower bound, upper bound, and WOE trend &amp;lt;-- what does it mean? ) firstly .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I need the code like your posted before for binning categroy variable .Like smoothing and flexibility.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 06:25:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/MAX-IV-Value-for-a-continuous-variable/m-p/960210#M4295</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-02-26T06:25:00Z</dc:date>
    </item>
  </channel>
</rss>

