Package hivemall.io

Examples of hivemall.io.FeatureValue


        features1.add("good");
        features1.add("opinion");
        udtf.update(features1, 1, 0.f);

        /* check weights */
        FeatureValue word1 = FeatureValue.parse(new String("good"));
        assertEquals(1.f, udtf.model.get(word1.getFeature()).get(), 1e-5f);

        FeatureValue word2 = FeatureValue.parse(new String("opinion"));
        assertEquals(1.f, udtf.model.get(word2.getFeature()).get(), 1e-5f);

        /* update weights by List<Object> */
        List<String> features2 = new ArrayList<String>();
        features2.add("bad");
        features2.add("opinion");
        udtf.update(features2, -1, 0.f);

        /* check weights */
        assertEquals(1.f, udtf.model.get(word1.getFeature()).get(), 1e-5f);

        FeatureValue word3 = FeatureValue.parse(new String("bad"));
        assertEquals(-1.f, udtf.model.get(word3.getFeature()).get(), 1e-5f);

        FeatureValue word4 = FeatureValue.parse(new String("opinion"));
        assertEquals(0.f, udtf.model.get(word4.getFeature()).get(), 1e-5f);
    }
View Full Code Here


        features1.add("good");
        features1.add("opinion");
        udtf.update(features1, 1, 0.f);

        /* check weights */
        FeatureValue word1 = FeatureValue.parse(new String("good"));
        assertEquals(1.f, udtf.model.get(word1.getFeature()).get(), 1e-5f);

        FeatureValue word2 = FeatureValue.parse(new String("opinion"));
        assertEquals(1.f, udtf.model.get(word2.getFeature()).get(), 1e-5f);

        /* update weights by List<Object> */
        List<String> features2 = new ArrayList<String>();
        features2.add("bad");
        features2.add("opinion");
        udtf.update(features2, -1, 0.f);

        /* check weights */
        assertEquals(1.f, udtf.model.get(word1.getFeature()).get(), 1e-5f);

        FeatureValue word3 = FeatureValue.parse(new String("bad"));
        assertEquals(-1.f, udtf.model.get(word3.getFeature()).get(), 1e-5f);

        FeatureValue word4 = FeatureValue.parse(new String("opinion"));
        assertEquals(0.f, udtf.model.get(word4.getFeature()).get(), 1e-5f);
    }
View Full Code Here

                continue;
            }
            final Object k;
            final float v;
            if(parseFeature) {
                FeatureValue fv = FeatureValue.parse(f);
                k = fv.getFeature();
                v = fv.getValue();
            } else {
                k = ObjectInspectorUtils.copyToStandardObject(f, featureInspector);
                v = 1.f;
            }
            float old_w = model.getWeight(k);
View Full Code Here

                continue;
            }
            final Object k;
            final float v;
            if(parseX) {
                FeatureValue fv = FeatureValue.parse(f);
                k = fv.getFeature();
                v = fv.getValue();
            } else {
                k = ObjectInspectorUtils.copyToStandardObject(f, featureInspector);
                v = 1.f;
            }
            float old_w = model.getWeight(k);
View Full Code Here

                continue;
            }
            final Object k;
            final float v;
            if(parseFeature) {
                FeatureValue fv = FeatureValue.parse(f);
                k = fv.getFeature();
                v = fv.getValue();
            } else {
                k = ObjectInspectorUtils.copyToStandardObject(f, featureInspector);
                v = 1.f;
            }
            IWeightValue old_w = model.get(k);
View Full Code Here

                continue;
            }
            final Object x;
            final float xi;
            if(parseFeature) {
                FeatureValue fv = FeatureValue.parse(f);
                x = fv.getFeature();
                xi = fv.getValue();
            } else {
                x = ObjectInspectorUtils.copyToStandardObject(f, featureInspector);
                xi = 1.f;
            }
            float old_w = model.getWeight(x);
View Full Code Here

                continue;
            }
            final Object k;
            final float v;
            if(parseFeature) {
                FeatureValue fv = FeatureValue.parse(f);
                k = fv.getFeature();
                v = fv.getValue();
            } else {
                k = ObjectInspectorUtils.copyToStandardObject(f, featureInspector);
                v = 1.f;
            }
            IWeightValue old_w = model.get(k);
View Full Code Here

                continue;
            }
            final Object x;
            final float xi;
            if(parseFeature) {
                FeatureValue fv = FeatureValue.parse(f);
                x = fv.getFeature();
                xi = fv.getValue();
            } else {
                x = ObjectInspectorUtils.copyToStandardObject(f, featureInspector);
                xi = 1.f;
            }
View Full Code Here

                continue;
            }
            final Object k;
            final float v;
            if(parseFeature) {
                FeatureValue fv = FeatureValue.parse(f);
                k = fv.getFeature();
                v = fv.getValue();
            } else {
                k = ObjectInspectorUtils.copyToStandardObject(f, featureInspector);
                v = 1.f;
            }
            IWeightValue old_correctclass_w = model2add.get(k);
View Full Code Here

                continue;
            }
            final Object k;
            final float v;
            if(parseFeature) {
                FeatureValue fv = FeatureValue.parse(f);
                k = fv.getFeature();
                v = fv.getValue();
            } else {
                k = ObjectInspectorUtils.copyToStandardObject(f, featureInspector);
                v = 1.f;
            }
            IWeightValue old_correctclass_w = model2add.get(k);
View Full Code Here

TOP

Related Classes of hivemall.io.FeatureValue

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.