標籤:des style blog http io ar color os 使用
要做推薦,使用者行為資料是基礎。
使用者行為資料有哪些欄位呢?
mahout的DataModel支援,使用者ID,ItemID是必須的,偏好值(使用者對當前Item的評分),時間戳記 這四個欄位
{@code userID,itemID[,preference[,timestamp]]}
mahout資料來源支援從檔案、DB中讀取。
從FileDataModle.java的注釋來看,還是做了不少工作的。
1)原檔案更新後一定的時間段,才會reload
2)支援累加式更新(不用每次都重新copy所有資料)
3)根據欄位數目(有無評分)來選擇不同的結構儲存,節省記憶體
另外,
4)自己實現基礎類型的資料結構,節省記憶體
~/mahout-core/src/main/java/org/apache/mahout/cf/taste/impl/common/FastIDSet.java
~/mahout-core/src/main/java/org/apache/mahout/cf/taste/impl/common/FastByIDMap.java
自己的實現的兩個資料類型,都是通過hash快速尋找, 而且避免java的Long class, 直接採用原生態的long行來節省記憶體空間。
同類型的還有 FastMap.java
* <p> * 累加式更新的方式, This class will also look for update "delta" files in the same * directory, with file names that start the same way (up to the first period). * These files have the same format, and provide updated data that supersedes * what is in the main data file. This is a mechanism that allows an application * to push updates to {@link FileDataModel} without re-copying the entire data * file. * * 同一個目錄下,數字來區分 * Finds update delta files in the same directory as the data file. This finds * any file whose name starts the same way as the data file (up to first period) * but isn‘t the data file itself. For example, if the data file is * /foo/data.txt.gz, you might place update files at /foo/data.1.txt.gz, * /foo/data.2.txt.gz, etc. * </p> * * <p> * 表示刪除的文法, 偏好為空白 One small format difference exists. Update files must also be * able to express deletes. This is done by ending with a blank preference * value, as in "123,456,". * </p> * * <p> * 累加式更新的檔案中,刪除和更新不能混合使用 Note that it‘s all-or-nothing -- all of the items in the * file must express no preference, or the all must. These cannot be mixed. Put * another way there will always be the same number of delimiters on every line * of the file! * </p>
FileDataModel封裝了從檔案讀取的功能,具體的儲存還是由GenericDataModel來實現的。
詳細的資料承載有這篇文章,這裡就不多著墨了。
Apache mahout 源碼閱讀筆記--DataModel之FileDataModel