Java Code Examples for com.jstarcraft.core.utility.RandomUtility#setSeed()

The following examples show how to use com.jstarcraft.core.utility.RandomUtility#setSeed() . 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: AbstractEvaluatorTestCase.java    From jstarcraft-ai with Apache License 2.0 6 votes vote down vote up
@Test
public void test() throws Exception {
    RandomUtility.setSeed(0L);
    int rowSize = 1000;
    int columnSize = 1000;
    HashMatrix featureTable = new HashMatrix(true, rowSize, columnSize, new Long2FloatRBTreeMap());
    for (int rowIndex = 0; rowIndex < rowSize; rowIndex++) {
        for (int columnIndex = 0; columnIndex < columnSize; columnIndex++) {
            if (RandomUtility.randomFloat(1F) < 0.5F) {
                featureTable.setValue(rowIndex, columnIndex, RandomUtility.randomFloat(1F));
            }
        }
    }
    SparseMatrix featureMatrix = SparseMatrix.valueOf(rowSize, columnSize, featureTable);
    Evaluator<L, R> evaluator = getEvaluator(featureMatrix);
    Integer2FloatKeyValue sum = evaluate(evaluator, featureMatrix);
    Assert.assertThat(sum.getValue() / sum.getKey(), CoreMatchers.equalTo(getMeasure()));
}
 
Example 2
Source File: RandomGuessModel.java    From jstarcraft-rns with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void predict(DataInstance instance) {
    int userIndex = instance.getQualityFeature(userDimension);
    int itemIndex = instance.getQualityFeature(itemDimension);
    RandomUtility.setSeed(userIndex * itemSize + itemIndex);
    instance.setQuantityMark(RandomUtility.randomFloat(minimumScore, maximumScore));
}
 
Example 3
Source File: AbstractTask.java    From jstarcraft-rns with Apache License 2.0 5 votes vote down vote up
protected AbstractTask(Model model, Configurator configurator) {
    this.configurator = configurator;
    Long seed = configurator.getLong("recommender.random.seed");
    if (seed != null) {
        RandomUtility.setSeed(seed);
    }
    this.model = model;
}
 
Example 4
Source File: AbstractTask.java    From jstarcraft-rns with Apache License 2.0 5 votes vote down vote up
protected AbstractTask(Class<? extends Model> clazz, Configurator configurator) {
    this.configurator = configurator;
    Long seed = configurator.getLong("recommender.random.seed");
    if (seed != null) {
        RandomUtility.setSeed(seed);
    }
    this.model = (Model) ReflectionUtility.getInstance(clazz);
}