def test_invalid_input_partition_data(): malware_rate = 0.87 valid_input = "invalid!" mlf.load_json_data(malware_rate) with pytest.raises(ValueError): mlf.partition_data(valid_input)
def test_cross_validate_with_invalid_k_fold(): k_fold = "invalid!" malware_rate = 0.33 mlf.load_json_data(malware_rate) mlf.select_classifier("Decision Tree") ret_val = mlf.cross_validate(k_fold) assert isinstance(ret_val, str)
def test_cross_validate_with_classifier(): k_fold = 5 malware_rate = 0.33 mlf.load_json_data(malware_rate) # TODO: value error mlf.select_classifier("Decision Tree") ret_val = mlf.cross_validate(k_fold) assert isinstance(ret_val, numpy.ndarray)
def test_train_classifier_with_classifier(): malware_rate = 0.45 partition_size = 0.92 mlf.load_json_data(malware_rate) mlf.partition_data(partition_size) mlf.select_classifier("Decision Tree") mlf.train_classifier()
def test_display_confusion_matrix_without_classifier(): malware_rate = 0.33 partition_size = 0.33 mlf.load_json_data(malware_rate) mlf.partition_data(partition_size) mlf.classify_new_data() ret_val = mlf.display_confusion_matrix() assert isinstance(ret_val, str)
def test_valid_input_partition_data(): malware_rate = 0.67 valid_input = 0.23 mlf.load_json_data(malware_rate) mlf.partition_data(valid_input) success_count = 0 for key, item in mlf.PARTITIONED_DATA_DICT.items(): if item: success_count += 1 assert success_count == len(mlf.PARTITIONED_DATA_DICT)
def test_calculate_classifier_accuracy_with_classifier(): malware_rate = 0.33 partition_size = 0.33 mlf.load_json_data(malware_rate) mlf.partition_data(partition_size) mlf.select_classifier("Decision Tree") mlf.train_classifier() ret_val = mlf.calculate_classifier_accuracy() assert isinstance(ret_val, float)
def test_classify_new_data_with_classifier(): malware_rate = 0.33 partition_size = 0.33 mlf.load_json_data(malware_rate) mlf.partition_data(partition_size) mlf.select_classifier("Decision Tree") mlf.train_classifier() ret_val = mlf.classify_new_data() assert isinstance(ret_val, numpy.ndarray)
def test_display_confusion_matrix_pass(): malware_rate = 0.33 partition_size = 0.33 mlf.REPORT.create_new_report_directory() mlf.load_json_data(malware_rate) mlf.partition_data(partition_size) mlf.select_classifier("Decision Tree") mlf.train_classifier() mlf.classify_new_data() mlf.display_confusion_matrix()
def load_data_menu(): selected_opt = click.prompt("Enter malware rate", default=None) mlf.load_json_data(float(selected_opt))
def test_load_json_data_invalid_parameter(): malware_rate = "invalid!" mlf.load_json_data(malware_rate)
def test_load_json_data_valid_parameter(): malware_rate = 0.33 mlf.load_json_data(malware_rate)