<commit_before>import numpy as np

import scipy.sparse as sp

from sklearn.metrics import roc_auc_score

from lightfm import LightFM, evaluation


def _generate_data(num_users, num_items, density=0.1, test_fraction=0.2):
    # Generate a dataset where every user has interactions
    # in both the train and the test set.

    train = sp.lil_matrix((num_users, num_items), dtype=np.float32)
    test = sp.lil_matrix((num_users, num_items), dtype=np.float32)

    for user_id in range(num_users):
        positives = np.random.choice(num_items,
                                     size=density * num_items,
                                     replace=False)

        for item_id in positives[:(test_fraction * len(positives))]:
            test[user_id, item_id] = 1.0

        for item_id in positives[(test_fraction * len(positives)):]:
            train[user_id, item_id] = 1.0<commit_msg>Fix float indices in tests.<commit_after>import numpy as np

import scipy.sparse as sp

from sklearn.metrics import roc_auc_score

from lightfm import LightFM, evaluation


def _generate_data(num_users, num_items, density=0.1, test_fraction=0.2):
    # Generate a dataset where every user has interactions
    # in both the train and the test set.

    train = sp.lil_matrix((num_users, num_items), dtype=np.float32)
    test = sp.lil_matrix((num_users, num_items), dtype=np.float32)

    for user_id in range(num_users):
        positives = np.random.choice(num_items,
                                     size=int(density * num_items),
                                     replace=False)

        for item_id in positives[:int(test_fraction * len(positives))]:
            test[user_id, item_id] = 1.0

        for item_id in positives[int(test_fraction * len(positives)):]:
            train[user_id, item_id] = 1.0
{'fraction_non_alphanumeric': 0.09000552181115405, 'fraction_numerical': 0.013252346769740474, 'mean_word_length': 2.668016194331984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4194120', 'n_tokens_mistral': 584, 'n_tokens_neox': 547, 'n_words': 145}