Package org.grouplens.lenskit.vectors

Examples of org.grouplens.lenskit.vectors.MutableSparseVector.freeze()


                        uis = new LongArrayList();
                        userItems.put(user, uis);
                    }
                    uis.add(item.getItemId());
                }
                itemVectors.put(item.getItemId(), vector.freeze());
            }
        } finally {
            itemCursor.close();
        }
View Full Code Here


            // Convert the uoff array to a SparseVector
            MutableSparseVector svuoff = Vectors.fromArray(snapshot.userIndex(), uoff);
            // Convert the ioff array to a SparseVector
            MutableSparseVector svioff = Vectors.fromArray(snapshot.itemIndex(), ioff);
            return new LeastSquaresItemScorer(svuoff.freeze(), svioff.freeze(), mean);
        }
    }
}
View Full Code Here

    @Override
    public SparseVector score(long user, @Nonnull Collection<Long> items) {
        MutableSparseVector scores = MutableSparseVector.create(items);
        score(user, scores);
        // FIXME Create a more efficient way of "releasing" mutable sparse vectors
        return scores.freeze();
    }

    /**
     * {@inheritDoc}
     * <p>Delegates to {@link #score(long, Collection)}.
View Full Code Here

    @Override
    public SparseVector predict(long user, @Nonnull Collection<Long> items) {
        MutableSparseVector scores = MutableSparseVector.create(items);
        predict(user, scores);
        // FIXME Create a more efficient way of "releasing" mutable sparse vectors
        return scores.freeze();
    }

    /**
     * {@inheritDoc}
     * <p>Delegates to {@link #predict(long, java.util.Collection)}.
View Full Code Here

            assert n > 0;
            // compute a total to subtract offset from each accumulated value
            final double noff = n * offset;
            v.set(e, (e.getValue() - noff) / (n + damping));
        }
        return v.freeze();
    }

    /**
     * Compute mean offsets for each item.  Equivalent to {@code computeIdMeans(globalMean(), damping)}.
     *
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.