如何在pmml中引用来自derivedfield的outputfield

时间:2016-08-25 12:51:09

标签: sas pmml

我在pmml中有衍生字段我想用它们作为输出字段。所以我想从derivedfield引用outputfield。但sas应用程序抛出错误。错误是:

  

错误:未定义变量Z_DD_OCCUPATION_ID。

如何从派生字段设置outputfield? 这是我的pmml不起作用

$body = @("Helpdesk,") 
$body += "These users have had their passwords reset and their accounts disabled. There is no action required on the part of IT helpdesk, this is strictly to notify you. These users will probably be calling soon:"

$body += $members

如果我使用datadictionary列而不是派生字段,它可以很好地工作。

例如,如果我转换

Send-MailMessage -Body ($body | Out-String) <OtherParameters>

<?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>

它有效。因为在这种情况下,我从datadictionary列引用outputfield。但实际上我需要在outputfields中使用derivedfields。如何从衍生字段中引用输出字段?

1 个答案:

答案 0 :(得分:1)

您需要将派生字段从LocalTransformations(即本地范围)移动到TransformationDictionary(即全局范围)。

PMML 4.2不允许从输出字段引用本地派生字段。 “逻辑”是指在PMML解析器看到之前您无法引用字段。在您的示例中,OutputField@name=out_1元素出现在DerivedField@name=Z_DD_OCCUPATION_ID元素之前。

PMML 4.3放宽了这条规则。有关详细信息,请参阅http://mantis.dmg.org/view.php?id=142