Package hivemall.io

Examples of hivemall.io.FeatureValue


                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

        final List<FeatureValue> list = new ArrayList<FeatureValue>(numFeatures);
        for(Object f : features) {
            if(f == null) {
                continue;
            }
            final FeatureValue fv;
            if(parseFeature) {
                fv = FeatureValue.parse(f);
            } else {
                Object o = ObjectInspectorUtils.copyToStandardObject(f, featureInspector, ObjectInspectorCopyOption.WRITABLE);
                Writable k = WritableUtils.toWritable(o);
                fv = new FeatureValue(k, 1.f);
            }
            list.add(fv);
        }
        return list;
    }
View Full Code Here

    private static List<FeatureValue> parseFeatures(final List<Integer> features) {
        final List<FeatureValue> ftvec = new ArrayList<FeatureValue>(features.size());
        for(Integer f : features) {
            if(f != null) {
                FeatureValue fv = new FeatureValue(f, 1.f);
                ftvec.add(fv);
            }
        }
        return ftvec;
    }
View Full Code Here

        final List<FeatureValue> ftvec = new ArrayList<FeatureValue>(features.size());
        for(String f : features) {
            if(f == null) {
                continue;
            }
            final FeatureValue fv;
            if(noWeight) {
                fv = new FeatureValue(f, 1.f);
            } else {
                fv = FeatureValue.parse(f);
            }
            ftvec.add(fv);
        }
View Full Code Here

    private static List<FeatureValue> parseFeatures(final List<Integer> features) {
        final List<FeatureValue> ftvec = new ArrayList<FeatureValue>(features.size());
        for(Integer f : features) {
            if(f != null) {
                FeatureValue fv = new FeatureValue(f, 1.f);
                ftvec.add(fv);
            }
        }
        return ftvec;
    }
View Full Code Here

        final List<FeatureValue> ftvec = new ArrayList<FeatureValue>(features.size());
        for(String f : features) {
            if(f == null) {
                continue;
            }
            final FeatureValue fv;
            if(noWeight) {
                fv = new FeatureValue(f, 1.f);
            } else {
                fv = FeatureValue.parse(f);
            }
            ftvec.add(fv);
        }
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

        for(String ft : ftvec1) {
            if(noWeight) {
                score1++;
                map1.put(ft, 1.f);
            } else {
                FeatureValue fv = FeatureValue.parseFeatureAsString(ft);
                float v = fv.getValue();
                score1 += (v * v);
                String f = fv.getFeature();
                map1.put(f, v);
            }
        }
        double l1norm1 = Math.sqrt(score1);

        float dotp = 0.f;
        double score2 = 0.d;
        for(String ft : ftvec2) {
            if(noWeight) {
                score2++;
                if(map1.containsKey(ft)) {
                    dotp++;
                }
            } else {
                FeatureValue fv = FeatureValue.parseFeatureAsString(ft);
                float v2 = fv.getValue();
                score2 += (v2 * v2);
                String f2 = fv.getFeature();
                Float v1 = map1.get(f2);
                if(v1 != null) {
                    dotp += (v1.floatValue() * v2);
                }
            }
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

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.