def test_predict_coreness(trained_pipeline): assert path_for('data_itos').exists() assert path_for('trained_classifier').exists() output_dict = predict_coreness(title=TEST_TITLE, abstract=TEST_ABSTRACT) assert set(output_dict.keys()) == {'prediction', 'scores'} assert output_dict['prediction'] in {'rejected', 'non_core', 'core'} assert set( output_dict['scores'].keys()) == {'rejected', 'non_core', 'core'} assert isclose(output_dict['scores']['rejected'] + output_dict['scores']['non_core'] + output_dict['scores']['core'], 1.0, abs_tol=1e-2)
def core_classifier(**kwargs): """Endpoint for the CORE classifier.""" return predict_coreness(kwargs['title'], kwargs['abstract'])
def predict(title, abstract, base_path): with click_spinner.spinner(): with current_app.app_context(): if base_path: current_app.config['CLASSIFIER_BASE_PATH'] = base_path click.echo(predict_coreness(title, abstract))