Package org.drools.pmml.pmml_4_1.predictive.models

Examples of org.drools.pmml.pmml_4_1.predictive.models.CleanupTest




    @Test
    public void testMissingTreeDefault() throws Exception {
        PMML4Compiler compiler = new PMML4Compiler();
        PMML pmml = compiler.loadModel( PMML, ResourceFactory.newClassPathResource( source2 ).getInputStream() );

        for ( Object o : pmml.getAssociationModelsAndBaselineModelsAndClusteringModels() ) {
            if ( o instanceof TreeModel ) {
                TreeModel tree = (TreeModel) o;
                tree.setMissingValueStrategy( MISSINGVALUESTRATEGY.DEFAULT_CHILD );
            }
        }

        KieSession kSession = getSession( compiler.generateTheory( pmml ) );

        setKSession( kSession );
        setKbase( getKSession().getKieBase() );

       
View Full Code Here


    }


    @Test
    public void testMissingTreeAllMissingDefault() throws Exception {
        PMML4Compiler compiler = new PMML4Compiler();
        PMML pmml = compiler.loadModel( PMML, ResourceFactory.newClassPathResource( source2 ).getInputStream() );

        for ( Object o : pmml.getAssociationModelsAndBaselineModelsAndClusteringModels() ) {
            if ( o instanceof TreeModel ) {
                TreeModel tree = (TreeModel) o;
                tree.setMissingValueStrategy( MISSINGVALUESTRATEGY.DEFAULT_CHILD );
            }
        }

        String theory = compiler.generateTheory( pmml );
        if ( VERBOSE ) {
            System.out.println( theory );
        }
        KieSession kSession = getSession( theory );
        setKSession( kSession );
View Full Code Here



    @Test
    public void testMissingTreeLastChoice() throws Exception {
        PMML4Compiler compiler = new PMML4Compiler();
        PMML pmml = compiler.loadModel( PMML, ResourceFactory.newClassPathResource( source2 ).getInputStream() );

        for ( Object o : pmml.getAssociationModelsAndBaselineModelsAndClusteringModels() ) {
            if ( o instanceof TreeModel ) {
                TreeModel tree = (TreeModel) o;
                tree.setMissingValueStrategy( MISSINGVALUESTRATEGY.LAST_PREDICTION );
            }
        }

        String theory = compiler.generateTheory( pmml );
        if ( VERBOSE ) {
            System.out.println( theory );
        }
        KieSession kSession = getSession( theory );
        setKSession( kSession );
View Full Code Here



    @Test
    public void testMissingTreeNull() throws Exception {
        PMML4Compiler compiler = new PMML4Compiler();
        PMML pmml = compiler.loadModel( PMML, ResourceFactory.newClassPathResource( source2 ).getInputStream() );

        for ( Object o : pmml.getAssociationModelsAndBaselineModelsAndClusteringModels() ) {
            if ( o instanceof TreeModel ) {
                TreeModel tree = (TreeModel) o;
                tree.setMissingValueStrategy( MISSINGVALUESTRATEGY.NULL_PREDICTION );
            }
        }

        String theory = compiler.generateTheory( pmml );
        if ( VERBOSE ) {
            System.out.println( theory );
        }
        KieSession kSession = getSession( theory );
        setKSession( kSession );
View Full Code Here



    @Test
    public void testMissingAggregate() throws Exception {
        PMML4Compiler compiler = new PMML4Compiler();
        PMML pmml = compiler.loadModel( PMML, ResourceFactory.newClassPathResource( source2 ).getInputStream() );

        for ( Object o : pmml.getAssociationModelsAndBaselineModelsAndClusteringModels() ) {
            if ( o instanceof TreeModel ) {
                TreeModel tree = (TreeModel) o;
                tree.setMissingValueStrategy( MISSINGVALUESTRATEGY.AGGREGATE_NODES );
            }
        }

        String theory = compiler.generateTheory( pmml );
        if ( VERBOSE ) {
            System.out.println( theory );
        }
        KieSession kSession = getSession( theory );
        setKSession( kSession );
View Full Code Here



    @Test
    public void testMissingTreeNone() throws Exception {
        PMML4Compiler compiler = new PMML4Compiler();
        PMML pmml = compiler.loadModel( PMML, ResourceFactory.newClassPathResource( source2 ).getInputStream() );

        for ( Object o : pmml.getAssociationModelsAndBaselineModelsAndClusteringModels() ) {
            if ( o instanceof TreeModel ) {
                TreeModel tree = (TreeModel) o;
                tree.setMissingValueStrategy( MISSINGVALUESTRATEGY.NONE );
            }
        }

        String theory = compiler.generateTheory( pmml );
        if ( VERBOSE ) {
            System.out.println( theory );
        }
        KieSession kSession = getSession( theory );
        setKSession( kSession );
View Full Code Here

        boolean appl = false;
        boolean descr = false;
        boolean copyright = false;
        boolean annotation = false;

    String theory = new PMML4Compiler().compile(source,null);
        BufferedReader reader = new BufferedReader(new StringReader(theory));
        try {
            String line = "";
            while ((line=reader.readLine()) != null) {
                line = line.trim();
View Full Code Here

        boolean appl = false;
        boolean descr = false;
        boolean copyright = false;
        boolean annotation = false;

        PMML4Compiler compiler = new PMML4Compiler();
        compiler.getHelper().setPack( "org.drools.pmml.pmml_4_1.test" );

        String theory = compiler.compilesource, null );
        BufferedReader reader = new BufferedReader(new StringReader(theory));
        try {
            String line = "";
            while ((line=reader.readLine()) != null) {
                line = line.trim();
View Full Code Here

    }


    @Test
    public void testFunctionMapping() {
        PMML4Helper ctx = new PMML4Helper();

        assertEquals("(2 + 3 + 4)" , ctx.mapFunction("+","2","3","4"));
        assertEquals("(2 - 3)" , ctx.mapFunction("-","2","3"));
        assertEquals("(2 * 3 * 4)" , ctx.mapFunction("*","2","3","4"));
        assertEquals("(2 / 4)" , ctx.mapFunction("/","2","4"));

        assertEquals("(Math.min(2,Math.min(3,4)))" , ctx.mapFunction("min","2","3","4"));
        assertEquals("(Math.max(2,Math.max(3,4)))" , ctx.mapFunction("max","2","3","4"));
        assertEquals("(2 + 3 + 4)" , ctx.mapFunction("sum","2","3","4"));
        assertEquals("(2 * 3 * 4)" , ctx.mapFunction("product","2","3","4"));
        assertEquals("((2 + 3 + 4) / 3)" , ctx.mapFunction("avg","2","3","4"));
        assertEquals("(3)" , ctx.mapFunction("median","1","2","3","4","5"));
        assertEquals("( 0.5 * 3 + 0.5 * 4 )" , ctx.mapFunction("median","1","2","3","4","5","6"));

        assertEquals("(Math.log10(2))" , ctx.mapFunction("log10","2"));
        assertEquals("(Math.log(2))" , ctx.mapFunction("ln","2"));
        assertEquals("(Math.sqrt(2))" , ctx.mapFunction("sqrt","2"));
        assertEquals("(Math.abs(2))" , ctx.mapFunction("abs","2"));
        assertEquals("(Math.exp(2))" , ctx.mapFunction("exp","2"));
        assertEquals("(Math.pow(2,3))" , ctx.mapFunction("pow","2","3"));
        assertEquals("(1)" , ctx.mapFunction("pow","0","0"));
        assertEquals("(2 > 3 ? 1 : 0)" , ctx.mapFunction("threshold","2","3"));
        assertEquals("(Math.floor(2))" , ctx.mapFunction("floor","2"));
        assertEquals("(Math.ceil(2))" , ctx.mapFunction("ceil","2"));
        assertEquals("(Math.round(2))" , ctx.mapFunction("round","2"));

        assertEquals("(\"abc\".toString().toUpperCase())" , ctx.mapFunction("uppercase","\"abc\""));
        assertEquals("(\"testString\".toString().substring(2,6))" , ctx.mapFunction("substring","\"testString\"","3","4"));
        assertEquals("(new java.util.Formatter(new StringBuilder(),java.util.Locale.getDefault()).format(\"%3d\",3.0))" , ctx.mapFunction("formatNumber","\"%3d\"","3.0"));

        assertEquals("(new java.text.SimpleDateFormat(\"format\").format(new SimpleDateFormat().parse(\"date\")))" , ctx.mapFunction("formatDatetime","\"date\"","\"format\""));

        assertEquals("(( (new java.text.SimpleDateFormat()).parse(\"date\").getTime() - (new java.text.SimpleDateFormat()).parse(\"01/01/1956\").getTime() ) / (1000*60*60*24))", ctx.mapFunction("dateDaysSinceYear","\"date\"","1956"));
        assertEquals("(( (new java.text.SimpleDateFormat()).parse(\"date\").getTime() - (new java.text.SimpleDateFormat()).parse(\"01/01/1956\").getTime() ) / 1000)", ctx.mapFunction("dateSecondsSinceYear","\"date\"","1956"));
        assertEquals("((new java.text.SimpleDateFormat()).parse(\"date\").getTime() % 1000)", ctx.mapFunction("dateSecondsSinceMidnight","\"date\""));


        assertEquals("(a == b)" , ctx.mapFunction("equal","a","b"));
        assertEquals("(a != b)" , ctx.mapFunction("notEqual","a","b"));
        assertEquals("(a < b)" , ctx.mapFunction("lessThan","a","b"));
        assertEquals("(a <= b)" , ctx.mapFunction("lessOrEqual","a","b"));
        assertEquals("(a > b)" , ctx.mapFunction("greaterThan","a","b"));
        assertEquals("(a >= b)" , ctx.mapFunction("greaterOrEqual","a","b"));
        assertEquals("(a.contains(b))" , ctx.mapFunction("isIn","a","b"));
        assertEquals("((! a.contains(b)))" , ctx.mapFunction("isNotIn","a","b"));

        assertEquals("(( ! a ))" , ctx.mapFunction("not","a"));
        assertEquals("(a && b && c)" , ctx.mapFunction("and","a","b","c"));
        assertEquals("(a || b)" , ctx.mapFunction("or","a","b"));

        assertEquals("(a ? b : c)" , ctx.mapFunction("if","a","b","c"));
        assertEquals("(a ? b : null)" , ctx.mapFunction("if","a","b"));

    }
View Full Code Here

    @Test
    public void testPMMLHeader() {
        String source = "test_header.xml";


    PMML4Helper wrapper = new PMML4Helper();
      wrapper.setPack("org.drools.pmml.pmml_4_1.test");

        boolean header = false;
        boolean timestamp = false;
        boolean appl = false;
        boolean descr = false;
View Full Code Here

TOP

Related Classes of org.drools.pmml.pmml_4_1.predictive.models.CleanupTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.