如何在pmml中引用派生字段的输出字段
how to refer outputfield from derivedfield in pmml
我的 pmml 中有派生字段,我想将它们用作输出字段。所以我想引用派生字段的输出字段。但是 sas 应用程序抛出错误。错误是:
ERROR: Variable Z_DD_OCCUPATION_ID is not defined.
如何从派生字段设置输出字段?
这是我的 pmml,它不起作用
<?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>
如果我使用数据字典列而不是派生字段,它会完美地工作。
例如如果我转换
<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>
至
<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>
有效。因为在这种情况下,我从数据字典列中引用输出字段。但实际上我需要在输出字段中使用派生字段。我如何从派生字段引用输出字段?
您需要将派生字段从 LocalTransformations
(即本地范围)移动到 TransformationDictionary
(即全球范围)。
PMML 4.2 不允许从输出字段引用本地派生字段。 "logic" 是您不能在 PMML 解析器看到某个字段之前引用该字段。在您的示例中,OutputField@name=out_1
元素出现在 DerivedField@name=Z_DD_OCCUPATION_ID
元素之前。
PMML 4.3 放宽了这条规则。有关详细信息,请参阅 http://mantis.dmg.org/view.php?id=142。
我的 pmml 中有派生字段,我想将它们用作输出字段。所以我想引用派生字段的输出字段。但是 sas 应用程序抛出错误。错误是:
ERROR: Variable Z_DD_OCCUPATION_ID is not defined.
如何从派生字段设置输出字段? 这是我的 pmml,它不起作用
<?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>
如果我使用数据字典列而不是派生字段,它会完美地工作。
例如如果我转换
<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>
至
<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>
有效。因为在这种情况下,我从数据字典列中引用输出字段。但实际上我需要在输出字段中使用派生字段。我如何从派生字段引用输出字段?
您需要将派生字段从 LocalTransformations
(即本地范围)移动到 TransformationDictionary
(即全球范围)。
PMML 4.2 不允许从输出字段引用本地派生字段。 "logic" 是您不能在 PMML 解析器看到某个字段之前引用该字段。在您的示例中,OutputField@name=out_1
元素出现在 DerivedField@name=Z_DD_OCCUPATION_ID
元素之前。
PMML 4.3 放宽了这条规则。有关详细信息,请参阅 http://mantis.dmg.org/view.php?id=142。