Skip to content

the batch_setup() and batch_predict() methods are not currently available in the stable version of LightFM (as of September 2021).  #1

@imshakti

Description

@imshakti

Hi Rubtsov

when i execute lightfm.ipynb ...i got following error

'LightFM' object has no attribute 'batch_setup'

and i realized batch_setup and batch_predict methods are not available in Stable version of LightFM. Hence will u suggest optimization of following code

model = LightFM(no_components=200, loss='warp', learning_rate=0.02, max_sampled=400, random_state=1, user_alpha=1e-05)

best_score = 0
for i in range(60):

model.fit_partial(X_train, epochs=5, num_threads=50)

**model.batch_setup(
    item_chunks={0: np.arange(config['num_tracks'])},
    n_process=50, 
)**
**res = model.batch_predict(chunk_id=0, user_ids=val1_pids, top_k=600)
model.batch_cleanup()**

score = []
for pid in val1_pids:
    tracks_t = val_tracks[pid]
    tracks = [i for i in res[pid][0] if i not in user_seen.get(pid, set())][:len(tracks_t)]
    guess = np.sum([i in tracks_t for i in tracks])
    score.append(guess / len(tracks_t))

score = np.mean(score)
print(score)
if score > best_score:
    joblib.dump(model, open(config['model_path'], 'wb'))
    best_score = score

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions