I want to add an additional target ("outputState") to my PMML-Regression modell.
outputState = 0: no missing/invalid input values(-> no imputation in the regression model)
outputState = 1: there are missing/invalid invalid values (->imputation in the regression model)
I tried to work with multiple models but I dont know how to handle multiple models/targets/outputs right.
Example (explanation below):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PMML xmlns="http://www.dmg.org/PMML-4_3" xmlns:data="http://jpmml.org/jpmml-model/InlineTable" version="4.3"><Header><Application name="JPMML-R" version="1.3.14"/><Timestamp>2020-01-07T15:56:07Z</Timestamp></Header>
<DataDictionary>
<DataField name="outputState" optype="categorical" dataType="integer"/>
<DataField name="outputResult" optype="continuous" dataType="double"/>
<DataField name="inputA" optype="continuous" dataType="double">
<Interval closure="closedClosed" leftMargin="-1" rightMargin="1"/>
<Value property="missing" value="NA"/>
</DataField>
<DataField name="inputB" optype="continuous" dataType="double">
<Interval closure="closedClosed" leftMargin="-1" rightMargin="1"/>
<Value property="missing" value="NA"/>
</DataField>
<DataField name="inputC" optype="continuous" dataType="double">
<Interval closure="closedClosed" leftMargin="-1" rightMargin="1"/>
<Value property="missing" value="NA"/>
</DataField>
</DataDictionary>
<TransformationDictionary/>
<MiningModel functionName="mixed">
<MiningSchema>
<MiningField name="outputState" usageType="target"/>
<MiningField name="outputResult" usageType="target"/>
<MiningField name="inputA"/>
<MiningField name="inputB"/>
<MiningField name="inputC"/>
</MiningSchema>
<Output>
<OutputField name="outputState" optype="categorical" dataType="integer" targetField="outputState"/>
<OutputField name="outputResult" optype="continuous" dataType="double" targetField="outputResult"/>
</Output>
<Segmentation multipleModelMethod="selectAll">
<Segment id="1">
<True/>
<TreeModel modelName="TEST" functionName="classification" noTrueChildStrategy="returnLastPrediction">
<MiningSchema>
<MiningField name="outputState" usageType="target"/>
<MiningField name="inputA" invalidValueTreatment="asMissing"/>
<MiningField name="inputB" invalidValueTreatment="asMissing"/>
<MiningField name="inputC" invalidValueTreatment="asMissing"/>
</MiningSchema>
<Node score="0">
<True/>
<Node score="1">
<CompoundPredicate booleanOperator="or">
<SimplePredicate field="inputA" operator="isMissing"/>
<SimplePredicate field="inputB" operator="isMissing"/>
<SimplePredicate field="inputC" operator="isMissing"/>
</CompoundPredicate>
</Node>
</Node>
</TreeModel>
</Segment>
<Segment id="2">
<True/>
<RegressionModel functionName="regression">
<MiningSchema>
<MiningField name="outputResult" usageType="target"/>
<MiningField name="inputA" missingValueReplacement="0" missingValueTreatment="asMean" invalidValueTreatment="asMissing"/>
<MiningField name="inputB" missingValueReplacement="0" missingValueTreatment="asMean" invalidValueTreatment="asMissing"/>
<MiningField name="inputC" missingValueReplacement="0" missingValueTreatment="asMean" invalidValueTreatment="asMissing"/>
</MiningSchema>
<RegressionTable intercept="2">
<NumericPredictor name="inputA" coefficient="1"/>
<NumericPredictor name="inputB" coefficient="2"/>
<NumericPredictor name="inputC" coefficient="3"/>
</RegressionTable>
</RegressionModel>
</Segment>
</Segmentation>
</MiningModel>
</PMML>
Explanation:
DataDictonary (with left and right margins)
MiningModel (functionName="mixed" seemed to be wrong?; Segmentation multipleModelMethod="selectAll" wrong too?):
output definition (seemed to be wrong too? because of different targets?)
simple classification treemodel (to detect missing/imputed values) -> target: outputState
simple regression model -> target:outputResult
Anyone an idea or better suggestions?
Related
I was trying to connect an oData table to a smart table in my web ide using the following code.
I have seen the metadata of my oData and the entity set I want to access is trainingPlan.
PLANID and COURSEID are 2 columns in the table I am accessing.
In the result screen just the empty toolbar is coming and 'no data' is written beneath it.
The table is accessible as I tried to display using normal table and the data is showing.
#App.view.xml
<core:View xmlns:core="sap.ui.core" xmlns="sap.m" xmlns:smartFilterBar="sap.ui.comp.smartfilterbar"
xmlns:smartTable="sap.ui.comp.smarttable" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1" controllerName="Workspace.controller.App" height="100%">
<smartFilterBar:SmartFilterBar id="smartFilterBar" entitySet="trainingPlan" persistencyKey="SmartFilter_Explored" enableBasicSearch="true" >
<smartFilterBar:controlConfiguration>
<smartFilterBar:ControlConfiguration key="PLANID"></smartFilterBar:ControlConfiguration>
<smartFilterBar:ControlConfiguration key="COURSEID"></smartFilterBar:ControlConfiguration>
</smartFilterBar:controlConfiguration>
</smartFilterBar:SmartFilterBar>
<smartTable:SmartTable entitySet="trainingPlan" initiallyVisibleFields="PLANID" smartFilterId="smartFilterBar" tableType="ResponsiveTable" useExportToExcel="true"
useVariantManagement="false" useTablePersonalisation="true" header="Line Items" showRowCount="true" tableBindingPath="{TEST>/trainingPlan}"
persistencyKey="SmartTableAnalytical_Explored" enableAutoBinding="true" demandPopin="true" class="sapUiResponsiveContentPadding"
/>
</core:View>
#metadata.xml
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"
Version="1.0">
<edmx:DataServices
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
m:DataServiceVersion="2.0">
<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns="http://schemas.microsoft.com/ado/2008/09/edm"
Namespace="demo.services.demo">
<<EntityType Name="trainingPlanType">
<Key>
<PropertyRef Name="PLANID"/>
<PropertyRef Name="COURSEID"/>
</Key>
<Property Name="PLANID" Type="Edm.Int32" Nullable="false"/>
<Property Name="COURSEID" Type="Edm.Int32" Nullable="false"/>
<Property Name="COURSENAME" Type="Edm.String" Nullable="false"
MaxLength="255"/>
<Property Name="STARTDATE" Type="Edm.DateTime" Nullable="false"/>
<Property Name="AVAILSEAT" Type="Edm.Int32" Nullable="false"/>
<Property Name="TOTALSEATS" Type="Edm.Int32" Nullable="false"/>
<Property Name="ROOMNO" Type="Edm.Int32" Nullable="false"/>
<Property Name="COURSEDURATION" Type="Edm.String" MaxLength="255"/>
</EntityType>
<EntityContainer Name="demo" m:IsDefaultEntityContainer="true">
<EntitySet Name="trainingPlan"
EntityType="demo.services.demo.trainingPlanType"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
I assume you used a model named "TEST".
If you obtain the OData service data through the manifest without a named model, change tableBindingPath to:
tableBindingPath="{/trainingPlan}"
How do I add weight or value to the Edges or Link in a DGML file?
<?xml version='1.0' encoding='utf-8'?>
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="a" Label="a" Size="10" />
<Node Id="b" Background="#FF008080" Label="b" />
<Node Id="c" Label="c" Start="2010-06-10" />
</Nodes>
<Links>
<Link Source="a" Target="b" />
<Link Source="a" Target="c" />
</Links>
<Properties>
<Property Id="Background" Label="Background" DataType="Brush" />
<Property Id="Label" Label="Label" DataType="String" />
<Property Id="Size" DataType="String" />
<Property Id="Start" DataType="DateTime" />
</Properties>
</DirectedGraph>
I would like to be able to assign a weight or value to the lines between each node to designate the strength between the nodes.
You can add weights to each link by adding a label field with a value to each of the Link Sources. The numbers will appear beside the arrows on your graph.
<Link Source="a" Target="b" Label="5" />
<Link Source="a" Target="c" Label="6" />
Additionally, the background color of each node can be changed by creating Category groups and assigning that group to each node.
<Category Id="Orange" Background="Orange" />
<Category Id="Yellow" Background="Yellow" />
<Node Id="a" Category="Orange" />
<Node Id="b" Category="Yellow" />
Here's an example that uses a link Weight Style to do it:
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="Banana" UseManualLocation="True" />
<Node Id="Test" UseManualLocation="True" />
</Nodes>
<Links>
<Link Source="Test" Target="Banana" Priority="10"/>
<Link Source="Test" Target="Green" />
</Links>
<Properties>
<Property Id="Bounds" DataType="System.Windows.Rect" />
<Property Id="UseManualLocation" DataType="System.Boolean" />
</Properties>
<Styles>
<Style TargetType="Link">
<Setter Property="Weight" Expression="Priority" />
</Style>
</Styles>
</DirectedGraph>
I have the following pmml file:
<?xml version="1.0" ?>
<PMML>
<Header copyright="">
<Timestamp>2015-10-02 14:41:20.278000</Timestamp>
</Header>
<DataDictionary numberOfFields="5">
<DataField dataType="double" name="sepal length" optype="continuous"/>
<DataField dataType="double" name="sepal width" optype="continuous"/>
<DataField dataType="double" name="petal length" optype="continuous"/>
<DataField dataType="double" name="petal width" optype="continuous"/>
<DataField dataType="string" name="result" optype="categorical">
<Value value="iris setosa"/>
<Value value="iris versicolor"/>
<Value value="iris virginica"/>
</DataField>
</DataDictionary>
<RegressionModel functionName="regression" modelName="IrisRegression" normalizationMethod="softmax" targetFieldName="result">
<MiningSchema>
<MiningField name="sepal length"/>
<MiningField name="sepal width"/>
<MiningField name="petal length"/>
<MiningField name="petal width"/>
<MiningField name="result" usageType="predicted"/>
</MiningSchema>
<RegressionTable intercept="0.265606167976">
<NumericPredictor coefficient="0.414988328296" name="sepal length"/>
<NumericPredictor coefficient="1.46129738856" name="sepal width"/>
<NumericPredictor coefficient="-2.2621411772" name="petal length"/>
<NumericPredictor coefficient="-1.02909509924" name="petal width"/>
</RegressionTable>
<RegressionTable intercept="1.08542374239">
<NumericPredictor coefficient="0.416639685595" name="sepal length"/>
<NumericPredictor coefficient="-1.60083318526" name="sepal width"/>
<NumericPredictor coefficient="0.577657628678" name="petal length"/>
<NumericPredictor coefficient="-1.38553842866" name="petal width"/>
</RegressionTable>
<RegressionTable intercept="-1.21471457808">
<NumericPredictor coefficient="-1.70752515382" name="sepal length"/>
<NumericPredictor coefficient="-1.53426833999" name="sepal width"/>
<NumericPredictor coefficient="2.47097168077" name="petal length"/>
<NumericPredictor coefficient="2.55538211298" name="petal width"/>
</RegressionTable>
</RegressionModel>
</PMML>
When I try to evaluate it using jpmml-evaluator, I get this error :
org.jpmml.evaluator.InvalidFeatureException: RegressionModel
It works fine with a linear regression. Any ideas why I get this error ? Is my pmml file wrong somehow ?
EDIT: I changed the functionName to regressionand now have the following error:
org.jpmml.evaluator.InvalidFeatureException: RegressionTable
at org.jpmml.evaluator.RegressionModelEvaluator.evaluateClassification(RegressionModelEvaluator.java:140)
at org.jpmml.evaluator.RegressionModelEvaluator.evaluate(RegressionModelEvaluator.java:70)
at org.jpmml.evaluator.ModelEvaluator.evaluate(ModelEvaluator.java:345)
at tryEvaluator.Example.somefunction(Example.java:75)
at tryEvaluator.Example.main(Example.java:110)
According to the PMML specification, it is illegal for a regression-type RegressionModel element to contain more than one RegressionTable child elements.
Here's the relevant quote:
If the model is used to predict a numerical field, then there is only one RegressionTable and the attribute targetCategory may be missing. If the model is used to predict a categorical field, then there are two or more RegressionTables and each one must have the attribute targetCategory defined with a unique value.
You can fix your PMML document by changing the value of the RegressionModel#functionName attribute from regression to classification. Clearly, you're working with a classification-type problem.
It should be simple but I can't set it working. My XML looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="http://procese/sysworkflow/en/classic/services/wsdl2" service="ProcessMakerService" port="ProcessMakerServiceSoap" serviceAddress="http://procese:80/sysworkflow/en/classic/services/soap2" doc:name="Web Service Consumer"/>
<data-mapper:config name="JSON_To_XML" transformationGraphPath="json_to_xml.grf" doc:name="JSON_To_XML"/>
<flow name="ws_pm_login3Flow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<set-payload value="#[{"userid":"xyz.qwe", "password":"12345"}]" doc:name="Set Payload"/>
<data-mapper:transform config-ref="JSON_To_XML" doc:name="JSON To XML"/>
<ws:consumer config-ref="Web_Service_Consumer" operation="login" doc:name="Web Service Consumer"/>
</flow>
</mule>
The WS is working fine.
The mapper file json_to_xml.grf looks like:
<?xml version="1.0" encoding="UTF-8"?><Graph __version="3.5.0" author="abc" created="Tue Apr 21 13:27:56 EEST 2015" description="JSON To XML" guiVersion="3.4.4.P" id="1429614596881" licenseCode="Unlicensed" licenseType="Unknown" modified="Tue Apr 21 13:27:56 EEST 2015" modifiedBy="abc" name="JSON_To_XML" revision="1.0" showComponentDetails="false">
<Global>
<Metadata __index="0" __referenceCounter="1" __sourcePath="{}/login" _dataStructure="OBJECT" _id="__id" _type="Input" id="e941872a-c0e5-4148-ac8c-6010c4dad903">
<Record fieldDelimiter="," name="login" recordDelimiter="\n\\|\r\n\\|\r" type="delimited">
<Field __artificialType="_id" __systemManaged="true" name="__id" type="string"/>
<Field __index="1" __sourcePath="{}/login/password" containerType="SINGLE" label="password" name="password" type="string"/>
<Field __index="0" __sourcePath="{}/login/userid" containerType="SINGLE" label="userid" name="userid" type="string"/>
</Record>
</Metadata>
<Metadata __index="0" __referenceCounter="1" __sourcePath="{}/login" _dataStructure="OBJECT" _id="__id" _type="Output" id="d9e5b0f6-b757-46cb-89bf-a7662be5c77f">
<Record fieldDelimiter="," name="login" recordDelimiter="\n\\|\r\n\\|\r" type="delimited">
<Field __artificialType="_id" __systemManaged="true" name="__id" type="string"/>
<Field __index="0" __sourcePath="{}/login/password" containerType="SINGLE" label="password" name="password" type="string"/>
<Field __index="1" __sourcePath="{}/login/userid" containerType="SINGLE" label="userid" name="userid" type="string"/>
</Record>
</Metadata>
<Dictionary>
<Entry id="DictionaryEntry0" input="true" name="inputPayload" output="false" type="object"/>
<Entry id="DictionaryEntry1" input="false" name="outputPayload" output="true" type="object"/>
</Dictionary>
</Global>
<Phase number="0">
<Node cacheInMemory="true" charset="UTF-8" enabled="enabled" fileURL="dict:outputPayload" guiName="XML WRITER" guiX="900" guiY="20" id="EXT_XML_WRITER0" type="EXT_XML_WRITER">
<attr name="mapping"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<login xmlns:clover="http://www.cloveretl.com/ns/xmlmapping" clover:inPort="0">
<password>$0.password</password>
<userid>$0.userid</userid>
</login>]]></attr>
<attr name="_data_format"><![CDATA[XML]]></attr>
</Node>
<Node enabled="enabled" guiName="Foreach 'login' -> 'login'" guiX="460" guiY="20" id="FOREACH_LOGIN_LOGIN" transformClass="com.mulesoft.datamapper.transform.MelRecordTransform" type="REFORMAT">
<attr name="melScript"><![CDATA[//MEL
//START -> DO NOT REMOVE
output.__id = input.__id;
//END -> DO NOT REMOVE
output.password = input.password;
output.userid = input.userid;
]]></attr>
</Node>
<Node charset="UTF-8" enabled="enabled" fileURL="dict:inputPayload" guiName="JSON READER" guiX="20" guiY="20" id="JSON_READER0" type="JSON_READER">
<attr name="mapping"><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Context xpath="/root">
<Context outPort="0" sequenceField="__id" xpath="object">
<Mapping cloverField="password" trim="true" xpath="password"/>
<Mapping cloverField="userid" trim="true" xpath="userid"/>
</Context>
</Context>
]]></attr>
<attr name="_data_format"><![CDATA[JSON]]></attr>
</Node>
<Edge debugMode="true" fromNode="FOREACH_LOGIN_LOGIN:0" guiBendpoints="" id="Edge1" inPort="Port 0 (in)" metadata="d9e5b0f6-b757-46cb-89bf-a7662be5c77f" outPort="Port 0 (out)" toNode="EXT_XML_WRITER0:0"/>
<Edge debugMode="true" fromNode="JSON_READER0:0" guiBendpoints="" id="Edge0" inPort="Port 0 (in)" metadata="e941872a-c0e5-4148-ac8c-6010c4dad903" outPort="Port 0 (out)" toNode="FOREACH_LOGIN_LOGIN:0"/>
</Phase>
</Graph>
When I start the process I get:
Error executing graph: ERROR (com.mulesoft.mule.module.datamapper.api.exception.DataMapperExecutionException). Message payload is of type: HashMap
I am using 3.6.1 EE
What am I missing?
Turns out it is a problem in mule to use the double quotes in JSON. I swithced to XML and now it is working fine.
I would like to create a WADL-File from which Java Interfaces can be created using Apache CXF wadl2java Maven plugin.
In the WADL I would like to use the Datatypes defined in a XSD-File.
These are my REST Services:
#Path("/v1/order")
public interface OrderResource {
#PUT
#Consumes(MediaType.APPLICATION_XML)
public Response createOrder(Order order);
#GET
#Produces(MediaType.APPLICATION_XML)
public List<Order> getOrders(#QueryParam("orderId") List<Long> orderIds);
}
My WADL:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<application xmlns="http://wadl.dev.java.net/2009/02" >
<grammars>
<include href="RestService_schema1.xsd" />
</grammars>
<resources base="http://localhost:9080/rest/">
<resource path="v1/order/" id="OrderResource">
<resource>
<method name="PUT" id="createOrder">
<request>
<representation mediaType="application/xml" />
</request>
<response status="200">
</response>
</method>
</resource>
</resource>
<resource>
<method name="GET" id="getOrders">
<request>
<param name="orderId" style="query" type="xs:long" />
</request>
<response status="200">
<representation mediaType="application/xml" />
</response>
</method>
</resource>
</resources>
</application>
My RestService_schema1.xsd:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Order" type="Order" />
<xs:complexType name="Order">
<xs:attribute name="OrderId" type="orderid">
<xs:annotation>
<xs:documentation>...
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:sequence>
.
.
.
.
</xs:sequence>
</xs:complexType>
<xs:simpleType name="orderid">
<xs:annotation>
<xs:documentation> ....
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:long" />
</xs:simpleType>
</xs:schema>
What I want to do:
I would like to specify in my WADL the input type Order for the createOrder Service. I know this can be done with the element-attribute, but how can I link it? Maybe element="Order" within the <representation>-Tag??
The Query Param of the getOrders()-Service should be List<Long> (in the WADL a List with orderid's) and the Response Type List<Order>. How can I specify this in the WADL?