Hi Juan,

IIRC then FileDataModel has a parameter that determines how much time must have been spent since the last modification of the underlying file. You can also directly append new data to the original file.

If you want a to have a DataModel that can be concurrently updated, I suggest your data to a database.

--sebastian

On 03/02/2014 11:11 PM, Juan José Ramos wrote:
I am having issues refreshing my recommender, in particular with the
DataModel.

I am using a FileDataModel and a GenericItemBasedRecommender that also has
a CachingItemSimilarity wrapping a FileItemSimilarity. But for the test I
am running I am making things even simpler.

By the time I instantiate the recommender, these two files are in the
FileSystem:
data/datamodel.txt
0,1,0.0

data/datamodel.0.txt
0,2,1.0

And then I run the code you can find below:

-----------------------------------------------------------------------------------------------------------------------

   FileDataModel dataModel = new FileDataModel(new File("data/dataModel.txt"
));

    FileItemSimilarity itemSimilarity = new FileItemSimilarity(new File(
"data/similarities"));

  GenericItemBasedRecommender itemRecommender =
newGenericItemBasedRecommender(dataModel, itemSimilarity);

    System.out.println("Number of users in the system: " +
itemRecommender.getDataModel().getNumUsers()+" and " +
itemRecommender.getDataModel().getNumItems() + "items");

  FileWriter writer = new FileWriter(new File("data/dataModel.1.txt"));

  writer.write("1,2,1.0\r");

  writer.close();

    writer = new FileWriter(new File("data/dataModel.2.txt"));

  writer.write("2,2,1.0\r");

  writer.close();

    writer = new FileWriter(new File("data/dataModel.3.txt"));

  writer.write("3,2,1.0\r");

  writer.close();

    writer = new FileWriter(new File("data/dataModel.4.txt"));

  writer.write("4,2,1.0\r");

  writer.close();

    writer = new FileWriter(new File("data/dataModel.5.txt"));

  writer.write("5,2,1.0\r");

  writer.close();

    writer = new FileWriter(new File("data/dataModel.6.txt"));

  writer.write("6,2,1.0\r");

  writer.close();

  itemRecommender.refresh(null);

  System.out.println("Number of users in the system: " +
itemRecommender.getDataModel().getNumUsers()+" and " +
itemRecommender.getDataModel().getNumItems() + "items");

-----------------------------------------------------------------------------------------------------------------------

The output is the same in both println: Number of users in the system: 2
and 2items. So, only the information from the files that were on the system
by the time I run this test seem to get loaded on the DataModel.

What can be causing that? Is there a maximum number of updates a
FileDataModel can take up in every refresh?

Could it be that actually by the time I call itemRecommender.refresh(null)
the files have not been written to the FileSystem?

Should I be calling refresh in a different manner?

Thank you for your help.


Reply via email to