@Override public DataModel buildDataModel(FastByIDMap<PreferenceArray> trainingData) { return new GenericBooleanPrefDataModel(GenericBooleanPrefDataModel.toDataMap(trainingData)); } };
return new GenericBooleanPrefDataModel(data, timestamps); FastByIDMap<FastIDSet> rawData = ((GenericBooleanPrefDataModel) delegate).getRawUserData(); return new GenericBooleanPrefDataModel(rawData, timestamps);
/** * <p> * Creates a new {@link GenericDataModel} containing an immutable copy of the data from another given * {@link DataModel}. * </p> * * @param dataModel * {@link DataModel} to copy * @throws TasteException * if an error occurs while retrieving the other {@link DataModel}'s users * @deprecated without direct replacement. * Consider {@link #toDataMap(DataModel)} with {@link #GenericBooleanPrefDataModel(FastByIDMap)} */ @Deprecated public GenericBooleanPrefDataModel(DataModel dataModel) throws TasteException { this(toDataMap(dataModel)); }
public static DataModel getBooleanDataModel(long[] userIDs, boolean[][] prefs) { FastByIDMap<FastIDSet> result = new FastByIDMap<FastIDSet>(); for (int i = 0; i < userIDs.length; i++) { FastIDSet prefsSet = new FastIDSet(); for (int j = 0; j < prefs[i].length; j++) { if (prefs[i][j]) { prefsSet.add(j); } } if (!prefsSet.isEmpty()) { result.put(userIDs[i], prefsSet); } } return new GenericBooleanPrefDataModel(result); }
return new GenericBooleanPrefDataModel(data, timestamps); FastByIDMap<FastIDSet> rawData = ((GenericBooleanPrefDataModel) delegate).getRawUserData(); return new GenericBooleanPrefDataModel(rawData, timestamps);
/** * <p> * Creates a new {@link GenericDataModel} containing an immutable copy of the data from another given * {@link DataModel}. * </p> * * @param dataModel * {@link DataModel} to copy * @throws TasteException * if an error occurs while retrieving the other {@link DataModel}'s users * @deprecated without direct replacement. * Consider {@link #toDataMap(DataModel)} with {@link #GenericBooleanPrefDataModel(FastByIDMap)} */ @Deprecated public GenericBooleanPrefDataModel(DataModel dataModel) throws TasteException { this(toDataMap(dataModel)); }
public static void main(String[] args) throws Exception { DataModel model = new FileDataModel(new File("ratings.dat")); model = new GenericBooleanPrefDataModel(GenericBooleanPrefDataModel.toDataMap(model)); RecommenderIRStatsEvaluator evaluator = new GenericRecommenderIRStatsEvaluator(); RecommenderBuilder recommenderBuilder = new RecommenderBuilder() { @Override public Recommender buildRecommender(DataModel model) throws TasteException { UserSimilarity similarity = new TanimotoCoefficientSimilarity(model); UserNeighborhood neighborhood = new NearestNUserNeighborhood(2, similarity, model); return new GenericBooleanPrefUserBasedRecommender(model, neighborhood, similarity); } }; IRStatistics stats = evaluator.evaluate(recommenderBuilder, null, model, null, 10, Double.NaN, 0.1); System.out.println(stats); }
return new GenericBooleanPrefDataModel(data, timestamps); FastByIDMap<FastIDSet> rawData = ((GenericBooleanPrefDataModel) delegate).getRawUserData(); return new GenericBooleanPrefDataModel(rawData, timestamps);
/** * <p> * Creates a new {@link GenericDataModel} containing an immutable copy of the data from another given * {@link DataModel}. * </p> * * @param dataModel * {@link DataModel} to copy * @throws TasteException * if an error occurs while retrieving the other {@link DataModel}'s users * @deprecated without direct replacement. * Consider {@link #toDataMap(DataModel)} with {@link #GenericBooleanPrefDataModel(FastByIDMap)} */ @Deprecated public GenericBooleanPrefDataModel(DataModel dataModel) throws TasteException { this(toDataMap(dataModel)); }
public static void main(String[] args) throws Exception { DataModel model = new GenericBooleanPrefDataModel( GenericBooleanPrefDataModel.toDataMap( new FileDataModel(new File("ua.base")))); RecommenderEvaluator evaluator = new AverageAbsoluteDifferenceRecommenderEvaluator(); RecommenderBuilder recommenderBuilder = new RecommenderBuilder() { @Override public Recommender buildRecommender(DataModel model) throws TasteException { UserSimilarity similarity = new PearsonCorrelationSimilarity(model); UserNeighborhood neighborhood = new NearestNUserNeighborhood(10, similarity, model); return new GenericUserBasedRecommender(model, neighborhood, similarity); } }; DataModelBuilder modelBuilder = new DataModelBuilder() { @Override public DataModel buildDataModel(FastByIDMap<PreferenceArray> trainingData) { return new GenericBooleanPrefDataModel( GenericBooleanPrefDataModel.toDataMap(trainingData)); } }; double score = evaluator.evaluate( recommenderBuilder, modelBuilder, model, 0.9, 1.0); System.out.println(score); }
public static void main(String[] args) throws Exception { DataModel model = new GenericBooleanPrefDataModel( GenericBooleanPrefDataModel.toDataMap( new FileDataModel(new File("ua.base")))); @Override public DataModel buildDataModel(FastByIDMap<PreferenceArray> trainingData) { return new GenericBooleanPrefDataModel( GenericBooleanPrefDataModel.toDataMap(trainingData));