2013-02-20 17 views
0

當創建新的操作員時,我們創建輸入端口來接收數據和輸出數據的端口。對於我們固定它的數據類型等每個輸入端口:如何定義新的示例SetOutPut格式?

exampleSetInput.addPrecondition (
    new ExampleSetPrecondition (
     exampleSetInput, 
     Ontology.ATTRIBUTE_VALUE)); 

而且我們定義像輸出中端口的數據類型:

getTransformer().addPassThroughRule (
    exampleSetInput, exampleSetOutput); 

這種情況將產生相同的輸出數據類型和格式爲輸入。我的問題是如何定義與輸入無關的新輸出格式和數據類型。例如,輸入格式具有數字數據類型和四個屬性,我希望輸出數據是String類型的,並且具有新的兩個屬性。

回答

0

好吧,我在快速礦工社區「如何擴展rapidminer」的交付文檔中找到解決方案。定義端口規則時,它包括在構造函數中使用下列功能:

getTransformer().addRule(new ExampleSetPassThroughRule(exampleSetInput, exampleSetOutPut, SetRelation.SUBSET) { 
     @Override 
     public ExampleSetMetaData modifyExampleSet(ExampleSetMetaData metaData) throws UndefinedParameterError { 
      metaData.removeAllAttributes();//This will remove all input attribtes 
      metaData.addAttribute(new AttributeMetaData("item", Ontology.STRING));//here the creation of new attribute 

      return metaData; 
     } 
    }); 

您也可以修改,因爲你需要輸入屬性名稱或類型。