0

I have derivedfields in my pmml I want to use them as outputfields. So I want to refer outputfield from derivedfield. But sas application throw an error. Error is :

ERROR: Variable Z_DD_OCCUPATION_ID is not defined.

How can I set outputfield from derived field? Here is my pmml which doesn't work

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

  <PMML version="4.2"

   xmlns="http://www.dmg.org/PMML-4_2"

   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <Header copyright="Copyright(c) 2002 SAS Institute Inc., Cary, NC, USA. All Rights Reserved.">

    <Application name="SAS(r)" version="9.4"/>

    <Timestamp>2016-06-23 15:36:04</Timestamp>

    </Header>

    <DataDictionary numberOfFields="26">

      <DataField name="CH_INT_FLG_CRR" optype="continuous" dataType="double"/>

      <DataField name="TD_SALE_FLG_00M_5" optype="categorical" dataType="string"/>

      <DataField name="TARGET_NUM" optype="categorical" dataType="double"/>

    </DataDictionary>

    <TransformationDictionary>

    </TransformationDictionary>

    <RegressionModel functionName="classification" targetFieldName="TARGET_NUM" normalizationMethod="logit">

      <MiningSchema>

        <MiningField name="CH_INT_FLG_CRR" usageType="active" optype="continuous"/>

        <MiningField name="TD_SALE_FLG_00M_5" usageType="active" optype="categorical"/>

        <MiningField name="TARGET_NUM" usageType="target" optype="categorical"/>

      </MiningSchema>

      <Output>

        <OutputField name="I_TARGET_NUM" displayName="Into: TARGET_NUM" optype="categorical" dataType="string" targetField="TARGET_NUM" feature="predictedValue"/>

        <OutputField name="U_TARGET_NUM" displayName="Unnormalized Into: TARGET_NUM" optype="categorical" dataType="string" targetField="TARGET_NUM" feature="predictedDisplayValue"/>

        <OutputField name="P_TARGET_NUM1" displayName="Predicted: TARGET_NUM=1" optype="continuous" dataType="double" targetField="TARGET_NUM" feature="probability" value="1"/>

        <OutputField name="P_TARGET_NUM0" displayName="Predicted: TARGET_NUM=0" optype="continuous" dataType="double" targetField="TARGET_NUM" feature="probability" value="0"/>


                <OutputField name="out_1" optype="continuous" dataType="double" feature="transformedValue">
        <FieldRef field="Z_DD_OCCUPATION_ID"/>
    </OutputField>

    <OutputField name="out_2" optype="continuous" dataType="double" feature="transformedValue">
        <FieldRef field="Z_CH_INT_FLG_CRR"/>
    </OutputField>


      </Output>

      <Targets>

        <Target field="TARGET_NUM" optype="categorical">

          <TargetValue value="1" displayValue="1" priorProbability="0.5000049143"/>

          <TargetValue value="0" displayValue="0" priorProbability="0.4999950857"/>

        </Target>

      </Targets>

      <LocalTransformations>

      <DerivedField name="Z_DD_OCCUPATION_ID" displayName="Z_DD_OCCUPATION_ID" optype="continuous" dataType="double" >
        <MapValues  outputColumn="return" defaultValue="99.9">
        <FieldColumnPair  column="condition" field="TD_SALE_FLG_00M_5"/>
        <InlineTable>
        <row>
        <condition>9999</condition>
        <return>-0.0992686543837357</return>
        </row>
        <row>
        <condition>7130</condition>
        <return>-0.010300374749499</return>
        </row>
        </InlineTable>
        </MapValues>
        </DerivedField>


        <DerivedField name="Z_CH_INT_FLG_CRR" displayName="Z_CH_INT_FLG_CRR" optype="continuous" dataType="double">

            <Discretize field="CH_INT_FLG_CRR" >

                <DiscretizeBin binValue="0.0154213834">

                    <Interval closure="openOpen" rightMargin="0"/>

                </DiscretizeBin>

                <DiscretizeBin binValue="-0.025845983">

                    <Interval closure="closedClosed" leftMargin="0" rightMargin="0"/>

                </DiscretizeBin>

                <DiscretizeBin binValue="0.0154213834">

                    <Interval closure="openOpen" leftMargin="0"/>

                </DiscretizeBin>

            </Discretize> 

        </DerivedField>

      </LocalTransformations>

      <RegressionTable intercept="0.0203226371" targetCategory="1">

        <NumericPredictor name="Z_CH_INT_FLG_CRR" coefficient="7.5086455767" />

        <NumericPredictor name="Z_DD_OCCUPATION_ID" coefficient="3.2" />


      </RegressionTable>

      <RegressionTable intercept="0" targetCategory="0"/>

    </RegressionModel>

  </PMML>

If I use datadictionary columns instead of derived fields, it works perfectly.

For example If I convert

    <OutputField name="out_1" optype="continuous" dataType="double" feature="transformedValue">
        <FieldRef field="Z_DD_OCCUPATION_ID"/>
    </OutputField>

    <OutputField name="out_2" optype="continuous" dataType="double" feature="transformedValue">
        <FieldRef field="Z_CH_INT_FLG_CRR"/>
    </OutputField>

to

<OutputField name="out_1" optype="continuous" dataType="double" feature="transformedValue">
    <FieldRef field="TD_SALE_FLG_00M_5"/>
</OutputField>

<OutputField name="out_2" optype="continuous" dataType="double" feature="transformedValue">
    <FieldRef field="CH_INT_FLG_CRR"/>
</OutputField>

it works. Because in this case, I refer outputfield from datadictionary columns. But actually I need to use derivedfields in outputfields. How can I refer outputfields from derivedfields?

neverwinter
  • 810
  • 2
  • 15
  • 42

1 Answers1

1

You need to move your derived fields from LocalTransformations (ie. local scope) to TransformationDictionary (ie. global scope).

PMML 4.2 does not permit referencing local derived fields from output fields. The "logic" is that you cannot reference a field before it has been seen by the PMML parser. In you example, OutputField@name=out_1 element occurs before DerivedField@name=Z_DD_OCCUPATION_ID element.

PMML 4.3 relaxed this rule. See http://mantis.dmg.org/view.php?id=142 for details.

user1808924
  • 4,563
  • 2
  • 17
  • 20