Java Code Examples for it.unimi.dsi.fastutil.floats.FloatList#add()

The following examples show how to use it.unimi.dsi.fastutil.floats.FloatList#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RatingTask.java    From jstarcraft-rns with Apache License 2.0 6 votes vote down vote up
@Override
protected FloatList recommend(Model recommender, int userIndex) {
    ReferenceModule testModule = testModules[userIndex];
    ArrayInstance copy = new ArrayInstance(testMarker.getQualityOrder(), testMarker.getQuantityOrder());
    List<Integer2FloatKeyValue> rateList = new ArrayList<>(testModule.getSize());
    for (DataInstance instance : testModule) {
        copy.copyInstance(instance);
        recommender.predict(copy);
        rateList.add(new Integer2FloatKeyValue(copy.getQualityFeature(itemDimension), copy.getQuantityMark()));
    }

    FloatList recommendList = new FloatArrayList(rateList.size());
    for (Integer2FloatKeyValue keyValue : rateList) {
        recommendList.add(keyValue.getValue());
    }
    return recommendList;
}
 
Example 2
Source File: RatingTask.java    From jstarcraft-rns with Apache License 2.0 5 votes vote down vote up
@Override
protected FloatList check(int userIndex) {
    ReferenceModule testModule = testModules[userIndex];
    FloatList scoreList = new FloatArrayList(testModule.getSize());
    for (DataInstance instance : testModule) {
        scoreList.add(instance.getQuantityMark());
    }
    return scoreList;
}
 
Example 3
Source File: AbstractRatingEvaluatorTestCase.java    From jstarcraft-ai with Apache License 2.0 5 votes vote down vote up
@Override
protected FloatList getLeft(MathVector vector) {
    FloatList scoreList = new FloatArrayList(vector.getElementSize());
    for (VectorScalar scalar : vector) {
        scoreList.add(scalar.getValue());
    }
    return scoreList;
}
 
Example 4
Source File: AbstractRatingEvaluatorTestCase.java    From jstarcraft-ai with Apache License 2.0 5 votes vote down vote up
@Override
protected FloatList getRight(MathVector vector) {
    FloatList recommendList = new FloatArrayList(vector.getElementSize());
    for (VectorScalar scalar : vector) {
        if (RandomUtility.randomFloat(1F) < 0.5F) {
            recommendList.add(scalar.getValue());
        } else {
            recommendList.add(scalar.getValue() * 0.5F);
        }
    }
    return recommendList;
}
 
Example 5
Source File: LuceneEngine.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
/**
 * 检索文档
 * 
 * @param query
 * @param sort
 * @param offset
 * @param size
 * @return
 */
public KeyValue<List<Document>, FloatList> retrieveDocuments(Query query, Sort sort, int offset, int size) {
    try {
        readLock.lock();
        lockRead();
        synchronized (this.semaphore) {
            if (this.transienceManager.isChanged() || this.persistenceManager.isChanged()) {
                this.searcher = new LuceneSearcher(this.transienceManager, this.persistenceManager);
            }
        }
        ScoreDoc[] search = null;
        int begin = offset;
        int end = offset + size;
        if (sort == null) {
            search = this.searcher.search(query, end).scoreDocs;
        } else {
            search = this.searcher.search(query, end, sort).scoreDocs;
        }
        end = search.length;
        size = end - begin;
        size = size < 0 ? 0 : size;
        ArrayList<Document> documents = new ArrayList<>(size);
        FloatList scores = new FloatArrayList(size);
        for (int index = begin; index < end; index++) {
            ScoreDoc score = search[index];
            Document document = this.searcher.doc(score.doc);
            documents.add(document);
            scores.add(score.score);
        }
        return new KeyValue<>(documents, scores);
    } catch (Exception exception) {
        throw new StorageException(exception);
    } finally {
        unlockRead();
        readLock.unlock();
    }
}
 
Example 6
Source File: ValueInTransformFunction.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
private static float[] filterFloats(FloatSet floatSet, float[] source) {
  FloatList floatList = new FloatArrayList();
  for (float value : source) {
    if (floatSet.contains(value)) {
      floatList.add(value);
    }
  }
  if (floatList.size() == source.length) {
    return source;
  } else {
    return floatList.toFloatArray();
  }
}