コード例 #1
0
ファイル: sharedtask.py プロジェクト: wmarinho-uff/TF-recomm
config = dataio.get_config(CONFIG_FILE)
experiment_args = vars(options)

df_train, df_val, df_test = dataio.get_data(DATASET_NAME)
try:
    skill_wins = load_npz(SKILL_WINS)
    skill_fails = load_npz(SKILL_FAILS)
except:
    skill_wins = None
    skill_fails = None

short_legend, full_legend, latex_legend, active_agents = dataio.get_legend(
    experiment_args)
EXPERIMENT_FOLDER = os.path.join(CSV_FOLDER, short_legend)
dataio.prepare_folder(EXPERIMENT_FOLDER)


def df_to_sparse(df, filename):
    SPARSE_NPZ = os.path.join(EXPERIMENT_FOLDER, filename)
    if os.path.isfile(SPARSE_NPZ):
        X_fm = load_npz(SPARSE_NPZ)
        return X_fm
    X = {}
    nb_events, _ = df.shape
    rows = list(range(nb_events))
    for key in ['users', 'items', 'speech']:
        X[key] = coo_matrix(([1] * nb_events, (rows, df[key])),
                            shape=(nb_events, config['NUM'][key]))
    # X['skills'] = qmatrix[df['item']]
コード例 #2
0
                    type=bool,
                    nargs='?',
                    const=True,
                    default=False)
options = parser.parse_args()

experiment_args = vars(options)
DATASET_NAME = options.dataset
CSV_FOLDER = dataio.build_new_paths(DATASET_NAME)

# Build legend
short_legend, full_legend, latex_legend, active_agents = dataio.get_legend(
    experiment_args)

EXPERIMENT_FOLDER = os.path.join(CSV_FOLDER, "results", short_legend)
dataio.prepare_folder(EXPERIMENT_FOLDER)
maxRuns = 5
for run_id in range(maxRuns):
    dataio.prepare_folder(os.path.join(EXPERIMENT_FOLDER, str(run_id)))

# Load sparsely encoded datasets
X = csr_matrix(load_npz(options.X_file))
all_users = np.unique(X[:, 0].toarray().flatten())
y = X[:, 3].toarray().flatten()
qmat = load_npz(os.path.join(CSV_FOLDER, "q_mat.npz"))

# FM parameters
params = {
    'task': 'classification',
    'num_iter': options.iter,
    'rlog': True,