Exemplo n.º 1
0
def main(args):
    # process input file
    input_file = util.ensure_local_file(args['train_file'])
    user_map, item_map, tr_sparse, test_sparse = model.create_test_and_train_sets(
        args, input_file, args['data_type'])

    # train model
    output_row, output_col = model.train_model(args, tr_sparse)

    # save trained model to job directory
    if args['data_type'] == 'user_ratings':
        model.save_model_json(args, user_map, item_map, output_row, output_col)
        user_items_w = model.get_user_items_w(input_file)
        model.save_user_items_w(args, user_items_w)
    else:
        model.save_model(args, user_map, item_map, output_row, output_col)

    # log results
    train_rmse = wals.get_rmse(output_row, output_col, tr_sparse)
    test_rmse = wals.get_rmse(output_row, output_col, test_sparse)

    if args['hypertune']:
        # write test_rmse metric for hyperparam tuning
        util.write_hptuning_metric(args, test_rmse)

    tf.logging.info('train RMSE = %.2f' % train_rmse)
    tf.logging.info('test RMSE = %.2f' % test_rmse)
Exemplo n.º 2
0
def main(args):

    tf.logging.set_verbosity(tf.logging.INFO)

    # input files
    input_file = util.ensure_local_file(args.train_file)
    user_map, item_map, tr_sparse, test_sparse = model.create_test_and_train_sets(
        input_file)

    # train model
    output_row, output_col = model.train_model(args, tr_sparse)

    # save trained model to job directory
    model.save_model(args, user_map, item_map, output_row, output_col)

    # log results
    test_rmse = wals.get_rmse(output_row, output_col, test_sparse)
    util.write_hptuning_metric(args, test_rmse)
def main(args):
  # process input file
  input_file = util.ensure_local_file(args['train_files'][0])
  user_map, item_map, tr_sparse, test_sparse = model.create_test_and_train_sets(
      args, input_file, args['data_type'])

  # train model
  output_row, output_col = model.train_model(args, tr_sparse)

  # save trained model to job directory
  model.save_model(args, user_map, item_map, output_row, output_col)

  # log results
  train_rmse = wals.get_rmse(output_row, output_col, tr_sparse)
  test_rmse = wals.get_rmse(output_row, output_col, test_sparse)

  if args['hypertune']:
    # write test_rmse metric for hyperparam tuning
    util.write_hptuning_metric(args, test_rmse)

  tf.logging.info('train RMSE = %.2f' % train_rmse)
  tf.logging.info('test RMSE = %.2f' % test_rmse)