示例#1
0
 @Override
 public String toString() {
   return "ALSSpeedModel[features:"
       + features
       + ", X:("
       + X.size()
       + " users), Y:("
       + Y.size()
       + " items)]";
 }
示例#2
0
 public void retainAllUsers(Collection<String> users) {
   Lock lock = xLock.writeLock();
   lock.lock();
   try {
     X.removeAll(new NotContainsPredicate<>(users));
   } finally {
     lock.unlock();
   }
 }
示例#3
0
 public float[] getItemVector(String item) {
   Lock lock = yLock.readLock();
   lock.lock();
   try {
     return Y.get(item);
   } finally {
     lock.unlock();
   }
 }
示例#4
0
 public float[] getUserVector(String user) {
   Lock lock = xLock.readLock();
   lock.lock();
   try {
     return X.get(user);
   } finally {
     lock.unlock();
   }
 }
示例#5
0
 public void retainAllItems(Collection<String> items) {
   Lock lock = yLock.writeLock();
   lock.lock();
   try {
     Y.removeAll(new NotContainsPredicate<>(items));
   } finally {
     lock.unlock();
   }
 }
示例#6
0
 public void setItemVector(String item, float[] vector) {
   Preconditions.checkNotNull(vector);
   Preconditions.checkArgument(vector.length == features);
   Lock lock = yLock.writeLock();
   lock.lock();
   try {
     Y.put(item, vector);
   } finally {
     lock.unlock();
   }
 }
示例#7
0
 public void setUserVector(String user, float[] vector) {
   Preconditions.checkNotNull(vector);
   Preconditions.checkArgument(vector.length == features);
   Lock lock = xLock.writeLock();
   lock.lock();
   try {
     X.put(user, vector);
   } finally {
     lock.unlock();
   }
 }
示例#8
0
 public Solver getYTYSolver() {
   RealMatrix YTY;
   Lock lock = yLock.readLock();
   lock.lock();
   try {
     YTY = VectorMath.transposeTimesSelf(Y.values());
   } finally {
     lock.unlock();
   }
   return new LinearSystemSolver().getSolver(YTY);
 }
示例#9
0
 public Solver getXTXSolver() {
   RealMatrix XTX;
   Lock lock = xLock.readLock();
   lock.lock();
   try {
     XTX = VectorMath.transposeTimesSelf(X.values());
   } finally {
     lock.unlock();
   }
   return new LinearSystemSolver().getSolver(XTX);
 }