Giter Site home page Giter Site logo

Decision Trees about scoruby HOT 14 CLOSED

asafschers avatar asafschers commented on May 31, 2024
Decision Trees

from scoruby.

Comments (14)

pts-owentran avatar pts-owentran commented on May 31, 2024 1

It's looking good, I tried test with the 8 fields from the data dictionary and it passes...

    it 'scores against data dictionary' do
      features = {
        ean_base_points: 1850,
        earn_bonus_points: 0,
        star_rating: 5,
        cost_per_star: 38.8,
        base_points_per_star: 370,
        ppd: 9.536082,
        percent_margin: 0.226134,
        booked: 0
      }
      expect(decision_tree.decide(features).score_distribution).to eq(
        {"0"=>"0.999513428516638", "1"=>"0.000486571483361926"}
      )

I'll see what happens on larger data sets. Thanks so much!

from scoruby.

pts-owentran avatar pts-owentran commented on May 31, 2024 1

Thanks! Works well. Closing this out. Have a great weekend!

from scoruby.

asafschers avatar asafschers commented on May 31, 2024

Sure, can you please send me an example PMML file, so I could develop and test by it?
Just want to make sure our environments produce the same PMML structure first.
Thanks!

from scoruby.

pts-owentran avatar pts-owentran commented on May 31, 2024

Of course, will get a sample PMML file using a decision tree with a test set for you in a few days. Thanks!

from scoruby.

pts-owentran avatar pts-owentran commented on May 31, 2024
<?xml version="1.0" encoding="UTF-8"?>
<PMML xmlns="http://www.dmg.org/PMML-4_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="4.1" xsi:schemaLocation="http://www.dmg.org/PMML-4_1 pmml-4-1.xsd">
   <Header copyright="Copyright(c) SPSS Inc. 1989-2009. All rights reserved.">
      <Application name="IBM SPSS Modeler Common" version="16.0.0.0" />
      <Timestamp />
   </Header>
   <DataDictionary numberOfFields="8">
      <DataField name="earn_base_points" displayName="earn_base_points" optype="continuous" isCyclic="0" dataType="double" />
      <DataField name="earn_bonus_points" displayName="earn_bonus_points" optype="continuous" isCyclic="0" dataType="double" />
      <DataField name="star_rating" displayName="star_rating" optype="ordinal" isCyclic="0" dataType="double">
         <Value value="0" displayValue="0.0" property="valid" />
         <Value value="1" displayValue="1.0" property="valid" />
         <Value value="2" displayValue="2.0" property="valid" />
         <Value value="2.5" displayValue="2.5" property="valid" />
         <Value value="3" displayValue="3.0" property="valid" />
         <Value value="3.5" displayValue="3.5" property="valid" />
         <Value value="4" displayValue="4.0" property="valid" />
         <Value value="4.5" displayValue="4.5" property="valid" />
         <Value value="5" displayValue="5.0" property="valid" />
      </DataField>
      <DataField name="cost_per_star" displayName="cost_per_star" optype="continuous" isCyclic="0" dataType="double" />
      <DataField name="base_points_per_star" displayName="base_points_per_star" optype="continuous" isCyclic="0" dataType="double" />
      <DataField name="ppd" displayName="ppd" optype="continuous" isCyclic="0" dataType="double" />
      <DataField name="percent_margin" displayName="percent_margin" optype="continuous" isCyclic="0" dataType="double" />
      <DataField name="booked" displayName="booked" optype="categorical" isCyclic="0" dataType="double">
         <Value value="0" displayValue="0" property="valid" />
         <Value value="1" displayValue="1" property="valid" />
      </DataField>
   </DataDictionary>
   <TreeModel algorithmName="CHAID" functionName="classification">
      <Extension extender="spss.com">
         <X-risk value="0.000396687269211734" />
         <X-seOfRisk value="2.98920999964765e-006" />
      </Extension>
      <MiningSchema>
         <MiningField name="ppd" usageType="active" />
         <MiningField name="booked" usageType="predicted" />
      </MiningSchema>
      <ModelStats>
         <UnivariateStats field="ppd">
            <Counts totalFreq="44377527" missingFreq="0" invalidFreq="0" />
            <NumericInfo minimum="0" maximum="9" />
         </UnivariateStats>
      </ModelStats>
      <Node score="0" recordCount="44377527" id="0" defaultChild="1">
         <Extension>
            <X-Node>
               <X-NodeStats chiSquare="755.26373485444" adjPValue="3.5716285536446e-163" df1="2" />
            </X-Node>
         </Extension>
         <True />
         <ScoreDistribution recordCount="44359923" value="0" probability="0.999603312730788" confidence="0.999603312730788">
            <Extension extender="spss.com" name="probability" value="0.999603312730788" />
         </ScoreDistribution>
         <ScoreDistribution recordCount="17604" value="1" probability="0.000396687269211734" confidence="0.000396687269211734">
            <Extension extender="spss.com" name="probability" value="0.000396687269211734" />
         </ScoreDistribution>
         <Node score="0" recordCount="17750732" id="1">
            <CompoundPredicate booleanOperator="surrogate">
               <CompoundPredicate booleanOperator="and">
                  <True />
                  <SimplePredicate field="ppd" operator="lessOrEqual" value="16.0918513223731" />
               </CompoundPredicate>
               <True />
            </CompoundPredicate>
            <ScoreDistribution recordCount="17742095" value="0" probability="0.999513428516638" confidence="0.999513428516638">
               <Extension extender="spss.com" name="probability" value="0.999513428516638" />
            </ScoreDistribution>
            <ScoreDistribution recordCount="8637" value="1" probability="0.000486571483361926" confidence="0.000486571483361926">
               <Extension extender="spss.com" name="probability" value="0.000486571483361926" />
            </ScoreDistribution>
         </Node>
         <Node score="0" recordCount="13313561" id="2">
            <CompoundPredicate booleanOperator="surrogate">
               <CompoundPredicate booleanOperator="and">
                  <SimplePredicate field="ppd" operator="greaterThan" value="16.0918513223731" />
                  <SimplePredicate field="ppd" operator="lessOrEqual" value="28.6885245901639" />
               </CompoundPredicate>
               <False />
            </CompoundPredicate>
            <ScoreDistribution recordCount="13308443" value="0" probability="0.999615579933873" confidence="0.999615579933873">
               <Extension extender="spss.com" name="probability" value="0.999615579933873" />
            </ScoreDistribution>
            <ScoreDistribution recordCount="5118" value="1" probability="0.000384420066126561" confidence="0.000384420066126561">
               <Extension extender="spss.com" name="probability" value="0.000384420066126561" />
            </ScoreDistribution>
         </Node>
         <Node score="0" recordCount="13313234" id="3">
            <CompoundPredicate booleanOperator="surrogate">
               <CompoundPredicate booleanOperator="and">
                  <SimplePredicate field="ppd" operator="greaterThan" value="28.6885245901639" />
                  <True />
               </CompoundPredicate>
               <False />
            </CompoundPredicate>
            <ScoreDistribution recordCount="13309385" value="0" probability="0.999710889179894" confidence="0.999710889179894">
               <Extension extender="spss.com" name="probability" value="0.999710889179894" />
            </ScoreDistribution>
            <ScoreDistribution recordCount="3849" value="1" probability="0.000289110820105768" confidence="0.000289110820105768">
               <Extension extender="spss.com" name="probability" value="0.000289110820105768" />
            </ScoreDistribution>
         </Node>
      </Node>
      <Extension>
         <X-TreeModel>
            <X-Priors>
               <X-Prior-Value targetCategory="0" value="0.999603312730788" />
               <X-Prior-Value targetCategory="1" value="0.000396687269211734" />
            </X-Priors>
         </X-TreeModel>
      </Extension>
   </TreeModel>
</PMML>

from scoruby.

pts-owentran avatar pts-owentran commented on May 31, 2024

Here's sample scoring data:

search_id,hotel_id,supplier,position,avg_rate,gross_margin_usd,earn_base_points,earn_bonus_points,spend_points,total,spend_cash,surcharge_total,retail_rate,session_id,ean_id,star_rating,booked,cost_per_star,base_points_per_star,ppd,percent_margin,$R-booked,$RC-booked,$RRP-booked
"bd8e2763-0b7d-451a-afac-6dabfc377253",235246,"T0_EUR",26,194,43.870000,1850,0,0,"","","","","0000198de06865cdf984e018fbee766e",235246,5.000000,0,38.800000,370.000000,9.536082,0.226134,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",260233,"EMN",7,82,22.690000,1225,0,0,"","","","","0000198de06865cdf984e018fbee766e",260233,3.500000,0,23.428571,350.000000,14.939024,0.276707,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",396703,"EMN",15,170,38.430000,1675,0,0,"","","","","0000198de06865cdf984e018fbee766e",396703,4.000000,0,42.500000,418.750000,9.852941,0.226059,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",447673,"T0_EUR",16,311,70.220000,2650,0,0,"","","","","0000198de06865cdf984e018fbee766e",447673,5.000000,0,62.200000,530.000000,8.520900,0.225788,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",448669,"EMN",19,83,18.660000,1075,0,0,"","","","","0000198de06865cdf984e018fbee766e",448669,3.500000,0,23.714286,307.142857,12.951807,0.224819,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",466110,"EMN",20,164,37.000000,1625,0,0,"","","","","0000198de06865cdf984e018fbee766e",466110,4.000000,0,41.000000,406.250000,9.908537,0.225610,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",470025,"EMN",17,80,18.070000,1050,0,0,"","","","","0000198de06865cdf984e018fbee766e",470025,3.000000,0,26.666667,350.000000,13.125000,0.225875,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",481533,"EMN",2,145,68.860000,2800,0,0,"","","","","0000198de06865cdf984e018fbee766e",481533,4.500000,0,32.222222,622.222222,19.310345,0.474897,0,0.999616,0.000384
"bd8e2763-0b7d-451a-afac-6dabfc377253",483617,"EMN",9,85,19.080000,1075,0,0,"","","","","0000198de06865cdf984e018fbee766e",483617,3.500000,0,24.285714,307.142857,12.647059,0.224471,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",485154,"GR",14,90,20.220000,1125,0,0,"","","","","0000198de06865cdf984e018fbee766e",485154,3.500000,0,25.714286,321.428571,12.500000,0.224667,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",485180,"EMN",10,81,18.340000,1075,0,0,"","","","","0000198de06865cdf984e018fbee766e",485180,3.500000,0,23.142857,307.142857,13.271605,0.226420,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",486868,"EMN",18,102,23.050000,1200,0,0,"","","","","0000198de06865cdf984e018fbee766e",486868,4.000000,0,25.500000,300.000000,11.764706,0.225980,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",487993,"EMN",6,118,26.560000,1325,0,0,"","","","","0000198de06865cdf984e018fbee766e",487993,3.500000,0,33.714286,378.571429,11.228814,0.225085,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",488465,"EMN",3,136,39.190000,1750,0,0,"","","","","0000198de06865cdf984e018fbee766e",488465,4.000000,0,34.000000,437.500000,12.867647,0.288162,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",490481,"EMN",8,88,19.850000,1100,0,0,"","","","","0000198de06865cdf984e018fbee766e",490481,3.000000,0,29.333333,366.666667,12.500000,0.225568,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",513875,"EMN",27,129,29.110000,1400,0,0,"","","","","0000198de06865cdf984e018fbee766e",513875,4.000000,0,32.250000,350.000000,10.852713,0.225659,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",542181,"EMN",23,89,20.110000,1125,0,0,"","","","","0000198de06865cdf984e018fbee766e",542181,3.000000,0,29.666667,375.000000,12.640449,0.225955,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",547385,"EMN",11,82,18.530000,1075,0,0,"","","","","0000198de06865cdf984e018fbee766e",547385,4.000000,0,20.500000,268.750000,13.109756,0.225976,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",550524,"EMN",21,82,18.530000,1075,0,0,"","","","","0000198de06865cdf984e018fbee766e",550524,3.000000,0,27.333333,358.333333,13.109756,0.225976,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",554280,"EMN",1,336,75.720000,2825,0,0,"","","","","0000198de06865cdf984e018fbee766e",554280,5.000000,0,67.200000,565.000000,8.407738,0.225357,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",555458,"EMN",25,139,31.440000,1475,0,0,"","","","","0000198de06865cdf984e018fbee766e",555458,4.000000,0,34.750000,368.750000,10.611511,0.226187,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",556117,"EMN",4,114,28.230000,1375,0,0,"","","","","0000198de06865cdf984e018fbee766e",556117,4.000000,0,28.500000,343.750000,12.061404,0.247632,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",566152,"EMN",12,80,18.140000,1050,0,0,"","","","","0000198de06865cdf984e018fbee766e",566152,4.000000,0,20.000000,262.500000,13.125000,0.226750,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",592373,"EMN",24,174,39.300000,1700,0,0,"","","","","0000198de06865cdf984e018fbee766e",592373,4.500000,0,38.666667,377.777778,9.770115,0.225862,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",603804,"EMN",22,103,23.290000,1225,0,0,"","","","","0000198de06865cdf984e018fbee766e",603804,4.000000,0,25.750000,306.250000,11.893204,0.226117,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",610915,"EMN",5,123,27.650000,1350,0,0,"","","","","0000198de06865cdf984e018fbee766e",610915,3.000000,0,41.000000,450.000000,10.975610,0.224797,0,0.999513,0.000487
"bd8e2763-0b7d-451a-afac-6dabfc377253",613096,"EMN",13,85,19.120000,1075,0,0,"","","","","0000198de06865cdf984e018fbee766e",613096,4.000000,0,21.250000,268.750000,12.647059,0.224941,0,0.999513,0.000487
"063bba55-d755-49c9-9c76-6df14eaa76b4",105506,"EMN",119,302,424.550000,15550,0,0,"","","","","00002ecdf98e324effc96031bdebc180",105506,4.000000,0,75.500000,3887.500000,51.490066,1.405795,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",105507,"T0_EUR",20,303,425.420000,15575,0,0,"","","","","00002ecdf98e324effc96031bdebc180",105507,4.000000,0,75.750000,3893.750000,51.402640,1.404026,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",105509,"EMC",79,198,149.050000,6775,0,0,"","","","","00002ecdf98e324effc96031bdebc180",105509,4.000000,0,49.500000,1693.750000,34.217172,0.752778,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",105991,"EMC",12,240,256.970000,10200,0,0,"","","","","00002ecdf98e324effc96031bdebc180",105991,5.000000,0,48.000000,2040.000000,42.500000,1.070708,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",105992,"EMN",146,256,358.920000,13625,0,0,"","","","","00002ecdf98e324effc96031bdebc180",105992,4.000000,0,64.000000,3406.250000,53.222656,1.402031,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",105996,"EMN",47,176,247.160000,10300,0,0,"","","","","00002ecdf98e324effc96031bdebc180",105996,4.000000,0,44.000000,2575.000000,58.522727,1.404318,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",106034,"EMC",21,430,432.980000,14975,0,0,"","","","","00002ecdf98e324effc96031bdebc180",106034,5.000000,0,86.000000,2995.000000,34.825581,1.006930,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",106275,"EMC",46,245,253.860000,10075,0,0,"","","","","00002ecdf98e324effc96031bdebc180",106275,4.000000,0,61.250000,2518.750000,41.122449,1.036163,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",106277,"EMC",190,198,159.590000,7150,0,0,"","","","","00002ecdf98e324effc96031bdebc180",106277,4.000000,0,49.500000,1787.500000,36.111111,0.806010,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",106311,"EMC",19,296,260.790000,9950,0,0,"","","","","00002ecdf98e324effc96031bdebc180",106311,5.000000,0,59.200000,1990.000000,33.614865,0.881047,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",107002,"EMC",36,196,173.200000,7625,0,0,"","","","","00002ecdf98e324effc96031bdebc180",107002,4.500000,0,43.555556,1694.444444,38.903061,0.883673,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",107066,"EMC",60,302,242.320000,9275,0,0,"","","","","00002ecdf98e324effc96031bdebc180",107066,4.000000,0,75.500000,2318.750000,30.711921,0.802384,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",107090,"EMN",118,217,304.050000,12000,0,0,"","","","","00002ecdf98e324effc96031bdebc180",107090,4.000000,0,54.250000,3000.000000,55.299539,1.401152,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",107642,"EMC",74,215,189.880000,8075,0,0,"","","","","00002ecdf98e324effc96031bdebc180",107642,4.000000,0,53.750000,2018.750000,37.558140,0.883163,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",109081,"EMC",176,214,208.850000,8725,0,0,"","","","","00002ecdf98e324effc96031bdebc180",109081,4.000000,0,53.500000,2181.250000,40.771028,0.975935,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",113142,"T0_EUR",3,359,504.090000,17900,0,0,"","","","","00002ecdf98e324effc96031bdebc180",113142,5.000000,0,71.800000,3580.000000,49.860724,1.404150,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",113603,"EMC",187,161,149.710000,7050,0,0,"","","","","00002ecdf98e324effc96031bdebc180",113603,3.000000,0,53.666667,2350.000000,43.788820,0.929876,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",114179,"EMC",69,262,247.640000,9725,0,0,"","","","","00002ecdf98e324effc96031bdebc180",114179,4.000000,0,65.500000,2431.250000,37.118321,0.945191,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",114183,"EMC",61,229,172.440000,7375,0,0,"","","","","00002ecdf98e324effc96031bdebc180",114183,4.000000,0,57.250000,1843.750000,32.205240,0.753013,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",114186,"EMN",104,239,335.350000,12925,0,0,"","","","","00002ecdf98e324effc96031bdebc180",114186,4.000000,0,59.750000,3231.250000,54.079498,1.403138,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",114196,"EMC",44,296,316.770000,11875,0,0,"","","","","00002ecdf98e324effc96031bdebc180",114196,4.000000,0,74.000000,2968.750000,40.118243,1.070169,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",114203,"EMN",7,206,289.070000,11550,0,0,"","","","","00002ecdf98e324effc96031bdebc180",114203,3.500000,0,58.857143,3300.000000,56.067961,1.403252,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",114408,"EMN",91,239,335.280000,12925,0,0,"","","","","00002ecdf98e324effc96031bdebc180",114408,4.500000,0,53.111111,2872.222222,54.079498,1.402845,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",114409,"EMN",38,198,278.700000,11250,0,0,"","","","","00002ecdf98e324effc96031bdebc180",114409,4.000000,0,49.500000,2812.500000,56.818182,1.407576,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",114512,"EMN",153,295,413.660000,15225,0,0,"","","","","00002ecdf98e324effc96031bdebc180",114512,4.000000,0,73.750000,3806.250000,51.610169,1.402237,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",114513,"EMC",28,311,274.010000,10300,0,0,"","","","","00002ecdf98e324effc96031bdebc180",114513,5.000000,0,62.200000,2060.000000,33.118971,0.881061,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",114658,"T0_EUR",193,379,532.750000,18750,0,0,"","","","","00002ecdf98e324effc96031bdebc180",114658,4.000000,0,94.750000,4687.500000,49.472296,1.405673,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",114929,"EMN",30,325,456.730000,16500,0,0,"","","","","00002ecdf98e324effc96031bdebc180",114929,4.000000,0,81.250000,4125.000000,50.769231,1.405323,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",115066,"EMN",1,737,1034.660000,33600,0,0,"","","","","00002ecdf98e324effc96031bdebc180",115066,5.000000,0,147.400000,6720.000000,45.590231,1.403881,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",115090,"T0_EUR",115,328,460.030000,16600,0,0,"","","","","00002ecdf98e324effc96031bdebc180",115090,5.000000,0,65.600000,3320.000000,50.609756,1.402530,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",116903,"EMC",133,391,357.290000,12625,0,0,"","","","","00002ecdf98e324effc96031bdebc180",116903,4.000000,0,97.750000,3156.250000,32.289003,0.913785,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",117116,"EMC",70,251,259.950000,10225,0,0,"","","","","00002ecdf98e324effc96031bdebc180",117116,4.000000,0,62.750000,2556.250000,40.737052,1.035657,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",117617,"T0_EUR",5,347,487.690000,17425,0,0,"","","","","00002ecdf98e324effc96031bdebc180",117617,5.000000,0,69.400000,3485.000000,50.216138,1.405447,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",118948,"EMN",50,206,289.070000,11550,0,0,"","","","","00002ecdf98e324effc96031bdebc180",118948,4.000000,0,51.500000,2887.500000,56.067961,1.403252,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",119468,"EMC",183,173,163.110000,7425,0,0,"","","","","00002ecdf98e324effc96031bdebc180",119468,3.000000,0,57.666667,2475.000000,42.919075,0.942832,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",120639,"EMN",159,254,384.410000,14500,0,0,"","","","","00002ecdf98e324effc96031bdebc180",120639,4.000000,0,63.500000,3625.000000,57.086614,1.513425,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",121279,"EMN",157,190,266.760000,10900,0,0,"","","","","00002ecdf98e324effc96031bdebc180",121279,3.000000,0,63.333333,3633.333333,57.368421,1.404000,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",122647,"EMC",138,201,171.260000,7525,0,0,"","","","","00002ecdf98e324effc96031bdebc180",122647,4.000000,0,50.250000,1881.250000,37.437811,0.852040,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",122649,"EMC",105,231,197.000000,8200,0,0,"","","","","00002ecdf98e324effc96031bdebc180",122649,4.000000,0,57.750000,2050.000000,35.497835,0.852814,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",122650,"EMC",23,249,211.920000,8600,0,0,"","","","","00002ecdf98e324effc96031bdebc180",122650,5.000000,0,49.800000,1720.000000,34.538153,0.851084,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",122651,"EMC",98,227,192.950000,8100,0,0,"","","","","00002ecdf98e324effc96031bdebc180",122651,4.000000,0,56.750000,2025.000000,35.682819,0.850000,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",123193,"EMC",33,331,333.680000,12225,0,0,"","","","","00002ecdf98e324effc96031bdebc180",123193,5.000000,0,66.200000,2445.000000,36.933535,1.008097,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",124023,"T0_EUR",129,266,374.070000,14075,0,0,"","","","","00002ecdf98e324effc96031bdebc180",124023,4.000000,0,66.500000,3518.750000,52.913534,1.406278,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",124179,"EMC",32,235,188.680000,7875,0,0,"","","","","00002ecdf98e324effc96031bdebc180",124179,4.000000,0,58.750000,1968.750000,33.510638,0.802894,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",124508,"T0_EUR",162,167,293.150000,11950,0,0,"","","","","00002ecdf98e324effc96031bdebc180",124508,4.000000,0,41.750000,2987.500000,71.556886,1.755389,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",129112,"EMN",67,372,522.210000,18450,0,0,"","","","","00002ecdf98e324effc96031bdebc180",129112,5.000000,0,74.400000,3690.000000,49.596774,1.403790,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",129344,"EMC",40,337,297.800000,10950,0,0,"","","","","00002ecdf98e324effc96031bdebc180",129344,5.000000,0,67.400000,2190.000000,32.492582,0.883680,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",130199,"EMC",186,213,198.770000,8375,0,0,"","","","","00002ecdf98e324effc96031bdebc180",130199,4.000000,0,53.250000,2093.750000,39.319249,0.933192,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",130640,"EMC",49,212,180.070000,7750,0,0,"","","","","00002ecdf98e324effc96031bdebc180",130640,4.000000,0,53.000000,1937.500000,36.556604,0.849387,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",132436,"EMC",127,333,293.500000,10825,0,0,"","","","","00002ecdf98e324effc96031bdebc180",132436,5.000000,0,66.600000,2165.000000,32.507508,0.881381,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",136493,"EMC",161,226,234.330000,9525,0,0,"","","","","00002ecdf98e324effc96031bdebc180",136493,5.000000,0,45.200000,1905.000000,42.146018,1.036858,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",137914,"EMC",102,137,125.240000,6375,0,0,"","","","","00002ecdf98e324effc96031bdebc180",137914,3.500000,0,39.142857,1821.428571,46.532847,0.914161,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",141166,"T0_EUR",113,355,687.820000,24275,0,0,"","","","","00002ecdf98e324effc96031bdebc180",141166,5.000000,0,71.000000,4855.000000,68.380282,1.937521,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",141423,"EMN",73,318,445.940000,16200,0,0,"","","","","00002ecdf98e324effc96031bdebc180",141423,5.000000,0,63.600000,3240.000000,50.943396,1.402327,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",144800,"EMC",181,146,133.480000,6600,0,0,"","","","","00002ecdf98e324effc96031bdebc180",144800,4.000000,0,36.500000,1650.000000,45.205479,0.914247,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",145127,"EMC",55,535,605.350000,20200,0,0,"","","","","00002ecdf98e324effc96031bdebc180",145127,5.000000,0,107.000000,4040.000000,37.757009,1.131495,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",150368,"EMC",58,130,134.380000,6750,0,0,"","","","","00002ecdf98e324effc96031bdebc180",150368,4.000000,0,32.500000,1687.500000,51.923077,1.033692,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",150369,"EMN",31,235,329.900000,12750,0,0,"","","","","00002ecdf98e324effc96031bdebc180",150369,4.000000,0,58.750000,3187.500000,54.255319,1.403830,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",150583,"EMC",130,167,152.980000,7125,0,0,"","","","","00002ecdf98e324effc96031bdebc180",150583,3.000000,0,55.666667,2375.000000,42.664671,0.916048,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",151409,"EMC",196,178,142.390000,6675,0,0,"","","","","00002ecdf98e324effc96031bdebc180",151409,3.000000,0,59.333333,2225.000000,37.500000,0.799944,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",160988,"EMN",89,185,260.020000,10700,0,0,"","","","","00002ecdf98e324effc96031bdebc180",160988,4.000000,0,46.250000,2675.000000,57.837838,1.405514,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",163512,"EMC",107,232,219.420000,8975,0,0,"","","","","00002ecdf98e324effc96031bdebc180",163512,4.000000,0,58.000000,2243.750000,38.685345,0.945776,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",163523,"EMN",63,165,232.080000,9875,0,0,"","","","","00002ecdf98e324effc96031bdebc180",163523,3.500000,0,47.142857,2821.428571,59.848485,1.406545,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",163540,"EMC",148,562,513.410000,16825,0,0,"","","","","00002ecdf98e324effc96031bdebc180",163540,3.000000,0,187.333333,5608.333333,29.937722,0.913541,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",164601,"EMC",94,429,391.670000,13550,0,0,"","","","","00002ecdf98e324effc96031bdebc180",164601,4.500000,0,95.333333,3011.111111,31.585082,0.912984,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",164604,"EMC",92,306,279.250000,10525,0,0,"","","","","00002ecdf98e324effc96031bdebc180",164604,5.000000,0,61.200000,2105.000000,34.395425,0.912582,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",164989,"EMC",16,465,454.140000,15450,0,0,"","","","","00002ecdf98e324effc96031bdebc180",164989,5.000000,0,93.000000,3090.000000,33.225806,0.976645,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",169092,"EMC",75,363,410.860000,14675,0,0,"","","","","00002ecdf98e324effc96031bdebc180",169092,5.000000,0,72.600000,2935.000000,40.426997,1.131846,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",169262,"EMC",178,324,295.850000,10975,0,0,"","","","","00002ecdf98e324effc96031bdebc180",169262,5.000000,0,64.800000,2195.000000,33.873457,0.913117,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",170309,"EMN",81,176,246.640000,10300,0,0,"","","","","00002ecdf98e324effc96031bdebc180",170309,4.000000,0,44.000000,2575.000000,58.522727,1.401364,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",170486,"EMC",62,251,268.770000,10525,0,0,"","","","","00002ecdf98e324effc96031bdebc180",170486,4.000000,0,62.750000,2631.250000,41.932271,1.070797,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",171131,"EMC",48,182,160.470000,7275,0,0,"","","","","00002ecdf98e324effc96031bdebc180",171131,4.000000,0,45.500000,1818.750000,39.972527,0.881703,0,0.999711,0.000289
"063bba55-d755-49c9-9c76-6df14eaa76b4",171220,"EMC",101,266,210.350000,8425,0,0,"","","","","00002ecdf98e324effc96031bdebc180",171220,4.000000,0,66.500000,2106.250000,31.672932,0.790789,0,0.999711,0.000289

from scoruby.

asafschers avatar asafschers commented on May 31, 2024

Files look good, thanks.
I started working, I'll let you know when it's ready.

from scoruby.

asafschers avatar asafschers commented on May 31, 2024

Deployed Scoruby 0.2.1, should support the PMML you sent.
You can use 'IBM SPSS decision tree' spec as reference.
Still need to add specs, handle missing values and add usage instructions.
Please contact me if any issue arises :)

from scoruby.

pts-owentran avatar pts-owentran commented on May 31, 2024

Hi.
I loaded up a new PMML file decision_tree_v2.pmml.txt and when cost_per_star is greater than 49.2 I get the following error:

E, [2017-07-19T22:39:55.844743 #15936] ERROR -- Scoruby: Null tree: , bad feature: [[:cost_per_star, :cost_per_star], nil]

I can also get the error by changing different values for ppd and other feature attributes. Could there be an issue with how the branches are written?

Thanks,
Owen

To reproduce:

  1. Copy the decision_tree_v2.pmml.txt to spec/fixtures/decision_tree_v2.pmml
  2. Run the following spec
  context 'IBM SPSS decision tree' do

    let(:tree_file) {'spec/fixtures/decision_tree_v2.pmml'}
    let(:tree_xml) {Scoruby.xml_from_file_path(tree_file)}
    let(:decision_tree) {DecisionTree.new(tree_xml.child)}

    it 'scores against data dictionary' do
      features = {
        ean_base_points:      3400.0,
        star_rating:          4.5,
        cost_per_star:        146.54, # change to 49.2 to work
        base_points_per_star: 755.56,
        ppd:                  5.16,
        percent_margin:       0.15,
      }
      expect(decision_tree.decide(features).score_distribution).to eq(
        {"0" => "0.999528329990269", "1" => "0.000471670009731297"}
      )
    end
end

It will error out with

E, [2017-07-19T22:56:14.595228 #16161] ERROR -- Scoruby: Null tree: , bad feature: [[nil, :cost_per_star], nil]

If you set the cost_per_star to less than 49.2 it will work.

from scoruby.

pts-owentran avatar pts-owentran commented on May 31, 2024

Here's a screen shot of where the error is happening for cost_per_star > 49.2

screen shot 2017-07-20 at 9 21 58 am

from scoruby.

asafschers avatar asafschers commented on May 31, 2024

Found the issue, my trees didn't support more than 3 children.
Added support for 5 children for now, still need to generalize and DRY code.
Spec will still fail due to rounding issue.

from scoruby.

pts-owentran avatar pts-owentran commented on May 31, 2024

Made a PR for 10 children #5

from scoruby.

asafschers avatar asafschers commented on May 31, 2024

Merged, thanks! will generalize soon.

from scoruby.

asafschers avatar asafschers commented on May 31, 2024

Released 0.2.4, should handle any number of children.
Please tell me if it works.
Thanks :)

from scoruby.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.