def test_simulation_permutation_perturbation(file_regression, tmpdir, caplog, shared_fs): """Test simulation with clustering hierarchy""" func_name = sys._getframe().f_code.co_name output_dir = pre_test(func_name, tmpdir, caplog) cmd = ("python -m anamod.simulation" " -seed 3 -num_instances 100 -num_features 30 -fraction_relevant_features 0.5 -noise_multiplier 0.1" " -contiguous_node_names 1 -hierarchy_type random -perturbation permutation -cleanup 0" f" -analysis_type hierarchical -shared_filesystem {shared_fs} -output_dir {output_dir}") pass_args = cmd.split()[2:] with patch.object(sys, 'argv', pass_args): simulation.main() post_test(file_regression, caplog, output_dir)
def test_simulation_flat_hierarchy(file_regression, tmpdir, caplog, shared_fs): """Test simulation with flat hierarchy""" func_name = sys._getframe().f_code.co_name output_dir = pre_test(func_name, tmpdir, caplog) cmd = ("python -m anamod.simulation" " -seed 0 -num_instances 100 -num_features 30 -fraction_relevant_features 0.5 -noise_multiplier 0.1" " -analysis_type hierarchical -hierarchy_type flat -cleanup 0" f" -model_loader_filename {os.path.abspath(model_loader.__file__)}" f" -shared_filesystem {shared_fs} -output_dir {output_dir}") pass_args = cmd.split()[2:] with patch.object(sys, 'argv', pass_args): simulation.main() post_test(file_regression, caplog, output_dir)
def test_condor_simulation_random_hierarchy(file_regression, tmpdir, caplog, shared_fs): """Test simulation with random hierarchy""" func_name = sys._getframe().f_code.co_name output_dir = pre_test(func_name, tmpdir, caplog) cmd = ("python -m anamod.simulation -condor 1 -memory_requirement 1 -disk_requirement 1" " -seed 1 -num_instances 100 -num_features 30 -fraction_relevant_features 0.5 -noise_multiplier 0.1" " -analysis_type hierarchical -contiguous_node_names 1 -hierarchy_type random -perturbation permutation -cleanup 0" f" -model_loader_filename {os.path.abspath(model_loader.__file__)}" f" -shared_filesystem {shared_fs} -output_dir {output_dir}") pass_args = cmd.split()[2:] with patch.object(sys, 'argv', pass_args): simulation.main() post_test(file_regression, caplog, output_dir)
def test_simulation_regressor1(file_regression, tmpdir, caplog, shared_fs): """Test simulation with regression model over temporal data""" func_name = sys._getframe().f_code.co_name output_dir = pre_test(func_name, tmpdir, caplog) cmd = ( "python -m anamod.simulation" " -seed 100 -analysis_type temporal -num_instances 100 -num_features 10" " -model_type regressor" " -noise_multiplier auto" " -fraction_relevant_features 0.5 -cleanup 0" f" -shared_filesystem {shared_fs} -output_dir {output_dir}") logging.getLogger().info(f"Cmd: {cmd}") pass_args = cmd.split()[2:] with patch.object(sys, 'argv', pass_args): simulation.main() post_test(file_regression, caplog, output_dir)
def test_simulation_classifier2(file_regression, tmpdir, caplog, shared_fs): """Test simulation with classification model over temporal data and quadratic losses computed w.r.t. predictions""" func_name = sys._getframe().f_code.co_name output_dir = pre_test(func_name, tmpdir, caplog) cmd = ( "python -m anamod.simulation" " -seed 100 -analysis_type temporal -num_instances 100 -num_features 10" " -model_type classifier" " -noise_multiplier auto -loss_target_values baseline_predictions" f" -model_loader_filename {os.path.abspath(model_loader.__file__)}" " -fraction_relevant_features 0.5 -cleanup 0" f" -shared_filesystem {shared_fs} -output_dir {output_dir}") logging.getLogger().info(f"Cmd: {cmd}") pass_args = cmd.split()[2:] with patch.object(sys, 'argv', pass_args): simulation.main() post_test(file_regression, caplog, output_dir)
def test_simulation_classifier_hierarchy1(file_regression, tmpdir, caplog, shared_fs): """Test simulation over temporal data with flat feature hierarchy (otherwise identical to test_simulation_classifier1)""" func_name = sys._getframe().f_code.co_name output_dir = pre_test(func_name, tmpdir, caplog) hierarchy_filename = f"{os.path.dirname(os.path.abspath(__file__))}/{RESOURCES_DIR}/{func_name}.json" cmd = ( "python -m anamod.simulation" " -seed 100 -analysis_type temporal -num_instances 100 -num_features 10" f" -model_type classifier -hierarchy_filename {hierarchy_filename}" " -noise_multiplier auto" f" -model_loader_filename {os.path.abspath(model_loader.__file__)}" " -fraction_relevant_features 0.5 -cleanup 0" f" -shared_filesystem {shared_fs} -output_dir {output_dir}") logging.getLogger().info(f"Cmd: {cmd}") pass_args = cmd.split()[2:] with patch.object(sys, 'argv', pass_args): simulation.main() post_test(file_regression, caplog, output_dir)