diff --git a/Example/auc.pdf b/Example/auc.pdf new file mode 100644 index 0000000000000000000000000000000000000000..a3386888380ca928c40eed847bb68b4c4890d346 Binary files /dev/null and b/Example/auc.pdf differ diff --git a/Example/norm_fulfillment_empowerment_abilities.pdf b/Example/norm_fulfillment_empowerment_abilities.pdf new file mode 100644 index 0000000000000000000000000000000000000000..c05a23d7195ca7550b01dd8d7a6482a6a05396f2 Binary files /dev/null and b/Example/norm_fulfillment_empowerment_abilities.pdf differ diff --git a/Example/output.txt b/Example/output.txt new file mode 100644 index 0000000000000000000000000000000000000000..6997e7f0426be9a8b3433c95d2a11790089c2f42 --- /dev/null +++ b/Example/output.txt @@ -0,0 +1,3 @@ +perception_severity/socialSupport_emotionality +norm_fulfillment/empowerment_abilities +perception_vulnerability/empowerment_desires diff --git a/Example/perception_severity_socialSupport_emotionality.pdf b/Example/perception_severity_socialSupport_emotionality.pdf new file mode 100644 index 0000000000000000000000000000000000000000..1b389eacdc9211ba597ad8b747a3f92ff5735759 Binary files /dev/null and b/Example/perception_severity_socialSupport_emotionality.pdf differ diff --git a/Example/perception_vulnerability_empowerment_desires.pdf b/Example/perception_vulnerability_empowerment_desires.pdf new file mode 100644 index 0000000000000000000000000000000000000000..db32c4aa5534aa9e62a82b15ab367278b1d05464 Binary files /dev/null and b/Example/perception_vulnerability_empowerment_desires.pdf differ diff --git a/Example/sobar-72.csv b/Example/sobar-72.csv new file mode 100644 index 0000000000000000000000000000000000000000..8781f135590b58eb39d23123a56b897a5964279d --- /dev/null +++ b/Example/sobar-72.csv @@ -0,0 +1,73 @@ +,behavior_sexualRisk,behavior_eating,behavior_personalHygine,intention_aggregation,intention_commitment,attitude_consistency,attitude_spontaneity,norm_significantPerson,norm_fulfillment,perception_vulnerability,perception_severity,motivation_strength,motivation_willingness,socialSupport_emotionality,socialSupport_appreciation,socialSupport_instrumental,empowerment_knowledge,empowerment_abilities,empowerment_desires,ca_cervix +0,10,13,12,4,7,9,10,1,8,7,3,14,8,5,7,12,12,11,8,1 +1,10,11,11,10,14,7,7,5,5,4,2,15,13,7,6,5,5,4,4,1 +2,10,15,3,2,14,8,10,1,4,7,2,7,3,3,6,11,3,3,15,1 +3,10,11,10,10,15,7,7,1,5,4,2,15,13,7,4,4,4,4,4,1 +4,8,11,7,8,10,7,8,1,5,3,2,15,5,3,6,12,5,4,7,1 +5,10,14,8,6,15,8,10,1,3,4,2,14,8,7,2,7,13,9,6,1 +6,10,15,4,6,14,6,10,5,3,7,2,7,13,3,3,15,3,3,5,1 +7,8,12,9,10,10,5,10,5,5,5,2,10,9,13,2,9,8,7,12,1 +8,10,15,7,2,15,6,10,1,3,5,2,9,15,13,10,15,13,15,15,1 +9,7,15,7,6,11,8,8,5,3,3,4,15,3,8,2,9,3,4,4,1 +10,7,15,7,10,14,7,9,1,3,8,2,4,3,7,9,13,8,3,9,1 +11,10,15,8,9,15,7,10,1,3,7,2,15,3,3,6,13,7,5,9,1 +12,10,15,12,10,15,6,10,1,3,3,2,4,3,3,2,15,13,6,11,1 +13,9,12,14,9,15,10,9,3,6,3,2,15,15,3,10,15,11,3,11,1 +14,2,15,15,6,13,8,9,1,3,3,4,15,3,7,6,7,7,7,3,1 +15,10,15,7,6,14,8,8,4,8,10,2,3,3,3,2,5,5,5,3,1 +16,10,15,9,7,6,8,8,1,12,5,4,5,4,3,3,5,7,7,3,1 +17,10,12,7,5,10,8,8,1,8,10,4,6,3,3,2,4,4,3,5,1 +18,10,11,12,2,10,8,8,2,10,8,7,6,5,3,2,4,4,4,3,1 +19,10,12,12,8,10,8,6,2,7,6,2,12,11,9,8,12,10,10,9,1 +20,10,15,15,4,15,8,10,5,3,8,3,11,3,3,2,7,8,5,3,1 +21,10,12,11,10,15,7,8,3,3,3,2,13,11,10,7,12,12,12,12,0 +22,10,13,14,10,15,6,8,1,5,5,2,15,10,12,8,15,15,15,15,0 +23,10,15,13,10,15,2,10,1,5,6,2,14,14,14,8,14,15,14,15,0 +24,10,12,10,7,15,6,8,2,4,9,2,15,12,10,7,12,14,10,14,0 +25,10,15,13,10,15,6,10,1,3,5,2,15,13,9,7,12,15,11,15,0 +26,10,13,15,8,13,7,8,3,5,9,2,13,11,12,9,10,12,13,12,0 +27,10,15,11,10,15,8,10,1,3,3,2,15,13,13,10,15,15,13,15,0 +28,10,11,11,10,14,5,8,1,4,3,4,15,11,13,9,13,13,12,13,0 +29,10,14,10,9,15,4,5,2,5,7,3,10,7,4,6,7,5,9,12,0 +30,10,8,9,10,15,10,10,1,3,3,2,15,13,11,6,15,15,10,15,0 +31,10,15,15,8,9,8,9,4,7,6,4,12,12,14,9,14,13,9,12,0 +32,10,10,11,10,15,5,8,1,5,3,6,15,13,13,10,15,13,13,13,0 +33,10,11,10,9,15,5,10,3,3,3,2,11,11,9,4,9,15,15,15,0 +34,10,15,15,10,15,10,10,1,3,3,2,15,10,10,10,15,15,15,15,0 +35,10,3,5,2,9,6,10,1,3,9,6,11,10,9,9,14,6,10,10,0 +36,10,15,9,3,15,8,10,1,3,5,6,10,15,13,10,15,15,15,15,0 +37,10,10,12,5,7,6,6,4,5,10,4,11,9,11,8,11,11,10,11,0 +38,10,9,11,10,15,7,6,1,3,6,2,15,15,15,10,15,15,15,14,0 +39,10,14,14,10,11,5,9,1,5,4,2,14,15,11,8,14,13,13,13,0 +40,10,12,11,10,15,7,8,3,3,4,2,14,7,9,8,12,15,10,14,0 +41,10,15,13,10,15,6,10,1,7,7,2,15,7,3,4,3,11,5,9,0 +42,10,15,15,10,15,8,8,5,11,15,10,15,15,15,10,15,15,15,15,0 +43,10,15,15,10,15,9,10,5,11,15,10,15,15,15,10,15,15,15,15,0 +44,10,11,14,10,15,10,10,5,15,14,10,15,9,9,4,3,14,11,15,0 +45,10,15,14,10,11,10,8,5,11,15,10,15,15,15,10,15,15,15,15,0 +46,10,14,11,10,15,9,10,5,15,15,10,15,13,6,6,12,15,11,14,0 +47,10,15,15,6,11,7,6,5,11,13,10,15,15,11,10,15,11,11,15,0 +48,10,15,11,10,15,8,10,1,15,15,10,15,13,3,2,9,15,8,11,0 +49,6,15,11,10,12,8,10,5,14,13,10,15,7,5,2,5,13,9,3,0 +50,10,11,15,10,11,6,10,5,15,11,10,15,15,15,6,9,15,15,9,0 +51,10,15,15,10,15,10,10,5,15,14,9,9,13,12,9,15,15,15,15,0 +52,10,9,12,10,14,9,6,5,11,11,9,15,11,3,2,6,13,7,3,0 +53,10,13,12,2,15,7,10,5,15,10,2,15,12,11,7,6,10,9,12,0 +54,10,15,15,10,11,7,8,5,15,13,10,15,15,11,8,15,15,13,11,0 +55,10,9,8,2,15,6,10,1,15,15,8,11,11,13,10,15,13,13,10,0 +56,10,10,5,2,15,8,10,5,13,15,10,15,3,3,2,13,15,15,15,0 +57,10,11,8,10,15,7,8,5,14,13,8,12,7,4,3,3,4,4,7,0 +58,10,11,9,6,15,6,8,5,14,11,8,11,7,3,2,3,3,3,3,0 +59,10,13,9,10,15,8,8,5,14,8,8,11,3,3,2,3,3,3,3,0 +60,10,12,10,10,15,6,8,5,15,11,8,13,7,3,2,3,3,3,3,0 +61,10,10,10,10,15,6,6,5,14,13,9,15,9,13,8,14,13,12,12,0 +62,10,13,11,6,15,8,10,5,15,7,10,13,7,3,5,3,3,3,3,0 +63,10,13,15,10,15,8,10,5,14,6,8,13,7,3,4,3,3,6,3,0 +64,10,15,8,6,11,6,10,5,11,15,8,15,7,3,4,11,13,10,15,0 +65,10,13,11,6,14,9,10,5,15,15,10,15,3,3,4,7,7,7,11,0 +66,10,12,13,10,11,7,7,5,14,15,9,14,10,6,6,6,9,7,11,0 +67,10,14,14,10,15,6,7,5,15,14,10,15,13,9,8,12,12,11,9,0 +68,10,12,15,10,15,8,8,5,15,14,8,12,14,11,7,13,15,11,14,0 +69,10,8,11,6,10,6,4,3,13,9,8,14,12,9,7,11,12,10,10,0 +70,9,12,13,10,13,6,6,5,14,13,10,13,12,11,8,12,11,13,15,0 +71,10,14,14,6,12,7,8,5,15,12,10,10,13,11,9,14,13,15,15,0 diff --git a/README.md b/README.md index 61f98e0b51c01121b7364b69adb6e53118d0962f..1a599ef863848bad1adc294d7d2b5b017ec571db 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,15 @@ python3 run_mem.py -h ``` +### Example +In the Example subrepository, you can find a dataset and the output files that you would obtain by running the following command line: +```python +python3 run_mem.py sobar-72.csv --nbcpus 12 --target ca_cervix +``` +The dataset comes from the UCI Machine Learning Repository ([dataset](https://archive.ics.uci.edu/ml/datasets/Cervical+Cancer+Behavior+Risk)). It dataset contains 19 attributes regarding cervical cancer behavior risk with class label is ca_cervix with 1 and 0 as values which means the respondent with and without cervical cancer, respectively. + + + ## References [1] Stout, Q.F. Isotonic Regression via Partitioning. Algorithmica 66, 93–112 (2013). https://doi.org/10.1007/s00453-012-9628-4 diff --git a/run_mem.py b/run_mem.py index 96da6668cea3923a494888954dba857f312260dc..53848bb1852aa99ad2472179c411c403842feaef 100644 --- a/run_mem.py +++ b/run_mem.py @@ -12,6 +12,7 @@ import numpy as np import pandas as pd import sys import argparse +import os def parse_args(): parser=argparse.ArgumentParser(description="Monotonic Ensemble Model approach") @@ -39,10 +40,10 @@ def verify_nb_classes_dataset(df, target): def modify_label_classes_dataset(df, target): - if not set(df[target]) == {0,1}: - tt = list(set(df[target])) - df[target] = df[target].map({tt[0]:0,tt[1]:1}) - df.rename({target:'target'}, axis=1, inplace=True) + df.rename({target:'target'}, axis=1, inplace=True) + if not set(df['target']) == {0,1}: + tt = list(set(df['target'])) + df[target] = df['target'].map({tt[0]:0,tt[1]:1}) return df @@ -60,10 +61,15 @@ def main(): df.reset_index(drop=True, inplace=True) except: print("Can't open the file {}. Check the format.\n".format(inputs.dataset)) + + if not os.path.isdir(inputs.outdir): + os.makedirs(inputs.outdir) + print("Outdir created") + if not verify_nb_classes_dataset(df, inputs.target): sys.exit() - + df = modify_label_classes_dataset(df, inputs.target)