def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/AdultMod.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('Age \nEducation \nCapital-gain \nhours-per-week \n') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = AdaBoostClassifier(n_estimators=100, random_state=0) #Fitting the model with the dataset model = model.fit(X, Y) #Calling the verification based testing approach to test strong group monotonicity detectionRate = veriTest.funcMain(model, df, 4, MAX_SAMPLES) return detectionRate
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/Automobile.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write( 'SymbolingRisk \nWheelBase \nLength \nWidth \nHeight \nCurbWeight \nNumCylinders \nEngineSize \nHorsePow \nPeak-rpm ' ) fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = GradientBoostingClassifier(n_estimators=100, learning_rate=1.0, max_depth=1, random_state=0) #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the verification based testing approach to test weak group monotonicity cexSet, failed_att, no_retrain = veriTest.funcMain(model, df, 4, MAX_SAMPLES) execution_time = (time.time() - start_time) return failed_att, no_retrain, execution_time, cexSet
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/Automobile.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write( 'SymbolingRisk \nWheelBase \nLength \nWidth \nHeight \nCurbWeight \nNumCylinders \nEngineSize \nHorsePow \nPeak-rpm ' ) fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = KNeighborsClassifier(n_neighbors=3, weights='uniform') #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the verification based testing approach to test strong group monotonicity detectionRate = veriTest.funcMain(model, df, 4, MAX_SAMPLES) return detectionRate
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/HousingData.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('RM \nRAD \nTAX') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = AdaBoostClassifier(n_estimators=100, random_state=0) #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the verification based testing approach to test weak group monotonicity cexSet, failed_att, no_retrain = veriTest.funcMain(model, df, 4, MAX_SAMPLES) execution_time = (time.time() - start_time) return failed_att, no_retrain, execution_time, cexSet
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/HousingData.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('RM \nRAD \nTAX') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = GradientBoostingClassifier(n_estimators=100, learning_rate=1.0, max_depth=1, random_state=0) #Fitting the model with the dataset model = model.fit(X, Y) #Calling the verification based testing approach to test strong group monotonicity detectionRate = veriTest.funcMain(model, df, 4, MAX_SAMPLES) return detectionRate
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/Mammographic.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('BI-RADS \nAge \nDensity') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = svm.LinearSVC(penalty='l2', loss='squared_hinge', dual=True, tol=0.0001, C=1.0, multi_class='ovr', fit_intercept=True, intercept_scaling=1, class_weight=None, verbose=0, random_state=None, max_iter=1000) #Fitting the model with the dataset model = model.fit(X, Y) #Calling the verification based testing approach detectionRate = veriTest.funcMain(model, df, 4, MAX_SAMPLES) return detectionRate
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/CPU.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('MinMainMem \nMaxMainMem \nCachMem \nMinChan \nMaxChan') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = KNeighborsClassifier(n_neighbors=5, weights='uniform') #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the verification based testing approach to test strong group monotonicity detectionRate = veriTest.funcMain(model, df, 4, MAX_SAMPLES) return detectionRate
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/ERA.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('in1 \nin2') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = GaussianNB() #Fitting the model with the dataset model = model.fit(X, Y) #Calling the verification based testing approach detectionRate = veriTest.funcMain(model, df, 4, MAX_SAMPLES) return detectionRate
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/CarEvaluation.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('NumDoors \nNumPersons \nLugBoot \nSafety') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = LogisticRegression(penalty='l2', dual=False, tol=0.0001, C=1.0, fit_intercept=True, intercept_scaling=1, class_weight=None, random_state=None, solver='lbfgs', max_iter=100, verbose=0, warm_start=False, n_jobs=None) #Fitting the model with the dataset model = model.fit(X, Y) #Calling the verification based testing approach to test strong group monotonicity detectionRate = veriTest.funcMain(model, df, 4, MAX_SAMPLES) return detectionRate
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/AdultMod.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('Age \nEducation \nCapital-gain \nhours-per-week \n') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = GaussianNB() #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the verification based testing approach to test weak group monotonicity cexSet, failed_att, no_retrain = veriTest.funcMain(model, df, 4, MAX_SAMPLES) execution_time = (time.time() - start_time) return failed_att, no_retrain, execution_time, cexSet
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/Automobile.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('SymbolingRisk \nWheelBase \nLength \nWidth \nHeight \nCurbWeight \nNumCylinders \nEngineSize \nHorsePow \nPeak-rpm ') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = RandomForestClassifier(n_estimators=100, criterion='entropy', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features='auto', max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, bootstrap=True, oob_score=False, n_jobs=1, random_state=None, verbose=0) #Fitting the model with the dataset model = model.fit(X, Y) #Calling the verification based testing approach detectionRate = veriTest.funcMain(model, df, 4, MAX_SAMPLES) return detectionRate
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/AutoMPG.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('Cylinders \nDisplacement \nHorsePower \nWeight \nAcceleration') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = svm.LinearSVC(penalty='l2', loss='squared_hinge', dual=True, tol=0.0001, C=1.0, multi_class='ovr', fit_intercept=True, intercept_scaling=1, class_weight=None, verbose=0, random_state=None, max_iter=1000) #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the verification based testing approach to test weak group monotonicity cexSet, failed_att, no_retrain = veriTest.funcMain(model, df, 4, MAX_SAMPLES) execution_time = (time.time() - start_time) return failed_att, no_retrain, execution_time, cexSet
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/AutoMPG.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write( 'Cylinders \nDisplacement \nHorsePower \nWeight \nAcceleration') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = AdaBoostClassifier(n_estimators=100, random_state=0) #Fitting the model with the dataset model = model.fit(X, Y) #Calling the verification based testing approach to test strong group monotonicity detectionRate = veriTest.funcMain(model, df, 4, MAX_SAMPLES) return detectionRate
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/ERA.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('in1 \nin2') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = KNeighborsClassifier(n_neighbors=7, weights='uniform') #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the random testing approach to test strong group monotonicity cexSet, failed_att, no_retrain = veriTest.funcMain(model, df, 4, MAX_SAMPLES) execution_time = (time.time() - start_time) return failed_att, no_retrain, execution_time, cexSet
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/Diabetes.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('NoOfPreg \nPlasmaGlucose \nBP \nWeight \nAge') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = GradientBoostingClassifier(n_estimators=100, learning_rate=1.0, max_depth=1, random_state=0) #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the verification based testing approach to test weak group monotonicity cexSet, failed_att, no_retrain = veriTest.funcMain(model, df, 4, MAX_SAMPLES) execution_time = (time.time() - start_time) return failed_att, no_retrain, execution_time, cexSet
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/Automobile.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('SymbolingRisk \nWheelBase \nLength \nWidth \nHeight \nCurbWeight \nNumCylinders \nEngineSize \nHorsePow \nPeak-rpm ') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = MLPClassifier(activation='logistic', alpha=1e-05, batch_size='auto', beta_1=0.9, beta_2=0.999, early_stopping=False, epsilon=1e-08, hidden_layer_sizes=(500, 50), learning_rate='adaptive', learning_rate_init=0.001, max_iter=200, momentum=0.9, nesterovs_momentum=True, power_t=0.5, random_state=1, shuffle=True, solver='adam', tol=0.0001, validation_fraction=0.1, verbose=False, warm_start=False) #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the random testing approach to test strong group monotonicity cexSet, failed_att, no_retrain = veriTest.funcMain(model, df, 4, MAX_SAMPLES) execution_time = (time.time() - start_time) return failed_att, no_retrain, execution_time, cexSet
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/ESL.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('in1 \nin2') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = svm.SVC(C=1.0, kernel='poly', degree=3) #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the verification based testing approach to test weak group monotonicity cexSet, failed_att, no_retrain = veriTest.funcMain(model, df, 4, MAX_SAMPLES) execution_time = (time.time() - start_time) return failed_att, no_retrain, execution_time, cexSet
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/AdultMod.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('Age \nEducation \nCapital-gain \nhours-per-week \n') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = LogisticRegression(penalty='l2', dual=False, tol=0.0001, C=1.0, fit_intercept=True, intercept_scaling=1, class_weight=None, random_state=None, solver='lbfgs', max_iter=100, verbose=0, warm_start=False, n_jobs=None) #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the verification based testing approach to test weak group monotonicity cexSet, failed_att, no_retrain = veriTest.funcMain(model, df, 4, MAX_SAMPLES) execution_time = (time.time() - start_time) return failed_att, no_retrain, execution_time, cexSet
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/AutoMPG.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('Cylinders \nDisplacement \nHorsePower \nWeight \nAcceleration') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = GaussianNB() #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the verification based testing approach to test weak group monotonicity cexSet, failed_att, no_retrain = veriTest.funcMain(model, df, 4, MAX_SAMPLES) execution_time = (time.time() - start_time) return failed_att, no_retrain, execution_time, cexSet
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/Mammographic.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('BI-RADS \nAge \nDensity') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = RandomForestClassifier(n_estimators=100, criterion='entropy', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features='auto', max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, bootstrap=True, oob_score=False, n_jobs=1, random_state=None, verbose=0) #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the verification based testing approach to test weak group monotonicity cexSet, failed_att, no_retrain = veriTest.funcMain(model, df, 4, MAX_SAMPLES) execution_time = (time.time() - start_time) return failed_att, no_retrain, execution_time, cexSet
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/AdultMod.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('Age \nEducation \nCapital-gain \nhours-per-week \n') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = MLPClassifier(activation='relu', alpha=1e-05, batch_size='auto', beta_1=0.9, beta_2=0.999, early_stopping=False, epsilon=1e-08, hidden_layer_sizes=(50, 50), learning_rate='constant', learning_rate_init=0.001, max_iter=200, momentum=0.9, nesterovs_momentum=True, power_t=0.5, random_state=1, shuffle=True, solver='sgd', tol=0.0001, validation_fraction=0.1, verbose=False, warm_start=False) #Fitting the model with the dataset model = model.fit(X, Y) #Computing time start_time = time.time() #Calling the verification based testing approach to test weak group monotonicity cexSet, failed_att, no_retrain = veriTest.funcMain(model, df, 4, MAX_SAMPLES) execution_time = (time.time() - start_time) return failed_att, no_retrain, execution_time, cexSet
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/CarEvaluation.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write('NumDoors \nNumPersons \nLugBoot \nSafety') fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = MLPClassifier(activation='relu', alpha=1e-05, batch_size='auto', beta_1=0.9, beta_2=0.999, early_stopping=False, epsilon=1e-08, hidden_layer_sizes=(500, 50), learning_rate='adaptive', learning_rate_init=0.001, max_iter=200, momentum=0.9, nesterovs_momentum=True, power_t=0.5, random_state=1, shuffle=True, solver='lbfgs', tol=0.0001, validation_fraction=0.1, verbose=False, warm_start=False) #Fitting the model with the dataset model = model.fit(X, Y) #Calling the verification based testing approach detectionRate = veriTest.funcMain(model, df, 4, MAX_SAMPLES) return detectionRate
def func_main(MAX_SAMPLES): #Defining the results array which ´will contain execution time and non-monotonicity score resultArr = np.zeros((2, )) #Reading the dataset df = pd.read_csv('Datasets/Automobile.csv') #Applying monotonicity constraints fileMon = open('monFeature.txt', 'w') fileMon.write( 'SymbolingRisk \nWheelBase \nLength \nWidth \nHeight \nCurbWeight \nNumCylinders \nEngineSize \nHorsePow \nPeak-rpm ' ) fileMon.close() data = df.values X = data[:, :-1] Y = data[:, -1] model = svm.LinearSVC(penalty='l2', loss='squared_hinge', dual=True, tol=0.0001, C=1.0, multi_class='ovr', fit_intercept=True, intercept_scaling=1, class_weight=None, verbose=0, random_state=None, max_iter=1000) #Fitting the model with the dataset model = model.fit(X, Y) #Calling the verification based testing approach detectionRate = veriTest.funcMain(model, df, 4, MAX_SAMPLES) return detectionRate