2016-12-05 81 views
0

我試圖創建冷啓動建議使用Python中的LightFM庫。 https://github.com/lyst/lightfmLightFM用戶/物品生成南嵌入

可正常工作的協同過濾,無需用戶和項目特點即:

from lightfm import LightFM 
interaction_matrix 

<322139x42715 sparse matrix of type '<type 'numpy.float32'>' 
    with 4571208 stored elements in COOrdinate format> 

model = LightFM(no_components=50) 
model.fit(interaction_matrix, epochs=1, num_threads=32) 
predictions = model.predict(12, np.arange(250), num_threads=32) 

這就產生預測的罰款。然而,當我補充一下:

members_features, item_features 

(<322139x2790 sparse matrix of type '<type 'numpy.float32'>' 
    with 19840665 stored elements in Compressed Sparse Row format>, 
<42715x2790 sparse matrix of type '<type 'numpy.float32'>' 
    with 355006 stored elements in Compressed Sparse Row format>) 

model2 = LightFM(no_components=100, loss='warp', item_alpha=0.001, user_alpha=0.001) 

model2.fit(interaction_matrix, user_features=members_features, item_features=item_features, sample_weight=None, \ 
        verbose=True, epochs=2, num_threads=32) 

我得到楠的用戶和項目的嵌入。

model2.item_embeddings 

array([[ nan, nan, nan, ..., nan, nan, nan], 
     [ nan, nan, nan, ..., nan, nan, nan], 
     [ nan, nan, nan, ..., nan, nan, nan], 
     ..., 
     [ nan, nan, nan, ..., nan, nan, nan], 
     [ nan, nan, nan, ..., nan, nan, nan], 
     [ nan, nan, nan, ..., nan, nan, nan]], dtype=float32) 

回答

0

你應該嘗試(通過pip install lightfm==1.12)更新到LightFM 1.12。該版本修復了一些數字不穩定性問題,可能會導致您看到的結果。

如果你對血型細節感興趣,你可以看看這個Github issue