src.test.test_private_hcms_client
1import os 2import sys 3 4sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 5from private_hadamard_count_mean.private_hcms_client import run_private_hcms_client 6from tabulate import tabulate 7 8def test_algoritmos(): 9 """ 10 Runs a test for various parameter combinations using the Private Hadamard Count Mean Sketch algorithm. 11 12 This function tests the algorithm by passing different values of k (number of hash functions) and 13 m (number of counters) to the `run_private_hcms_client` function. The results include various error 14 metrics, including Mean Error, Percentage Error, MSE, RMSE, Normalized MSE, Normalized RMSE, and Pearson 15 Correlation Coefficient. The results are displayed in a tabular format. 16 17 The test data used is based on the 'exp_distrib_50k' dataset, and the error tolerance (e) is set to 2. 18 19 The results are printed in a table, where each row contains: 20 - k: Number of hash functions 21 - m: Number of counters 22 - Mean Error 23 - Percentage Error 24 - MSE (Mean Squared Error) 25 - RMSE (Root Mean Squared Error) 26 - Normalized MSE 27 - Normalized RMSE 28 - Pearson Correlation Coefficient 29 """ 30 excel_file = os.path.join(os.path.join('..', '..', 'data', 'raw'), 'dataOviedo.xlsx') 31 df = pd.read_excel(excel_file) 32 33 e = 2 34 k = [16, 128, 128, 1024, 32768] 35 m = [16, 16, 1024, 256, 256] 36 37 general_table = [] 38 39 for i in range(len(k)): 40 _, error_table = run_private_hcms_client(k[i], m[i], e, df) 41 42 error_dict = { key: value for key, value in error_table } 43 44 row = [ 45 k[i], 46 m[i], 47 error_dict.get("Mean Error", ""), 48 error_dict.get("Percentage Error", ""), 49 error_dict.get("MSE", ""), 50 error_dict.get("RMSE", ""), 51 error_dict.get("Normalized MSE", ""), 52 error_dict.get("Normalized RMSE", ""), 53 error_dict.get("Pearson Correlation Coefficient", "") 54 ] 55 general_table.append(row) 56 57 headers = [ 58 "k", "m", "Mean Error", "Percentage Error", 59 "MSE", "RMSE", "Normalized MSE", "Normalized RMSE", "Pearson Corr" 60 ] 61 62 print(tabulate(general_table, headers=headers, tablefmt="grid")) 63 64if __name__ == '__main__': 65 test_algoritmos()
9def test_algoritmos(): 10 """ 11 Runs a test for various parameter combinations using the Private Hadamard Count Mean Sketch algorithm. 12 13 This function tests the algorithm by passing different values of k (number of hash functions) and 14 m (number of counters) to the `run_private_hcms_client` function. The results include various error 15 metrics, including Mean Error, Percentage Error, MSE, RMSE, Normalized MSE, Normalized RMSE, and Pearson 16 Correlation Coefficient. The results are displayed in a tabular format. 17 18 The test data used is based on the 'exp_distrib_50k' dataset, and the error tolerance (e) is set to 2. 19 20 The results are printed in a table, where each row contains: 21 - k: Number of hash functions 22 - m: Number of counters 23 - Mean Error 24 - Percentage Error 25 - MSE (Mean Squared Error) 26 - RMSE (Root Mean Squared Error) 27 - Normalized MSE 28 - Normalized RMSE 29 - Pearson Correlation Coefficient 30 """ 31 excel_file = os.path.join(os.path.join('..', '..', 'data', 'raw'), 'dataOviedo.xlsx') 32 df = pd.read_excel(excel_file) 33 34 e = 2 35 k = [16, 128, 128, 1024, 32768] 36 m = [16, 16, 1024, 256, 256] 37 38 general_table = [] 39 40 for i in range(len(k)): 41 _, error_table = run_private_hcms_client(k[i], m[i], e, df) 42 43 error_dict = { key: value for key, value in error_table } 44 45 row = [ 46 k[i], 47 m[i], 48 error_dict.get("Mean Error", ""), 49 error_dict.get("Percentage Error", ""), 50 error_dict.get("MSE", ""), 51 error_dict.get("RMSE", ""), 52 error_dict.get("Normalized MSE", ""), 53 error_dict.get("Normalized RMSE", ""), 54 error_dict.get("Pearson Correlation Coefficient", "") 55 ] 56 general_table.append(row) 57 58 headers = [ 59 "k", "m", "Mean Error", "Percentage Error", 60 "MSE", "RMSE", "Normalized MSE", "Normalized RMSE", "Pearson Corr" 61 ] 62 63 print(tabulate(general_table, headers=headers, tablefmt="grid"))
Runs a test for various parameter combinations using the Private Hadamard Count Mean Sketch algorithm.
This function tests the algorithm by passing different values of k (number of hash functions) and
m (number of counters) to the run_private_hcms_client
function. The results include various error
metrics, including Mean Error, Percentage Error, MSE, RMSE, Normalized MSE, Normalized RMSE, and Pearson
Correlation Coefficient. The results are displayed in a tabular format.
The test data used is based on the 'exp_distrib_50k' dataset, and the error tolerance (e) is set to 2.
The results are printed in a table, where each row contains: - k: Number of hash functions - m: Number of counters - Mean Error - Percentage Error - MSE (Mean Squared Error) - RMSE (Root Mean Squared Error) - Normalized MSE - Normalized RMSE - Pearson Correlation Coefficient