Package it.unimi.dsi.fastutil.longs

Examples of it.unimi.dsi.fastutil.longs.Long2DoubleMap


                    throw new RecommenderBuildException("invalid prediction row");
                }
                long uid = Long.parseLong(row[0]);
                long iid = Long.parseLong(row[1]);
                double pred = Double.parseDouble(row[2]);
                Long2DoubleMap user = data.get(uid);
                if (user == null) {
                    user = new Long2DoubleOpenHashMap();
                    data.put(uid, user);
                }
                user.put(iid, pred);
            }
        } finally {
            cursor.close();
        }
        Long2ObjectMap<SparseVector> vectors = new Long2ObjectOpenHashMap<SparseVector>(data.size());
View Full Code Here


        assertThat(v2.get(3), closeTo(1.5));
    }

    @Test
    public void testMapConstructor() {
        Long2DoubleMap map = new Long2DoubleArrayMap();
        long[] keys = { 3, 7, 8 };
        double[] values = { 1.5, 3.5, 2 };
        for (int i = 0; i < keys.length; i++) {
            map.put(keys[i], values[i]);
        }
       
        MutableSparseVector msv = new MutableSparseVector(map);

        assertThat(msv.get(3), closeTo(1.5));
View Full Code Here

        return wantedType;
    }

    @Override @Nonnull
    public SparseVector summarize(@Nonnull UserHistory<? extends Event> history) {
        Long2DoubleMap map = new Long2DoubleOpenHashMap();
        for (Event e : history.filter(wantedType)) {
            final long iid = e.getItemId();
            map.put(iid, map.get(iid) + 1);
        }
        return ImmutableSparseVector.create(map);
    }
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.longs.Long2DoubleMap

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.