Search in sources :

Example 11 with LocalTransformations

use of org.dmg.pmml.LocalTransformationsDocument.LocalTransformations in project knime-core by knime.

the class DerivedFieldMapper method getDerivedFields.

/**
 * @param pmml the pmml document to retrieve the derived fields from
 * @return all derived fields from the transformation dictionary as well as
 *      of all local transformation elements, or an empty array if no
 *      derived fields are defined.
 */
public static DerivedField[] getDerivedFields(final PMML pmml) {
    List<DerivedField> derivedFields = new ArrayList<DerivedField>();
    TransformationDictionary trans = pmml.getTransformationDictionary();
    if (trans != null) {
        derivedFields.addAll(Arrays.asList(trans.getDerivedFieldArray()));
    }
    LocalTransformations localTrans = null;
    if (pmml.getAssociationModelArray().length > 0) {
        localTrans = pmml.getAssociationModelArray(0).getLocalTransformations();
    } else if (pmml.getClusteringModelArray().length > 0) {
        localTrans = pmml.getClusteringModelArray(0).getLocalTransformations();
    } else if (pmml.getGeneralRegressionModelArray().length > 0) {
        localTrans = pmml.getGeneralRegressionModelArray(0).getLocalTransformations();
    } else if (pmml.getNaiveBayesModelArray().length > 0) {
        localTrans = pmml.getNaiveBayesModelArray(0).getLocalTransformations();
    } else if (pmml.getNeuralNetworkArray().length > 0) {
        localTrans = pmml.getNeuralNetworkArray(0).getLocalTransformations();
    } else if (pmml.getRegressionModelArray().length > 0) {
        localTrans = pmml.getRegressionModelArray(0).getLocalTransformations();
    } else if (pmml.getRuleSetModelArray().length > 0) {
        localTrans = pmml.getRuleSetModelArray(0).getLocalTransformations();
    } else if (pmml.getSequenceModelArray().length > 0) {
        localTrans = pmml.getSequenceModelArray(0).getLocalTransformations();
    } else if (pmml.getSupportVectorMachineModelArray().length > 0) {
        localTrans = pmml.getSupportVectorMachineModelArray(0).getLocalTransformations();
    } else if (pmml.getTextModelArray().length > 0) {
        localTrans = pmml.getTextModelArray(0).getLocalTransformations();
    } else if (pmml.getTimeSeriesModelArray().length > 0) {
        localTrans = pmml.getTimeSeriesModelArray(0).getLocalTransformations();
    } else if (pmml.getTreeModelArray().length > 0) {
        localTrans = pmml.getTreeModelArray(0).getLocalTransformations();
    } else if (pmml.sizeOfRuleSetModelArray() > 0) {
        localTrans = pmml.getRuleSetModelArray(0).getLocalTransformations();
    }
    if (localTrans != null) {
        derivedFields.addAll(Arrays.asList(localTrans.getDerivedFieldArray()));
    }
    return derivedFields.toArray(new DerivedField[0]);
}
Also used : LocalTransformations(org.dmg.pmml.LocalTransformationsDocument.LocalTransformations) TransformationDictionary(org.dmg.pmml.TransformationDictionaryDocument.TransformationDictionary) ArrayList(java.util.ArrayList) DerivedField(org.dmg.pmml.DerivedFieldDocument.DerivedField)

Example 12 with LocalTransformations

use of org.dmg.pmml.LocalTransformationsDocument.LocalTransformations in project knime-core by knime.

the class PMMLBinningTranslator method exportToLocalTrans.

/**
 * {@inheritDoc}
 */
@Override
public LocalTransformations exportToLocalTrans() {
    LocalTransformations localtrans = LocalTransformations.Factory.newInstance();
    localtrans.setDerivedFieldArray(createDerivedFields());
    return localtrans;
}
Also used : LocalTransformations(org.dmg.pmml.LocalTransformationsDocument.LocalTransformations)

Example 13 with LocalTransformations

use of org.dmg.pmml.LocalTransformationsDocument.LocalTransformations in project knime-core by knime.

the class PMMLMany2OneTranslator method exportToLocalTrans.

/**
 * {@inheritDoc}
 */
@Override
public LocalTransformations exportToLocalTrans() {
    final LocalTransformations localTrans = LocalTransformations.Factory.newInstance();
    localTrans.setDerivedFieldArray(new DerivedField[] { createDerivedField() });
    return localTrans;
}
Also used : LocalTransformations(org.dmg.pmml.LocalTransformationsDocument.LocalTransformations)

Example 14 with LocalTransformations

use of org.dmg.pmml.LocalTransformationsDocument.LocalTransformations in project knime-core by knime.

the class PMMLStringConversionTranslator method exportToLocalTrans.

/**
 * {@inheritDoc}
 */
@Override
public LocalTransformations exportToLocalTrans() {
    LocalTransformations localtrans = LocalTransformations.Factory.newInstance();
    localtrans.setDerivedFieldArray(createDerivedFields());
    return localtrans;
}
Also used : LocalTransformations(org.dmg.pmml.LocalTransformationsDocument.LocalTransformations)

Example 15 with LocalTransformations

use of org.dmg.pmml.LocalTransformationsDocument.LocalTransformations in project knime-core by knime.

the class PMMLMapValuesTranslator method exportToLocalTrans.

/**
 * {@inheritDoc}
 */
@Override
public LocalTransformations exportToLocalTrans() {
    LocalTransformations localTrans = LocalTransformations.Factory.newInstance();
    localTrans.setDerivedFieldArray(createDerivedFields());
    return localTrans;
}
Also used : LocalTransformations(org.dmg.pmml.LocalTransformationsDocument.LocalTransformations)

Aggregations

LocalTransformations (org.dmg.pmml.LocalTransformationsDocument.LocalTransformations)15 DerivedField (org.dmg.pmml.DerivedFieldDocument.DerivedField)4 GeneralRegressionModel (org.dmg.pmml.GeneralRegressionModelDocument.GeneralRegressionModel)3 TransformationDictionary (org.dmg.pmml.TransformationDictionaryDocument.TransformationDictionary)3 ArrayList (java.util.ArrayList)2 ClusteringModel (org.dmg.pmml.ClusteringModelDocument.ClusteringModel)2 NeuralNetwork (org.dmg.pmml.NeuralNetworkDocument.NeuralNetwork)2 PMML (org.dmg.pmml.PMMLDocument.PMML)2 RegressionModel (org.dmg.pmml.RegressionModelDocument.RegressionModel)2 RuleSetModel (org.dmg.pmml.RuleSetModelDocument.RuleSetModel)2 SupportVectorMachineModel (org.dmg.pmml.SupportVectorMachineModelDocument.SupportVectorMachineModel)2 TreeModel (org.dmg.pmml.TreeModelDocument.TreeModel)2 BigInteger (java.math.BigInteger)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 JsonObjectBuilder (javax.json.JsonObjectBuilder)1 SchemaType (org.apache.xmlbeans.SchemaType)1 XmlCursor (org.apache.xmlbeans.XmlCursor)1 XmlObject (org.apache.xmlbeans.XmlObject)1 Apply (org.dmg.pmml.ApplyDocument.Apply)1