def test_model_xdeepfm(resource_path): data_path = os.path.join(resource_path, '../resources/deeprec/xdeepfm') yaml_file = os.path.join(data_path, r'xDeepFM.yaml') data_file = os.path.join(data_path, r'sample_FFM_data.txt') output_file = os.path.join(data_path, r'output.txt') if not os.path.exists(yaml_file): download_deeprec_resources( r'https://recodatasets.blob.core.windows.net/deeprec/', data_path, 'xdeepfmresources.zip') hparams = prepare_hparams(yaml_file, learning_rate=0.01) assert hparams is not None input_creator = FFMTextIterator model = XDeepFMModel(hparams, input_creator) assert model.run_eval(data_file) is not None assert isinstance(model.fit(data_file, data_file), BaseModel) assert model.predict(data_file, output_file) is not None
def test_model_xdeepfm(deeprec_resource_path): data_path = os.path.join(deeprec_resource_path, "xdeepfm") yaml_file = os.path.join(data_path, "xDeepFM.yaml") data_file = os.path.join(data_path, "sample_FFM_data.txt") output_file = os.path.join(data_path, "output.txt") if not os.path.exists(yaml_file): download_deeprec_resources( "https://recodatasets.z20.web.core.windows.net/deeprec/", data_path, "xdeepfmresources.zip", ) hparams = prepare_hparams(yaml_file, learning_rate=0.01) assert hparams is not None input_creator = FFMTextIterator model = XDeepFMModel(hparams, input_creator) assert model.run_eval(data_file) is not None assert isinstance(model.fit(data_file, data_file), BaseModel) assert model.predict(data_file, output_file) is not None
def test_model_xdeepfm(resource_path): data_path = os.path.join(resource_path, "..", "resources", "deeprec", "xdeepfm") yaml_file = os.path.join(data_path, "xDeepFM.yaml") data_file = os.path.join(data_path, "sample_FFM_data.txt") output_file = os.path.join(data_path, "output.txt") if not os.path.exists(yaml_file): download_deeprec_resources( "https://recodatasets.blob.core.windows.net/deeprec/", data_path, "xdeepfmresources.zip", ) hparams = prepare_hparams(yaml_file, learning_rate=0.01) assert hparams is not None input_creator = FFMTextIterator model = XDeepFMModel(hparams, input_creator) assert model.run_eval(data_file) is not None assert isinstance(model.fit(data_file, data_file), BaseModel) assert model.predict(data_file, output_file) is not None
download_deeprec_resources( r'https://recodatasets.blob.core.windows.net/deeprec/', data_path, 'xdeepfmresources.zip') # set hyper-parameters hparams = prepare_hparams(yaml_file, FEATURE_COUNT=2300000, FIELD_COUNT=39, cross_l2=0.01, embed_l2=0.01, layer_l2=0.01, learning_rate=0.002, batch_size=BATCH_SIZE, epochs=EPOCHS, cross_layer_sizes=[20, 10], init_value=0.1, layer_sizes=[20, 20], use_Linear_part=True, use_CIN_part=True, use_DNN_part=True) # make model model = XDeepFMModel(hparams, FFMTextIterator, seed=RANDOM_SEED) # train model model.fit(train_file, valid_file) # profiling model.train_timeliner.save('xDeepFM-timeliner.json') # inference after training #print(model.run_eval(test_file))