Package org.kie.api.runtime

Examples of org.kie.api.runtime.KieSession


    @Test
    public void testMissingTreeWeighted1() throws Exception {
        setKSession( getModelSession( source2, VERBOSE ) );
        setKbase( getKSession().getKieBase() );
        KieSession kSession = getKSession();

        kSession.fireAllRules()//init model

        FactType tgt = kSession.getKieBase().getFactType( packageName, "Fld9" );
        FactType tok = kSession.getKieBase().getFactType( PMML4Helper.pmmlDefaultPackageName(), "TreeToken" );

        kSession.getEntryPoint( "in_Fld1" ).insert( -1.0 );
        kSession.getEntryPoint( "in_Fld2" ).insert( -1.0 );
        kSession.getEntryPoint( "in_Fld3" ).insert( "optA" );

        kSession.fireAllRules();

        Object token = getToken( kSession );
        assertEquals( 0.8, tok.get( token, "confidence" ) );
        assertEquals( "null", tok.get( token, "current" ) );
        assertEquals( 50.0, tok.get( token, "totalCount" ) );
View Full Code Here


    @Test
    public void testMissingTreeWeighted2() throws Exception {
        setKSession( getModelSession( source2, VERBOSE ) );
        setKbase( getKSession().getKieBase() );
        KieSession kSession = getKSession();

        kSession.fireAllRules()//init model

        FactType tgt = kSession.getKieBase().getFactType( packageName, "Fld9" );
        FactType tok = kSession.getKieBase().getFactType( PMML4Helper.pmmlDefaultPackageName(), "TreeToken" );

        kSession.getEntryPoint( "in_Fld1" ).insert( -1.0 );
        kSession.getEntryPoint( "in_Fld2" ).insert( -1.0 );
        kSession.getEntryPoint( "in_Fld3" ).insert( "miss" );

        kSession.fireAllRules();

        Object token = getToken( kSession );
        assertEquals( 0.6, tok.get( token, "confidence" ) );
        assertEquals( "null", tok.get( token, "current" ) );
        assertEquals( 100.0, tok.get( token, "totalCount" ) );
View Full Code Here

                TreeModel tree = (TreeModel) o;
                tree.setMissingValueStrategy( MISSINGVALUESTRATEGY.DEFAULT_CHILD );
            }
        }

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

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

       
       
        kSession.fireAllRules()//init model

        FactType tgt = kSession.getKieBase().getFactType( packageName, "Fld9" );
        FactType tok = kSession.getKieBase().getFactType( PMML4Helper.pmmlDefaultPackageName(), "TreeToken" );

        kSession.getEntryPoint( "in_Fld1" ).insert( 70.0 );
        kSession.getEntryPoint( "in_Fld2" ).insert( 40.0 );
        kSession.getEntryPoint( "in_Fld3" ).insert( "miss" );

        kSession.fireAllRules();

        Object token = getToken( kSession );
        assertEquals( 0.72, (Double) tok.get( token, "confidence" ), 1e-6 );
        assertEquals( "null", tok.get( token, "current" ) );
        assertEquals( 40.0, tok.get( token, "totalCount" ) );
View Full Code Here

        String theory = compiler.generateTheory( pmml );
        if ( VERBOSE ) {
            System.out.println( theory );
        }
        KieSession kSession = getSession( theory );
        setKSession( kSession );
        setKbase( getKSession().getKieBase() );



        kSession.fireAllRules()//init model

        FactType tgt = kSession.getKieBase().getFactType( packageName, "Fld9" );
        FactType tok = kSession.getKieBase().getFactType( PMML4Helper.pmmlDefaultPackageName(), "TreeToken" );

        kSession.getEntryPoint( "in_Fld1" ).insert( -1.0 );
        kSession.getEntryPoint( "in_Fld2" ).insert( -1.0 );
        kSession.getEntryPoint( "in_Fld3" ).insert( "miss" );

        kSession.fireAllRules();

        Object token = getToken( kSession );
        assertEquals( 1.0, (Double) tok.get( token, "confidence" ), 1e-6 );
        assertEquals( "null", tok.get( token, "current" ) );
        assertEquals( 0.0, tok.get( token, "totalCount" ) );
View Full Code Here

    @Test
    public void testCenterBasedClustering() throws Exception {
        setKSession( getModelSession( source1, VERBOSE ) );
        setKbase( getKSession().getKieBase() );
        KieSession kSession = getKSession();

        kSession.fireAllRules()//init model

        kSession.getEntryPoint( "in_Fld0" ).insert( "y" );
        kSession.getEntryPoint( "in_Fld1" ).insert( 2.0 );
        kSession.getEntryPoint( "in_Fld2" ).insert( -1.0 );

        kSession.fireAllRules();
       
        FactType mu = kSession.getKieBase().getFactType( packageName, "DistanceMembership" );
        Collection mus = kSession.getObjects( new ClassObjectFilter( mu.getFactClass()) );
        assertTrue( mus.size() > 0 );
        for ( Object x : mus ) {
            Integer ix = (Integer) mu.get( x, "index" );
            String lab = (String) mu.get( x, "label" );
            Double m = (Double) mu.get( x, "mu" );
View Full Code Here

    @Test
    public void testRegression() throws Exception {
        setKSession( getModelSession( source1, VERBOSE ) );
        setKbase( getKSession().getKieBase() );
        KieSession kSession = getKSession();

        kSession.fireAllRules()//init model

        FactType tgt = kSession.getKieBase().getFactType( packageName, "Fld4" );

        kSession.getEntryPoint( "in_Fld1" ).insert( 0.9 );
        kSession.getEntryPoint( "in_Fld2" ).insert( 0.3 );
        kSession.getEntryPoint( "in_Fld3" ).insert( "x" );
        kSession.fireAllRules();

        double x = 0.5
                   + 5 * 0.9 * 0.9
                   + 2 * 0.3
                   - 3.0
View Full Code Here

    @Test
    public void testClassification() throws Exception {
        setKSession( getModelSession( source2, VERBOSE ) );
        setKbase( getKSession().getKieBase() );
        KieSession kSession = getKSession();

        kSession.fireAllRules()//init model

        FactType tgt = kSession.getKieBase().getFactType( packageName, "Fld4" );

        kSession.getEntryPoint( "in_Fld1" ).insert( 1.0 );
        kSession.getEntryPoint( "in_Fld2" ).insert( 1.0 );
        kSession.getEntryPoint( "in_Fld3" ).insert( "x" );
        kSession.fireAllRules();

        checkFirstDataFieldOfTypeStatus( kSession.getKieBase().getFactType( packageName, "RegOut" ),
                                            true, false, "LinReg", "catC" );
        checkFirstDataFieldOfTypeStatus( kSession.getKieBase().getFactType( packageName, "RegProb" ),
                                            true, false, "LinReg", 0.709228 );
        checkFirstDataFieldOfTypeStatus( kSession.getKieBase().getFactType( packageName, "RegProbA" ),
                                            true, false, "LinReg", 0.010635 );


    }
View Full Code Here

    @Test
    public void testSVM() throws Exception {
        setKSession( getModelSession( source1, VERBOSE ) );
        setKbase( getKSession().getKieBase() );
        KieSession kSession = getKSession();

        kSession.fireAllRules()//init model

        FactType ztype = kSession.getKieBase().getFactType( packageName, "Z" );
        assertNotNull( ztype );

        kSession.getEntryPoint( "in_X" ).insert( 0.0 );
        kSession.getEntryPoint( "in_Y" ).insert( 0.0 );
        kSession.fireAllRules();
        System.out.println( reportWMObjects( kSession ) );
        checkFirstDataFieldOfTypeStatus( ztype, true, false, "SVMXORMODEL", "yes" );


        kSession.getEntryPoint( "in_X" ).insert( 0.23 );
        kSession.getEntryPoint( "in_Y" ).insert( 0.75 );
        kSession.fireAllRules();
        checkFirstDataFieldOfTypeStatus( ztype, true, false, "SVMXORMODEL", "no" );


        kSession.getEntryPoint( "in_X" ).insert( 0.85 );
        kSession.fireAllRules();
        checkFirstDataFieldOfTypeStatus( ztype, true, false, "SVMXORMODEL", "yes" );

        kSession.getEntryPoint( "in_Y" ).insert( -0.12 );
        kSession.fireAllRules();
        checkFirstDataFieldOfTypeStatus( ztype, true, false, "SVMXORMODEL", "no" );

        kSession.getEntryPoint( "in_X" ).insert( 7.85 );
        kSession.fireAllRules();
        System.out.println( reportWMObjects( kSession ) );
        checkFirstDataFieldOfTypeStatus( ztype, true, false, "SVMXORMODEL", "no" );
    }
View Full Code Here

    @Test
    public void testSVM1vN() throws Exception {
        setKSession( getModelSession( source2, VERBOSE ) );
        setKbase( getKSession().getKieBase() );
        KieSession kSession = getKSession();

        kSession.fireAllRules()//init model

        FactType ztype = kSession.getKieBase().getFactType( packageName, "Z" );
        assertNotNull( ztype );


        kSession.getEntryPoint( "in_X" ).insert( 0.0 );
        kSession.getEntryPoint( "in_Y" ).insert( 0.0 );
        kSession.fireAllRules();

        checkFirstDataFieldOfTypeStatus( ztype, true, false, "SVMXORMODEL", "no" );

        checkFirstDataFieldOfTypeStatus( kSession.getKieBase().getFactType( packageName, "OutZ" ),
                                                true, false, "SVMXORMODEL", "no" );
        checkFirstDataFieldOfTypeStatus( kSession.getKieBase().getFactType( packageName, "ProbZNo" ),
                                                true, false, "SVMXORMODEL", 0.7357588 );

    }
View Full Code Here

    @Test
    public void testSVM1v1() throws Exception {
        setKSession( getModelSession( source3, VERBOSE ) );
        setKbase( getKSession().getKieBase() );
        KieSession kSession = getKSession();

        kSession.fireAllRules()//init model

        FactType ztype = kSession.getKieBase().getFactType( packageName, "Z" );
        assertNotNull( ztype );


        kSession.getEntryPoint( "in_X" ).insert( 0.63 );
        kSession.getEntryPoint( "in_Y" ).insert( 0.0 );
        kSession.fireAllRules();

        checkFirstDataFieldOfTypeStatus( ztype, true, false, "SVMXORMODEL", "yes" );

        checkFirstDataFieldOfTypeStatus( kSession.getKieBase().getFactType( packageName, "OutZ" ),
                                                true, false, "SVMXORMODEL", "yes" );
        checkFirstDataFieldOfTypeStatus( kSession.getKieBase().getFactType( packageName, "ProbZYes" ),
                                                true, false, "SVMXORMODEL", 0.872057 );


    }
View Full Code Here

TOP

Related Classes of org.kie.api.runtime.KieSession

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.