├── Gender_Detection.pdf ├── README.md └── code ├── .idea ├── .gitignore ├── Gender_Speech_Recognition.iml ├── inspectionProfiles │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── other.xml └── vcs.xml ├── Classifiers ├── GMM.py └── __pycache__ │ ├── GMM.cpython-310.pyc │ └── GMM.cpython-39.pyc ├── INFO.txt ├── PCA.png ├── Test.txt ├── Train.txt ├── __pycache__ ├── classifiers.cpython-310.pyc ├── classifiers.cpython-39.pyc ├── mlFunc.cpython-310.pyc ├── mlFunc.cpython-39.pyc ├── plot_features.cpython-310.pyc ├── plot_features.cpython-39.pyc ├── validators.cpython-310.pyc └── validators.cpython-39.pyc ├── classifiers.py ├── evaluators ├── __pycache__ │ ├── compare_best_2.cpython-310.pyc │ ├── compare_best_2.cpython-39.pyc │ ├── evaluation_GMM.cpython-310.pyc │ ├── evaluation_GMM.cpython-39.pyc │ ├── evaluation_LR.cpython-310.pyc │ ├── evaluation_LR.cpython-39.pyc │ ├── evaluation_MVG.cpython-310.pyc │ ├── evaluation_MVG.cpython-39.pyc │ ├── evaluation_SVM.cpython-310.pyc │ ├── evaluation_SVM.cpython-39.pyc │ ├── evaluation_SVM_RBF.cpython-39.pyc │ ├── evaluation_SVM_RFB.cpython-310.pyc │ ├── evaluation_SVM_RFB.cpython-39.pyc │ ├── evaluation_SVM_polynomial.cpython-310.pyc │ ├── evaluation_SVM_polynomial.cpython-39.pyc │ ├── evaluation_quad_LR.cpython-310.pyc │ ├── evaluation_quad_LR.cpython-39.pyc │ ├── evaluation_weighted_LR.cpython-310.pyc │ ├── evaluation_weighted_LR.cpython-39.pyc │ ├── kfold_lr.cpython-39.pyc │ └── mvg_script.cpython-39.pyc ├── compare_best_2.py ├── evaluation_GMM.py ├── evaluation_LR.py ├── evaluation_MVG.py ├── evaluation_QLR_GAUSSIANIZED_.npz ├── evaluation_QLR_RAW_.npz ├── evaluation_QLR_Z-NORM_.npz ├── evaluation_SVM.py ├── evaluation_SVM_RBF.py ├── evaluation_SVM_polynomial.py ├── evaluation_quad_LR.py └── evaluation_weighted_LR.py ├── functions └── __pycache__ │ ├── calibrationFunc.cpython-310.pyc │ ├── calibrationFunc.cpython-39.pyc │ ├── mlFunc.cpython-310.pyc │ └── mlFunc.cpython-39.pyc ├── images ├── .DS_Store ├── DCF_GAUSSIANIZED_LR, lambda=0.0001.png ├── DCF_GAUSSIANIZED_LR, lambda=0.01.png ├── DCF_GAUSSIANIZED_LR, lambda=1e-06.png ├── DCF_GAUSSIANIZED_QUAD_LR_minDCF_comparison.svg ├── DCF_GAUSSIANIZED_SVM_minDCF_comparison.svg ├── DCF_GAUSSIANIZED_WEIGHTED_LR_minDCF_comparison.svg ├── DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Naive + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Naive.png ├── DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG.png ├── DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Naive + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Naive.png ├── DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG.png ├── DCF_GAUSSIANIZED_minDCF_π=0.1__MVG + Naive + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.1__MVG + Naive.png ├── DCF_GAUSSIANIZED_minDCF_π=0.1__MVG + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.1__MVG.png ├── DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Naive + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Naive.png ├── DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG.png ├── DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Naive + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Naive.png ├── DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG.png ├── DCF_GAUSSIANIZED_minDCF_π=0.5__MVG + Naive + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.5__MVG + Naive.png ├── DCF_GAUSSIANIZED_minDCF_π=0.5__MVG + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.5__MVG.png ├── DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Naive + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Naive.png ├── DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG.png ├── DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Naive + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Naive.png ├── DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG.png ├── DCF_GAUSSIANIZED_minDCF_π=0.9__MVG + Naive + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.9__MVG + Naive.png ├── DCF_GAUSSIANIZED_minDCF_π=0.9__MVG + Tied.png ├── DCF_GAUSSIANIZED_minDCF_π=0.9__MVG.png ├── DCF_GMM_diag.png ├── DCF_GMM_diag2.png ├── DCF_GMM_full.png ├── DCF_GMM_full2.png ├── DCF_GMM_tied.png ├── DCF_GMM_tied2.png ├── DCF_GMM_tied_diag.png ├── DCF_GMM_tied_diag2.png ├── DCF_LR, lambda=0.0001.png ├── DCF_LR, lambda=0.01.png ├── DCF_LR, lambda=1.0.png ├── DCF_LR, lambda=1e-06.png ├── DCF_MVG + Naive + Tied.png ├── DCF_MVG + Naive.png ├── DCF_MVG + Tied.png ├── DCF_MVG.png ├── DCF_QUAD_QUAD_LR_minDCF_comparison.svg ├── DCF_RAW_LR, lambda=0.0001.png ├── DCF_RAW_LR, lambda=0.01.png ├── DCF_RAW_LR, lambda=1.0.png ├── DCF_RAW_LR, lambda=1e-06.png ├── DCF_RAW_LR_minDCF_comparison.png ├── DCF_RAW_QUAD_LR_minDCF_comparison.png ├── DCF_RAW_QUAD_LR_minDCF_comparison.svg ├── DCF_RAW_SVM, K=0.1, C=0.01.png ├── DCF_RAW_SVM, K=0.1, C=0.1.png ├── DCF_RAW_SVM, K=0.1, C=1.0.png ├── DCF_RAW_SVM, K=0.1, C=10.0.png ├── DCF_RAW_SVM, K=1.0, C=0.01.png ├── DCF_RAW_SVM, K=1.0, C=0.1.png ├── DCF_RAW_SVM, K=1.0, C=1.0.png ├── DCF_RAW_SVM, K=1.0, C=10.0.png ├── DCF_RAW_SVM, K=10.0, C=0.01.png ├── DCF_RAW_SVM, K=10.0, C=0.1.png ├── DCF_RAW_SVM, K=10.0, C=1.0.png ├── DCF_RAW_SVM, K=10.0, C=10.0.png ├── DCF_RAW_SVM_minDCF_comparison.svg ├── DCF_RAW_VAL_SVM_RBF_minDCF_comparison.svg ├── DCF_RAW_WEIGHTED_LR_minDCF_comparison.svg ├── DCF_RAW_minDCF_π=0.1_PCA m=10__MVG + Naive + Tied.png ├── DCF_RAW_minDCF_π=0.1_PCA m=10__MVG + Naive.png ├── DCF_RAW_minDCF_π=0.1_PCA m=10__MVG + Tied.png ├── DCF_RAW_minDCF_π=0.1_PCA m=10__MVG.png ├── DCF_RAW_minDCF_π=0.1_PCA m=9__MVG + Naive + Tied.png ├── DCF_RAW_minDCF_π=0.1_PCA m=9__MVG + Naive.png ├── DCF_RAW_minDCF_π=0.1_PCA m=9__MVG + Tied.png ├── DCF_RAW_minDCF_π=0.1_PCA m=9__MVG.png ├── DCF_RAW_minDCF_π=0.1__MVG + Naive + Tied.png ├── DCF_RAW_minDCF_π=0.1__MVG + Naive.png ├── DCF_RAW_minDCF_π=0.1__MVG + Tied.png ├── DCF_RAW_minDCF_π=0.1__MVG.png ├── DCF_RAW_minDCF_π=0.5_PCA m=10__MVG + Naive + Tied.png ├── DCF_RAW_minDCF_π=0.5_PCA m=10__MVG + Naive.png ├── DCF_RAW_minDCF_π=0.5_PCA m=10__MVG + Tied.png ├── DCF_RAW_minDCF_π=0.5_PCA m=10__MVG.png ├── DCF_RAW_minDCF_π=0.5_PCA m=9__MVG + Naive + Tied.png ├── DCF_RAW_minDCF_π=0.5_PCA m=9__MVG + Naive.png ├── DCF_RAW_minDCF_π=0.5_PCA m=9__MVG + Tied.png ├── DCF_RAW_minDCF_π=0.5_PCA m=9__MVG.png ├── DCF_RAW_minDCF_π=0.5__MVG + Naive + Tied.png ├── DCF_RAW_minDCF_π=0.5__MVG + Naive.png ├── DCF_RAW_minDCF_π=0.5__MVG + Tied.png ├── DCF_RAW_minDCF_π=0.5__MVG.png ├── DCF_RAW_minDCF_π=0.9_PCA m=10__MVG + Naive + Tied.png ├── DCF_RAW_minDCF_π=0.9_PCA m=10__MVG + Naive.png ├── DCF_RAW_minDCF_π=0.9_PCA m=10__MVG + Tied.png ├── DCF_RAW_minDCF_π=0.9_PCA m=10__MVG.png ├── DCF_RAW_minDCF_π=0.9_PCA m=9__MVG + Naive + Tied.png ├── DCF_RAW_minDCF_π=0.9_PCA m=9__MVG + Naive.png ├── DCF_RAW_minDCF_π=0.9_PCA m=9__MVG + Tied.png ├── DCF_RAW_minDCF_π=0.9_PCA m=9__MVG.png ├── DCF_RAW_minDCF_π=0.9__MVG + Naive + Tied.png ├── DCF_RAW_minDCF_π=0.9__MVG + Naive.png ├── DCF_RAW_minDCF_π=0.9__MVG + Tied.png ├── DCF_RAW_minDCF_π=0.9__MVG.png ├── DCF_ZNORMALIZED_SVM_minDCF_comparison.svg ├── DCF_ZNORM_QUAD_LR_minDCF_comparison.svg ├── DCF_ZNORM_WEIGHTED_LR_minDCF_comparison.svg ├── DCF_gauss_GMM_diag.png ├── DCF_gauss_GMM_full.png ├── DCF_gauss_GMM_tied.png ├── DCF_gauss_GMM_tied_diag.png ├── DCF_raw_GMM_diag.png ├── DCF_raw_GMM_full.png ├── DCF_raw_GMM_tied.png ├── DCF_raw_GMM_tied_diag.png ├── GAUSSIANIZED_PCA_m=2 + LDA.png ├── GAUSSIANIZED_PCA_m=2.png ├── GAUSSIANIZED_PCA_m=3 + LDA.png ├── GAUSSIANIZED_PCA_m=3.png ├── GMM │ ├── .DS_Store │ ├── diag-cov-valid.svg │ ├── diag-cov.png │ ├── full-cov-valid.svg │ ├── full-cov.png │ ├── gmm │ │ ├── .DS_Store │ │ ├── diag_cov.png │ │ ├── full_cov.png │ │ ├── tied_diag.png │ │ └── tied_full.png │ ├── tied diag-cov-valid.svg │ ├── tied diag-cov.png │ ├── tied full-cov-valid.svg │ └── tied full-cov.png ├── LogReg_eval_GAUSSIANIZED_.svg ├── LogReg_eval_RAW_.svg ├── LogReg_eval_Z-NORM.svg ├── LogReg_eval_minDCF_LogReg_val_eval.svg ├── PCA_m=2 + LDA.png ├── PCA_m=2.png ├── PCA_m=3 + LDA.png ├── PCA_m=3.png ├── QuadLogReg_eval_GAUSSIANIZED_.svg ├── QuadLogReg_eval_RAW_.svg ├── QuadLogReg_eval_Z-NORM_.svg ├── RAW_PCA_m=2 + LDA.png ├── RAW_PCA_m=2.png ├── RAW_PCA_m=3 + LDA.png ├── RAW_PCA_m=3.png ├── ROC_GAUSSIANIZED_LR, lambda=0.0001.png ├── ROC_GAUSSIANIZED_LR, lambda=0.01.png ├── ROC_GAUSSIANIZED_LR, lambda=1e-06.png ├── ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Naive + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Naive.png ├── ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG.png ├── ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Naive + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Naive.png ├── ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG.png ├── ROC_GAUSSIANIZED_minDCF_π=0.1__MVG + Naive + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.1__MVG + Naive.png ├── ROC_GAUSSIANIZED_minDCF_π=0.1__MVG + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.1__MVG.png ├── ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Naive + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Naive.png ├── ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG.png ├── ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Naive + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Naive.png ├── ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG.png ├── ROC_GAUSSIANIZED_minDCF_π=0.5__MVG + Naive + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.5__MVG + Naive.png ├── ROC_GAUSSIANIZED_minDCF_π=0.5__MVG + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.5__MVG.png ├── ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Naive + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Naive.png ├── ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG.png ├── ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Naive + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Naive.png ├── ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG.png ├── ROC_GAUSSIANIZED_minDCF_π=0.9__MVG + Naive + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.9__MVG + Naive.png ├── ROC_GAUSSIANIZED_minDCF_π=0.9__MVG + Tied.png ├── ROC_GAUSSIANIZED_minDCF_π=0.9__MVG.png ├── ROC_GMM_diag2.png ├── ROC_GMM_diag_raw.png ├── ROC_GMM_full2.png ├── ROC_GMM_full_raw.png ├── ROC_GMM_tied2.png ├── ROC_GMM_tied_diag2.png ├── ROC_GMM_tied_diag_raw.png ├── ROC_GMM_tied_raw.png ├── ROC_LR, lambda=0.0001.png ├── ROC_LR, lambda=0.01.png ├── ROC_LR, lambda=1.0.png ├── ROC_LR, lambda=1e-06.png ├── ROC_MVG + Naive + Tied.png ├── ROC_MVG + Naive.png ├── ROC_MVG + Tied.png ├── ROC_MVG.png ├── ROC_RAW_LR, lambda=0.0001.png ├── ROC_RAW_LR, lambda=0.01.png ├── ROC_RAW_LR, lambda=1.0.png ├── ROC_RAW_LR, lambda=1e-06.png ├── ROC_RAW_minDCF_π=0.1_PCA m=10__MVG + Naive + Tied.png ├── ROC_RAW_minDCF_π=0.1_PCA m=10__MVG + Naive.png ├── ROC_RAW_minDCF_π=0.1_PCA m=10__MVG + Tied.png ├── ROC_RAW_minDCF_π=0.1_PCA m=10__MVG.png ├── ROC_RAW_minDCF_π=0.1_PCA m=9__MVG + Naive + Tied.png ├── ROC_RAW_minDCF_π=0.1_PCA m=9__MVG + Naive.png ├── ROC_RAW_minDCF_π=0.1_PCA m=9__MVG + Tied.png ├── ROC_RAW_minDCF_π=0.1_PCA m=9__MVG.png ├── ROC_RAW_minDCF_π=0.1__MVG + Naive + Tied.png ├── ROC_RAW_minDCF_π=0.1__MVG + Naive.png ├── ROC_RAW_minDCF_π=0.1__MVG + Tied.png ├── ROC_RAW_minDCF_π=0.1__MVG.png ├── ROC_RAW_minDCF_π=0.5_PCA m=10__MVG + Naive + Tied.png ├── ROC_RAW_minDCF_π=0.5_PCA m=10__MVG + Naive.png ├── ROC_RAW_minDCF_π=0.5_PCA m=10__MVG + Tied.png ├── ROC_RAW_minDCF_π=0.5_PCA m=10__MVG.png ├── ROC_RAW_minDCF_π=0.5_PCA m=9__MVG + Naive + Tied.png ├── ROC_RAW_minDCF_π=0.5_PCA m=9__MVG + Naive.png ├── ROC_RAW_minDCF_π=0.5_PCA m=9__MVG + Tied.png ├── ROC_RAW_minDCF_π=0.5_PCA m=9__MVG.png ├── ROC_RAW_minDCF_π=0.5__MVG + Naive + Tied.png ├── ROC_RAW_minDCF_π=0.5__MVG + Naive.png ├── ROC_RAW_minDCF_π=0.5__MVG + Tied.png ├── ROC_RAW_minDCF_π=0.5__MVG.png ├── ROC_RAW_minDCF_π=0.9_PCA m=10__MVG + Naive + Tied.png ├── ROC_RAW_minDCF_π=0.9_PCA m=10__MVG + Naive.png ├── ROC_RAW_minDCF_π=0.9_PCA m=10__MVG + Tied.png ├── ROC_RAW_minDCF_π=0.9_PCA m=10__MVG.png ├── ROC_RAW_minDCF_π=0.9_PCA m=9__MVG + Naive + Tied.png ├── ROC_RAW_minDCF_π=0.9_PCA m=9__MVG + Naive.png ├── ROC_RAW_minDCF_π=0.9_PCA m=9__MVG + Tied.png ├── ROC_RAW_minDCF_π=0.9_PCA m=9__MVG.png ├── ROC_RAW_minDCF_π=0.9__MVG + Naive + Tied.png ├── ROC_RAW_minDCF_π=0.9__MVG + Naive.png ├── ROC_RAW_minDCF_π=0.9__MVG + Tied.png ├── ROC_RAW_minDCF_π=0.9__MVG.png ├── comparison │ ├── DCF_2best.svg │ ├── DCF_2bestGMM_MVG_eval.svg │ ├── DCF_2bestWLR_GMM.svg │ ├── DCF_2bestWLR_GMM_eval.svg │ ├── DCF_2best_WLR_GMM_eval.svg │ ├── ROC_2bestGMM_MVG_eval.svg │ ├── ROC_2bestWLR_GMM.svg │ ├── ROC_2bestWLR_GMM_eval.svg │ ├── ROC_2best_WLR_GMM_eval.svg │ └── ciao.txt ├── heatmap_GAUSSIANIZED_.png ├── heatmap_GAUSSIANIZED_.svg ├── heatmap_RAW_.png ├── heatmap_RAW_.svg ├── heatmap_female_GAUSSIANIZED_.svg ├── heatmap_female_RAW_.svg ├── heatmap_male_GAUSSIANIZED_.svg ├── heatmap_male_RAW_.svg ├── heatmap_no_gauss.png ├── histLDA.png ├── histNo manipulation.png ├── histPCA + LDA.png ├── histPCA.png ├── histPCA_m=2 + LDA.png ├── histPCA_m=2 + LDA.svg ├── histPCA_m=3 + LDA.png ├── hist_GAUSSIANIZED_feature_0.svg ├── hist_GAUSSIANIZED_feature_1.svg ├── hist_GAUSSIANIZED_feature_10.svg ├── hist_GAUSSIANIZED_feature_11.svg ├── hist_GAUSSIANIZED_feature_2.svg ├── hist_GAUSSIANIZED_feature_3.svg ├── hist_GAUSSIANIZED_feature_4.svg ├── hist_GAUSSIANIZED_feature_5.svg ├── hist_GAUSSIANIZED_feature_6.svg ├── hist_GAUSSIANIZED_feature_7.svg ├── hist_GAUSSIANIZED_feature_8.svg ├── hist_GAUSSIANIZED_feature_9.svg ├── hist_RAW_feature_0.svg ├── hist_RAW_feature_1.svg ├── hist_RAW_feature_10.svg ├── hist_RAW_feature_11.svg ├── hist_RAW_feature_2.svg ├── hist_RAW_feature_3.svg ├── hist_RAW_feature_4.svg ├── hist_RAW_feature_5.svg ├── hist_RAW_feature_6.svg ├── hist_RAW_feature_7.svg ├── hist_RAW_feature_8.svg ├── hist_RAW_feature_9.svg ├── hist_feature_0.png ├── hist_feature_0.svg ├── hist_feature_1.png ├── hist_feature_1.svg ├── hist_feature_10.png ├── hist_feature_10.svg ├── hist_feature_11.png ├── hist_feature_11.svg ├── hist_feature_2.png ├── hist_feature_2.svg ├── hist_feature_3.png ├── hist_feature_3.svg ├── hist_feature_4.png ├── hist_feature_4.svg ├── hist_feature_5.png ├── hist_feature_5.svg ├── hist_feature_6.png ├── hist_feature_6.svg ├── hist_feature_7.png ├── hist_feature_7.svg ├── hist_feature_8.png ├── hist_feature_8.svg ├── hist_feature_9.png └── hist_feature_9.svg ├── main.py ├── mlFunc.py ├── plot_features.py ├── score_calibration ├── SVM_RBF_scores_calibration.py ├── SVM_scores_calibration.py └── __pycache__ │ ├── SVM_RBF_scores_calibration.cpython-39.pyc │ └── SVM_scores_calibration.cpython-39.pyc ├── validation ├── __pycache__ │ ├── compare_best_2.cpython-39.pyc │ ├── validation_GMM.cpython-310.pyc │ ├── validation_GMM.cpython-39.pyc │ ├── validation_LR.cpython-310.pyc │ ├── validation_LR.cpython-39.pyc │ ├── validation_MVG.cpython-310.pyc │ ├── validation_MVG.cpython-39.pyc │ ├── validation_SVM.cpython-310.pyc │ ├── validation_SVM.cpython-39.pyc │ ├── validation_SVM_RBF.cpython-39.pyc │ ├── validation_SVM_RFB.cpython-310.pyc │ ├── validation_SVM_RFB.cpython-39.pyc │ ├── validation_SVM_polynomial.cpython-310.pyc │ ├── validation_SVM_polynomial.cpython-39.pyc │ ├── validation_compare.cpython-39.pyc │ ├── validation_quad_LR.cpython-310.pyc │ ├── validation_quad_LR.cpython-39.pyc │ ├── validation_weighted_LR.cpython-310.pyc │ └── validation_weighted_LR.cpython-39.pyc ├── validation_GMM.py ├── validation_LR.py ├── validation_MVG.py ├── validation_SVM.py ├── validation_SVM_RBF.py ├── validation_SVM_polynomial.py ├── validation_compare.py ├── validation_quad_LR.py └── validation_weighted_LR.py └── validators.py /Gender_Detection.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/Gender_Detection.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gender Detection 2 | 3 | This is a report developed by me and [Alessio Carachino](https://github.com/CarachinoAlessio) for [Machine Learning and Pattern Recognition](https://didattica.polito.it/pls/portal30/gap.pkg_guide.viewGap?p_cod_ins=01URTOV&p_a_acc=2022&p_header=S&p_lang=&multi=N) course. 4 | 5 | We have tested some techniques studied during the lectures, all of them developed from scratch: 6 | * Preprocessing: 7 | * Z-score Normalization 8 | * Gaussianized Features 9 | * PCA (Principal Component Analysis) 10 | * LDA (Linear Discriminant Analysis) 11 | * Classification Models: 12 | * Multivariate Gaussian Classifiers 13 | * Logistic Regression 14 | * Support-vector Machine 15 | * Gaussian Mixure Models 16 | 17 | Feel free to check out the [report](https://github.com/Peipi98/Gender_Detection/blob/main/Gender_Detection.pdf)! 18 | -------------------------------------------------------------------------------- /code/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /code/.idea/Gender_Speech_Recognition.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /code/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /code/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /code/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /code/.idea/other.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /code/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /code/Classifiers/__pycache__/GMM.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/Classifiers/__pycache__/GMM.cpython-310.pyc -------------------------------------------------------------------------------- /code/Classifiers/__pycache__/GMM.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/Classifiers/__pycache__/GMM.cpython-39.pyc -------------------------------------------------------------------------------- /code/INFO.txt: -------------------------------------------------------------------------------- 1 | The dataset consists of synthetic speaker embeddings that represent the acoustic characteristics of a spoken utterance. Each row corresponds to a different speaker, and contains 12 features followed by the gender label (1 for female, 0 for male). The features do not have any particular interpretation. Speakers belong to four different age groups. The age information, however, is not available. 2 | 3 | The training set consists of 3000 samples per class, whereas the test set contains 2000 samples per class. 4 | 5 | -------------------------------------------------------------------------------- /code/PCA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/PCA.png -------------------------------------------------------------------------------- /code/__pycache__/classifiers.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/__pycache__/classifiers.cpython-310.pyc -------------------------------------------------------------------------------- /code/__pycache__/classifiers.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/__pycache__/classifiers.cpython-39.pyc -------------------------------------------------------------------------------- /code/__pycache__/mlFunc.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/__pycache__/mlFunc.cpython-310.pyc -------------------------------------------------------------------------------- /code/__pycache__/mlFunc.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/__pycache__/mlFunc.cpython-39.pyc -------------------------------------------------------------------------------- /code/__pycache__/plot_features.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/__pycache__/plot_features.cpython-310.pyc -------------------------------------------------------------------------------- /code/__pycache__/plot_features.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/__pycache__/plot_features.cpython-39.pyc -------------------------------------------------------------------------------- /code/__pycache__/validators.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/__pycache__/validators.cpython-310.pyc -------------------------------------------------------------------------------- /code/__pycache__/validators.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/__pycache__/validators.cpython-39.pyc -------------------------------------------------------------------------------- /code/classifiers.py: -------------------------------------------------------------------------------- 1 | import numpy 2 | from mlFunc import * 3 | 4 | 5 | def MVG(DTE, DTR, LTR): 6 | h = {} 7 | 8 | for i in range(2): 9 | mu, C = ML_GAU(DTR[:, LTR == i]) 10 | h[i] = (mu, C) 11 | 12 | SJoint = numpy.zeros((2, DTE.shape[1])) 13 | logSJoint = numpy.zeros((2, DTE.shape[1])) 14 | dens = numpy.zeros((2, DTE.shape[1])) 15 | classPriors = [0.5, 0.5] 16 | 17 | for label in range(2): 18 | mu, C = h[label] 19 | dens[label, :] = numpy.exp(logpdf_GAU_ND(DTE, mu, C).ravel()) 20 | SJoint[label, :] = dens[label, :] * classPriors[label] 21 | logSJoint[label, :] = logpdf_GAU_ND(DTE, mu, C).ravel() + numpy.log(classPriors[label]) 22 | 23 | SMarginal = SJoint.sum(0) 24 | logSMarginal = scipy.special.logsumexp(logSJoint, axis=0) 25 | 26 | Post1 = SJoint / mrow(SMarginal) 27 | logPost = logSJoint - mrow(logSMarginal) 28 | Post2 = numpy.exp(logPost) 29 | LPred1 = Post1.argmax(0) 30 | LPred2 = Post2.argmax(0) 31 | return LPred1, LPred2, numpy.log(dens[1] / dens[0]) 32 | 33 | 34 | def naive_MVG(DTE, DTR, LTR): 35 | h = {} 36 | 37 | for i in range(2): 38 | mu, C = ML_GAU(DTR[:, LTR == i]) 39 | C = C * numpy.identity(C.shape[0]) 40 | h[i] = (mu, C) 41 | 42 | SJoint = numpy.zeros((2, DTE.shape[1])) 43 | logSJoint = numpy.zeros((2, DTE.shape[1])) 44 | dens = numpy.zeros((2, DTE.shape[1])) 45 | classPriors = [0.5, 0.5] 46 | 47 | for label in range(2): 48 | mu, C = h[label] 49 | dens[label, :] = numpy.exp(logpdf_GAU_ND(DTE, mu, C).ravel()) 50 | SJoint[label, :] = dens[label, :] * classPriors[label] 51 | logSJoint[label, :] = logpdf_GAU_ND(DTE, mu, C).ravel() + numpy.log(classPriors[label]) 52 | 53 | SMarginal = SJoint.sum(0) 54 | logSMarginal = scipy.special.logsumexp(logSJoint, axis=0) 55 | 56 | Post1 = SJoint / mrow(SMarginal) 57 | logPost = logSJoint - mrow(logSMarginal) 58 | Post2 = numpy.exp(logPost) 59 | 60 | LPred1 = Post1.argmax(0) 61 | LPred2 = Post2.argmax(0) 62 | return LPred1, LPred2, numpy.log(dens[1] / dens[0]) 63 | 64 | 65 | def tied_cov_GC(DTE, DTR, LTR): 66 | h = {} 67 | Ctot = 0 68 | for i in range(2): 69 | mu, C = ML_GAU(DTR[:, LTR == i]) 70 | Ctot += DTR[:, LTR == i].shape[1] * C 71 | h[i] = (mu) 72 | 73 | Ctot = Ctot / DTR.shape[1] 74 | 75 | SJoint = numpy.zeros((2, DTE.shape[1])) 76 | logSJoint = numpy.zeros((2, DTE.shape[1])) 77 | dens = numpy.zeros((2, DTE.shape[1])) 78 | classPriors = [0.5, 0.5] 79 | 80 | for label in range(2): 81 | mu = h[label] 82 | dens[label, :] = numpy.exp(logpdf_GAU_ND(DTE, mu, Ctot).ravel()) 83 | SJoint[label, :] = dens[label, :] * classPriors[label] 84 | logSJoint[label, :] = logpdf_GAU_ND(DTE, mu, Ctot).ravel() + numpy.log(classPriors[label]) 85 | 86 | SMarginal = SJoint.sum(0) 87 | logSMarginal = scipy.special.logsumexp(logSJoint, axis=0) 88 | 89 | Post1 = SJoint / mrow(SMarginal) 90 | logPost = logSJoint - mrow(logSMarginal) 91 | Post2 = numpy.exp(logPost) 92 | 93 | LPred1 = Post1.argmax(0) 94 | LPred2 = Post2.argmax(0) 95 | return LPred1, LPred2, numpy.log(dens[1] / dens[0]) 96 | 97 | 98 | def tied_cov_naive_GC(DTE, DTR, LTR): 99 | h = {} 100 | Ctot = 0 101 | for i in range(2): 102 | mu, C = ML_GAU(DTR[:, LTR == i]) 103 | Ctot += DTR[:, LTR == i].shape[1] * C 104 | h[i] = (mu) 105 | 106 | Ctot = Ctot / DTR.shape[1] 107 | Ctot = Ctot * numpy.identity(Ctot.shape[0]) 108 | 109 | SJoint = numpy.zeros((2, DTE.shape[1])) 110 | logSJoint = numpy.zeros((2, DTE.shape[1])) 111 | dens = numpy.zeros((2, DTE.shape[1])) 112 | classPriors = [0.5, 0.5] 113 | 114 | for label in range(2): 115 | mu = h[label] 116 | dens[label, :] = numpy.exp(logpdf_GAU_ND(DTE, mu, Ctot).ravel()) 117 | SJoint[label, :] = dens[label, :] * classPriors[label] 118 | logSJoint[label, :] = logpdf_GAU_ND(DTE, mu, Ctot).ravel() + numpy.log(classPriors[label]) 119 | 120 | SMarginal = SJoint.sum(0) 121 | logSMarginal = scipy.special.logsumexp(logSJoint, axis=0) 122 | 123 | Post1 = SJoint / mrow(SMarginal) 124 | logPost = logSJoint - mrow(logSMarginal) 125 | Post2 = numpy.exp(logPost) 126 | 127 | LPred1 = Post1.argmax(0) 128 | LPred2 = Post2.argmax(0) 129 | return LPred1, LPred2, numpy.log(dens[1] / dens[0]) 130 | 131 | 132 | def logistic_reg(DTR, LTR, DTE, l): 133 | logreg_obj = logreg_obj_wrap(DTR, LTR, l) 134 | _v, _J, _d = opt.fmin_l_bfgs_b(logreg_obj, numpy.zeros(DTR.shape[0] + 1), approx_grad=True) 135 | _w = _v[0:DTR.shape[0]] 136 | _b = _v[-1] 137 | STE = numpy.dot(_w.T, DTE) + _b 138 | LP = STE > 0 139 | return LP, _J 140 | 141 | 142 | def logistic_reg_score(DTR, LTR, DTE, l): 143 | logreg_obj = logreg_obj_wrap(numpy.array(DTR), LTR, l) 144 | _v, _J, _d = opt.fmin_l_bfgs_b(logreg_obj, numpy.zeros(DTR.shape[0] + 1), approx_grad=True) 145 | _w = _v[0:DTR.shape[0]] 146 | _b = _v[-1] 147 | STE = numpy.dot(_w.T, DTE) + _b 148 | return STE 149 | 150 | def logistic_reg_calibration(DTR, LTR, DTE, l, pi=None): 151 | logreg_obj = weighted_logreg_obj_wrap(numpy.array(DTR), LTR, l) 152 | _v, _J, _d = opt.fmin_l_bfgs_b(logreg_obj, numpy.zeros(DTR.shape[0] + 1), approx_grad=True) 153 | _w = _v[0:DTR.shape[0]] 154 | _b = _v[-1] 155 | calibration = 0 if pi is None else numpy.log(pi / (1 - pi)) 156 | STE = numpy.dot(_w.T, DTE) + _b - calibration 157 | return STE, _w, _b 158 | 159 | def weighted_logistic_reg_score(DTR, LTR, DTE, l, pi=0.5): 160 | logreg_obj = weighted_logreg_obj_wrap(numpy.array(DTR), LTR, l, pi) 161 | _v, _J, _d = opt.fmin_l_bfgs_b(logreg_obj, numpy.zeros(DTR.shape[0] + 1), approx_grad=True) 162 | _w = _v[0:DTR.shape[0]] 163 | _b = _v[-1] 164 | STE = numpy.dot(_w.T, DTE) + _b 165 | return STE 166 | 167 | def quad_logistic_reg_score(DTR, LTR, DTE, l, pi=0.5): 168 | logreg_obj = quad_logreg_obj_wrap(numpy.array(DTR), LTR, l, pi) 169 | _v, _J, _d = opt.fmin_l_bfgs_b(logreg_obj, numpy.zeros(DTR.shape[0] + 1), approx_grad=True) 170 | _w = _v[0:DTR.shape[0]] 171 | _b = _v[-1] 172 | STE = numpy.dot(_w.T, DTE) + _b 173 | return STE 174 | 175 | 176 | def generative_acc_err(DTE, DTR, LTE, LTR, title): 177 | _, LPred2 = MVG(DTE, DTR, LTR) 178 | _, LP2n = naive_MVG(DTE, DTR, LTR) 179 | _, LP2t = tied_cov_GC(DTE, DTR, LTR) 180 | _, LP2nt = tied_cov_naive_GC(DTE, DTR, LTR) 181 | # logMVG accuracy 182 | log_acc, log_err = test(LTE, LPred2) 183 | log_acc_n, log_err_n = test(LTE, LP2n) 184 | log_acc_t, log_err_t = test(LTE, LP2t) 185 | log_acc_nt, log_err_nt = test(LTE, LP2nt) 186 | 187 | table = PrettyTable(["", "Accuracy %", "Error "]) 188 | table.title = title 189 | table.add_row(["MVG", round(log_acc * 100, 3), round(log_err * 100, 3)]) 190 | table.add_row(["Naive MVG", round(log_acc_n * 100, 3), round(log_err_n * 100, 3)]) 191 | table.add_row(["Tied GC", round(log_acc_t * 100, 3), round(log_err_t * 100, 3)]) 192 | table.add_row(["Naive Tied GC", round(log_acc_nt * 100, 3), round(log_err_nt * 100, 3)]) 193 | print(table) 194 | -------------------------------------------------------------------------------- /code/evaluators/__pycache__/compare_best_2.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/compare_best_2.cpython-310.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/compare_best_2.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/compare_best_2.cpython-39.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_GMM.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_GMM.cpython-310.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_GMM.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_GMM.cpython-39.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_LR.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_LR.cpython-310.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_LR.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_LR.cpython-39.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_MVG.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_MVG.cpython-310.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_MVG.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_MVG.cpython-39.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_SVM.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_SVM.cpython-310.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_SVM.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_SVM.cpython-39.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_SVM_RBF.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_SVM_RBF.cpython-39.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_SVM_RFB.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_SVM_RFB.cpython-310.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_SVM_RFB.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_SVM_RFB.cpython-39.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_SVM_polynomial.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_SVM_polynomial.cpython-310.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_SVM_polynomial.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_SVM_polynomial.cpython-39.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_quad_LR.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_quad_LR.cpython-310.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_quad_LR.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_quad_LR.cpython-39.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_weighted_LR.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_weighted_LR.cpython-310.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/evaluation_weighted_LR.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/evaluation_weighted_LR.cpython-39.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/kfold_lr.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/kfold_lr.cpython-39.pyc -------------------------------------------------------------------------------- /code/evaluators/__pycache__/mvg_script.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/__pycache__/mvg_script.cpython-39.pyc -------------------------------------------------------------------------------- /code/evaluators/compare_best_2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | import pylab 7 | from mlFunc import mrow 8 | from classifiers import weighted_logistic_reg_score, tied_cov_GC, logistic_reg_calibration 9 | from evaluators.evaluation_GMM import evaluation_GMM_ncomp 10 | from mlFunc import train_SVM_linear, train_SVM_RBF 11 | from validators import bayes_error_plot, confusion_matrix_binary 12 | 13 | 14 | def bayes_error_plot_2best(D, L, pi, title, ylim): 15 | p = np.linspace(-3, 3, 21) 16 | pylab.title(title) 17 | pylab.plot(p, bayes_error_plot(p, D[0], L, minCost=False), color='r', label='SVM_RBF_RAW_actDCF(calibrated)') 18 | pylab.plot(p, bayes_error_plot(p, D[0], L, minCost=True), 'r--', label='SVM_RBF_RAW_minDCF') 19 | 20 | pylab.plot(p, bayes_error_plot(p, D[1], L, minCost=False), color='b', label='MVG_TIED_RAW_actDCF(calibrated)') 21 | pylab.plot(p, bayes_error_plot(p, D[1], L, minCost=True), 'b--', label='MVG_TIED_RAW_minDCF') 22 | 23 | pylab.ylim(0, ylim) 24 | pylab.legend() 25 | #pylab.savefig('../images/comparison/ROC_2best' + title + '.png') 26 | pylab.show() 27 | 28 | def ROC_2best(D, L, pi, title): 29 | thresholds = np.array(D[0]) 30 | thresholds.sort() 31 | thresholds = np.concatenate([np.array([-np.inf]), thresholds, np.array([np.inf])]) 32 | FPR = np.zeros(thresholds.size) 33 | TPR = np.zeros(thresholds.size) 34 | for idx, t in enumerate(thresholds): 35 | Pred = np.int32(D[0] > t) 36 | conf = confusion_matrix_binary(Pred, L) 37 | TPR[idx] = conf[1, 1] / (conf[1, 1] + conf[0, 1]) 38 | FPR[idx] = conf[1, 0] / (conf[1, 0] + conf[0, 0]) 39 | pylab.plot(FPR, TPR, label="SVM_RBF") 40 | 41 | thresholds = np.array(D[1]) 42 | thresholds.sort() 43 | thresholds = np.concatenate([np.array([-np.inf]), thresholds, np.array([np.inf])]) 44 | FPR = np.zeros(thresholds.size) 45 | TPR = np.zeros(thresholds.size) 46 | for idx, t in enumerate(thresholds): 47 | Pred = np.int32(D[1] > t) 48 | conf = confusion_matrix_binary(Pred, L) 49 | TPR[idx] = conf[1, 1] / (conf[1, 1] + conf[0, 1]) 50 | FPR[idx] = conf[1, 0] / (conf[1, 0] + conf[0, 0]) 51 | pylab.plot(FPR, TPR, label="MVG_TIED") 52 | 53 | pylab.title(title) 54 | pylab.legend() 55 | #pylab.savefig('../images/comparison/ROC_2best' + title + '.png') 56 | pylab.show() 57 | 58 | def compute_2best_plots(DTR, LTR, DTE, LTE): 59 | # GMM_llrst_raw, GMM_labels_raw = validation_GMM_ncomp(DTR, LTR, 0.5, 2) 60 | # WLR_scores = weighted_logistic_reg_score(DTR, LTR, DTE, 1e-4) 61 | 62 | 63 | GMM_llrst_raw = evaluation_GMM_ncomp('', DTR, LTR, DTE, LTE, 0.5, 2) 64 | #WLR_scores = weighted_logistic_reg_score(DTR, LTR, DTE, 1e-4) 65 | 66 | C = 1.0 67 | K = 1.0 68 | # wStar, primal, dual, gap = train_SVM_linear(DTR, LTR, C=C, K=K) 69 | # DTEEXT = np.vstack([DTE, K * np.ones((1, DTE.shape[1]))]) 70 | # second_scores = np.dot(wStar.T, DTEEXT).ravel() 71 | 72 | Z = np.zeros(LTR.shape) 73 | Z[LTR == 1] = 1 74 | Z[LTR == 0] = -1 75 | gamma = 0.001 76 | aStar, loss = train_SVM_RBF(DTR, LTR, C=1.0, K=K, gamma=gamma) 77 | 78 | kern = np.zeros((DTR.shape[1], DTE.shape[1])) 79 | for i in range(DTR.shape[1]): 80 | for j in range(DTE.shape[1]): 81 | kern[i, j] = np.exp(-gamma * (np.linalg.norm(DTR[:, i] - DTE[:, j]) ** 2)) + K * K 82 | 83 | 84 | second_scores = np.sum(np.dot(aStar * mrow(Z), kern), axis=0) 85 | scores_append = np.hstack(second_scores) 86 | cal_scores, cal_labels, w, b = calibrate_scores(scores_append, LTE) 87 | scores_append = scores_append.reshape((1, 4000)) 88 | final_score = np.dot(w.T, scores_append) + b 89 | # 90 | # bayes_error_plot_2best([GMM_llrst_raw, second_scores], LTE, 0.5, '', 0.4) 91 | # ROC_2best([GMM_llrst_raw, second_scores], LTE, 0.5, '') 92 | 93 | #_, _, second_scores = tied_cov_GC(DTE, DTR, LTR) 94 | bayes_error_plot_2best([GMM_llrst_raw, final_score], LTE, 0.5, '', 0.4) 95 | ROC_2best([GMM_llrst_raw, final_score], LTE, 0.5, '') 96 | 97 | # Put here models to be compared 98 | 99 | #bayes_error_plot_2best([D1, D2], [L1,L2], 0.5, "", 0.4) 100 | 101 | def calibrate_scores(scores, labels): 102 | scores_70 = scores[:int(len(scores) * 0.7)] 103 | scores_30 = scores[int(len(scores) * 0.7):] 104 | labels_70 = labels[:int(len(labels) * 0.7)] 105 | labels_30 = labels[int(len(labels) * 0.7):] 106 | 107 | S, estimated_w, estimated_b = logistic_reg_calibration(np.array([scores_70]), labels_70, 108 | np.array([scores_30]), 1e-3) 109 | 110 | return np.array(S), labels_30, estimated_w, estimated_b -------------------------------------------------------------------------------- /code/evaluators/evaluation_LR.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | 4 | import numpy as np 5 | 6 | sys.path.append('../') 7 | from validators import * 8 | from prettytable import PrettyTable 9 | 10 | 11 | def validate_LR(scores, LR_labels, appendToTitle, l): 12 | scores_append = np.hstack(scores) 13 | scores_tot = compute_min_DCF(scores_append, LR_labels, 0.5, 1, 1) 14 | 15 | # plot_ROC(scores_append, LR_labels, appendToTitle + 'LR, lambda=' + str(l)) 16 | 17 | # Cfn and Ctp are set to 1 18 | # bayes_error_min_act_plot(scores_append, LR_labels, appendToTitle + 'LR, lambda=' + str(l), 0.4) 19 | 20 | t = PrettyTable(["Type", "minDCF"]) 21 | t.title = appendToTitle + "minDCF: π=0.5" 22 | t.add_row(['LR, lambda=' + str(l), round(scores_tot, 3)]) 23 | print(t) 24 | 25 | ############################### 26 | 27 | # π = 0.1 28 | scores_tot = compute_min_DCF(scores_append, LR_labels, 0.1, 1, 1) 29 | 30 | t = PrettyTable(["Type", "minDCF"]) 31 | t.title = appendToTitle + "minDCF: π=0.1" 32 | t.add_row(['LR, lambda=' + str(l), round(scores_tot, 3)]) 33 | 34 | print(t) 35 | 36 | ############################### 37 | 38 | # π = 0.9 39 | scores_tot = compute_min_DCF(scores_append, LR_labels, 0.9, 1, 1) 40 | 41 | t = PrettyTable(["Type", "minDCF"]) 42 | t.title = appendToTitle + "minDCF: π=0.9" 43 | t.add_row(['LR, lambda=' + str(l), round(scores_tot, 3)]) 44 | 45 | print(t) 46 | 47 | 48 | def evaluate_LR(DTR, LTR, DTE, LTE, l, appendToTitle, PCA_Flag=True): 49 | 50 | scores_append = [] 51 | PCA_LR_scores_append = [] 52 | PCA2_LR_scores_append = [] 53 | LR_labels = [] 54 | 55 | 56 | scores = logistic_reg_score(DTR, LTR, DTE, l) 57 | scores_append.append(scores) 58 | 59 | LR_labels = np.append(LR_labels, LTE, axis=0) 60 | LR_labels = np.hstack(LR_labels) 61 | 62 | 63 | 64 | validate_LR(scores_append, LR_labels, appendToTitle, l) 65 | 66 | if PCA_Flag is True: 67 | # PCA m=10 68 | P = PCA(DTR, LTR, m=10) 69 | DTR_PCA = numpy.dot(P.T, DTR) 70 | DTE_PCA = numpy.dot(P.T, DTE) 71 | 72 | PCA_LR_scores = logistic_reg_score(DTR_PCA, LTR, DTE_PCA, l) 73 | PCA_LR_scores_append.append(PCA_LR_scores) 74 | 75 | # PCA m=9 76 | P = PCA(DTR, LTR, m=9) 77 | DTR_PCA = numpy.dot(P.T, DTR) 78 | DTE_PCA = numpy.dot(P.T, DTE) 79 | 80 | PCA2_LR_scores = logistic_reg_score(DTR_PCA, LTR, DTE_PCA, l) 81 | PCA2_LR_scores_append.append(PCA2_LR_scores) 82 | validate_LR(PCA_LR_scores_append, LR_labels, appendToTitle + 'PCA_m10_', l) 83 | 84 | validate_LR(PCA2_LR_scores_append, LR_labels, appendToTitle + 'PCA_m9_', l) 85 | 86 | 87 | def kfold_LR_calibration(DTR, LTR, l): 88 | k = 5 89 | Dtr = numpy.split(DTR, k, axis=1) 90 | Ltr = numpy.split(LTR, k) 91 | 92 | scores_append = [] 93 | LR_labels = [] 94 | 95 | for i in range(k): 96 | D = [] 97 | L = [] 98 | if i == 0: 99 | D.append(np.hstack(Dtr[i + 1:])) 100 | L.append(np.hstack(Ltr[i + 1:])) 101 | elif i == k - 1: 102 | D.append(np.hstack(Dtr[:i])) 103 | L.append(np.hstack(Ltr[:i])) 104 | else: 105 | D.append(np.hstack(Dtr[:i])) 106 | D.append(np.hstack(Dtr[i + 1:])) 107 | L.append(np.hstack(Ltr[:i])) 108 | L.append(np.hstack(Ltr[i + 1:])) 109 | 110 | D = np.hstack(D) 111 | L = np.hstack(L) 112 | 113 | Dte = Dtr[i] 114 | Lte = Ltr[i] 115 | 116 | scores = logistic_reg_score(D, L, Dte, l) 117 | scores_append.append(scores) 118 | 119 | LR_labels = np.append(LR_labels, Lte, axis=0) 120 | LR_labels = np.hstack(LR_labels) 121 | 122 | return np.hstack(scores_append), LR_labels 123 | 124 | 125 | def evaluation_LR(DTR, LTR, DTE, LTE, L, appendToTitle, PCA_Flag=True): 126 | for l in L: #l is a constant, not an array 127 | evaluate_LR(DTR, LTR, DTE, LTE, l, appendToTitle, PCA_Flag) 128 | 129 | # x = numpy.logspace(-5, 1, 30) 130 | # y = numpy.array([]) 131 | # y_05 = numpy.array([]) 132 | # y_09 = numpy.array([]) 133 | # y_01 = numpy.array([]) 134 | # for xi in x: 135 | # scores, labels = kfold_LR_calibration(DTR, LTR, xi) 136 | # y_05 = numpy.hstack((y_05, bayes_error_plot_compare(0.5, scores, labels))) 137 | # y_09 = numpy.hstack((y_09, bayes_error_plot_compare(0.9, scores, labels))) 138 | # y_01 = numpy.hstack((y_01, bayes_error_plot_compare(0.1, scores, labels))) 139 | # 140 | # y = numpy.hstack((y, y_05)) 141 | # y = numpy.vstack((y, y_09)) 142 | # y = numpy.vstack((y, y_01)) 143 | # 144 | # plot_DCF(x, y, 'lambda', appendToTitle + 'LR_minDCF_comparison') 145 | -------------------------------------------------------------------------------- /code/evaluators/evaluation_MVG.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | import numpy as np 4 | 5 | sys.path.append('../') 6 | from mlFunc import * 7 | from validators import * 8 | from classifiers import * 9 | from classifiers import * 10 | from validators import * 11 | from prettytable import PrettyTable 12 | 13 | 14 | def compute_MVG_score(Dte, D, L, MVG_res, MVG_naive, MVG_t, MVG_nt, MVG_labels): 15 | _, _, llrs = MVG(Dte, D, L) 16 | _, _, llrsn = naive_MVG(Dte, D, L) 17 | _, _, llrst = tied_cov_GC(Dte, D, L) 18 | _, _, llrsnt = tied_cov_naive_GC(Dte, D, L) 19 | 20 | MVG_res.append(llrs) 21 | MVG_naive.append(llrsn) 22 | MVG_t.append(llrst) 23 | MVG_nt.append(llrsnt) 24 | # MVG_labels.append(Lte) 25 | # MVG_labels = np.append(MVG_labels, Lte, axis=0) 26 | # MVG_labels = np.hstack(MVG_labels) 27 | return MVG_res, MVG_naive, MVG_t, MVG_nt 28 | 29 | 30 | def evaluation(title, pi, MVG_res, MVG_naive, MVG_t, MVG_nt, MVG_labels, appendToTitle): 31 | MVG_res = np.hstack(MVG_res) 32 | MVG_naive = np.hstack(MVG_naive) 33 | MVG_t = np.hstack(MVG_t) 34 | MVG_nt = np.hstack(MVG_nt) 35 | 36 | llrs_tot = compute_min_DCF(MVG_res, MVG_labels, pi, 1, 1) 37 | llrsn_tot = compute_min_DCF(MVG_naive, MVG_labels, pi, 1, 1) 38 | llrst_tot = compute_min_DCF(MVG_t, MVG_labels, pi, 1, 1) 39 | llrsnt_tot = compute_min_DCF(MVG_nt, MVG_labels, pi, 1, 1) 40 | 41 | # plot_ROC(MVG_res, MVG_labels, appendToTitle + 'MVG') 42 | # plot_ROC(MVG_naive, MVG_labels, appendToTitle + 'MVG + Naive') 43 | # plot_ROC(MVG_t, MVG_labels, appendToTitle + 'MVG + Tied') 44 | # plot_ROC(MVG_nt, MVG_labels, appendToTitle + 'MVG + Naive + Tied') 45 | 46 | # # Cfn and Ctp are set to 1 47 | # bayes_error_min_act_plot(MVG_res, MVG_labels, appendToTitle + 'MVG', 0.4) 48 | # bayes_error_min_act_plot(MVG_naive, MVG_labels, appendToTitle + 'MVG + Naive', 1) 49 | # bayes_error_min_act_plot(MVG_t, MVG_labels, appendToTitle + 'MVG + Tied', 0.4) 50 | # bayes_error_min_act_plot(MVG_nt, MVG_labels, appendToTitle + 'MVG + Naive + Tied', 1) 51 | 52 | t = PrettyTable(["Type", "minDCF"]) 53 | t.title = title 54 | t.add_row(["MVG", round(llrs_tot, 3)]) 55 | t.add_row(["MVG naive", round(llrsn_tot, 3)]) 56 | t.add_row(["MVG tied", round(llrst_tot, 3)]) 57 | t.add_row(["MVG naive + tied", round(llrsnt_tot, 3)]) 58 | print(t) 59 | 60 | def evaluation_MVG(DTR, LTR, DTE, LTE, appendToTitle, PCA_Flag=True): 61 | 62 | MVG_res = [] 63 | MVG_naive = [] 64 | MVG_t = [] 65 | MVG_nt = [] 66 | MVG_labels = [] 67 | 68 | PCA_mvg = [] 69 | PCA_mvg_naive = [] 70 | PCA_mvg_t = [] 71 | PCA_mvg_nt = [] 72 | 73 | PCA2_mvg = [] 74 | PCA2_mvg_naive = [] 75 | PCA2_mvg_t = [] 76 | PCA2_mvg_nt = [] 77 | 78 | # Once we have computed our folds, we can try different models 79 | # RAW DATA 80 | MVG_labels = np.append(MVG_labels, LTE, axis=0) 81 | MVG_labels = np.hstack(MVG_labels) 82 | 83 | MVG_res, MVG_naive, MVG_t, MVG_nt = compute_MVG_score( 84 | DTE, 85 | DTR, 86 | LTR, 87 | MVG_res, 88 | MVG_naive, 89 | MVG_t, 90 | MVG_nt, 91 | MVG_labels) 92 | 93 | if PCA_Flag is True: 94 | # PCA m=10 95 | P = PCA(DTR, LTR, m=10) 96 | DTR_PCA = numpy.dot(P.T, DTR) 97 | DTE_PCA = numpy.dot(P.T, DTE) 98 | 99 | PCA_mvg, PCA_mvg_naive, PCA_mvg_t, PCA_mvg_nt = compute_MVG_score( 100 | DTE_PCA, 101 | DTR_PCA, 102 | LTR, 103 | PCA_mvg, 104 | PCA_mvg_naive, 105 | PCA_mvg_t, 106 | PCA_mvg_nt, 107 | MVG_labels) 108 | 109 | # PCA m=9 110 | P = PCA(DTR, LTR, m=9) 111 | DTR_PCA = numpy.dot(P.T, DTR) 112 | DTE_PCA = numpy.dot(P.T, DTE) 113 | 114 | PCA2_mvg, PCA2_mvg_naive, PCA_2mvg_t, PCA2_mvg_nt = compute_MVG_score( 115 | DTE_PCA, 116 | DTR_PCA, 117 | LTR, 118 | PCA2_mvg, 119 | PCA2_mvg_naive, 120 | PCA2_mvg_t, 121 | PCA2_mvg_nt, 122 | MVG_labels) 123 | 124 | # π = 0.5 (our application prior) 125 | evaluation("minDCF: π=0.5", 0.5, MVG_res, MVG_naive, MVG_t, MVG_nt, MVG_labels, appendToTitle + 'minDCF_π=0.5__') 126 | 127 | ############################### 128 | 129 | # π = 0.1 130 | evaluation("minDCF: π=0.1", 0.1, MVG_res, MVG_naive, MVG_t, MVG_nt, MVG_labels, appendToTitle + 'minDCF_π=0.1__') 131 | 132 | ############################### 133 | 134 | # π = 0.9 135 | evaluation("minDCF: π=0.9", 0.9, MVG_res, MVG_naive, MVG_t, MVG_nt, MVG_labels, appendToTitle + "minDCF_π=0.9__") 136 | 137 | if PCA_Flag is True: 138 | # PCA m=10 139 | # π = 0.5 (our application prior) 140 | evaluation("minDCF: π=0.5 | PCA m=10", 0.5, PCA_mvg, 141 | PCA_mvg_naive, 142 | PCA_mvg_t, 143 | PCA_mvg_nt, 144 | MVG_labels, appendToTitle + "minDCF_π=0.5_PCA m=10__") 145 | 146 | ############################### 147 | 148 | # π = 0.1 149 | evaluation("minDCF: π=0.1 | PCA m=10", 0.1, PCA_mvg, 150 | PCA_mvg_naive, 151 | PCA_mvg_t, 152 | PCA_mvg_nt, 153 | MVG_labels, appendToTitle + "minDCF_π=0.1_PCA m=10__") 154 | 155 | ############################### 156 | 157 | # π = 0.9 158 | evaluation("minDCF: π=0.9 | PCA m=10", 0.9, PCA_mvg, 159 | PCA_mvg_naive, 160 | PCA_mvg_t, 161 | PCA_mvg_nt, 162 | MVG_labels, appendToTitle + "minDCF_π=0.9_PCA m=10__") 163 | 164 | # PCA m=9 165 | # π = 0.5 (our application prior) 166 | evaluation("minDCF: π=0.5 | PCA m=9", 0.5, PCA2_mvg, 167 | PCA2_mvg_naive, 168 | PCA2_mvg_t, 169 | PCA2_mvg_nt, 170 | MVG_labels, appendToTitle + "minDCF_π=0.5_PCA m=9__") 171 | 172 | ############################### 173 | 174 | # π = 0.1 175 | evaluation("minDCF: π=0.1 | PCA m=9", 0.1, PCA2_mvg, 176 | PCA2_mvg_naive, 177 | PCA2_mvg_t, 178 | PCA2_mvg_nt, 179 | MVG_labels, appendToTitle + "minDCF_π=0.1_PCA m=9__") 180 | 181 | ############################### 182 | 183 | # π = 0.9 184 | evaluation("minDCF: π=0.9 | PCA m=9", 0.9, PCA2_mvg, 185 | PCA2_mvg_naive, 186 | PCA2_mvg_t, 187 | PCA2_mvg_nt, 188 | MVG_labels, appendToTitle + "minDCF_π=0.9_PCA m=9__") 189 | -------------------------------------------------------------------------------- /code/evaluators/evaluation_QLR_GAUSSIANIZED_.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/evaluation_QLR_GAUSSIANIZED_.npz -------------------------------------------------------------------------------- /code/evaluators/evaluation_QLR_RAW_.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/evaluation_QLR_RAW_.npz -------------------------------------------------------------------------------- /code/evaluators/evaluation_QLR_Z-NORM_.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/evaluators/evaluation_QLR_Z-NORM_.npz -------------------------------------------------------------------------------- /code/evaluators/evaluation_SVM.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | 4 | import numpy as np 5 | 6 | sys.path.append('../') 7 | from validators import * 8 | from prettytable import PrettyTable 9 | 10 | 11 | def evaluate_SVM(DTR, LTR, DTE, LTE, K, C, appendToTitle, PCA_Flag=True): 12 | scores_append = [] 13 | SVM_labels = [] 14 | 15 | wStar, _ = train_SVM_linear(DTR, LTR, C=C, K=K) 16 | 17 | DTEEXT = numpy.vstack([DTE, K * numpy.ones((1, DTE.shape[1]))]) 18 | 19 | scores = numpy.dot(wStar.T, DTEEXT).ravel() 20 | scores_append.append(scores) 21 | 22 | SVM_labels = np.append(SVM_labels, LTE, axis=0) 23 | SVM_labels = np.hstack(SVM_labels) 24 | 25 | scores_append = np.hstack(scores_append) 26 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.5, 1, 1) 27 | 28 | # plot_ROC(scores_append, SVM_labels, appendToTitle + 'SVM, K=' + str(K) + ', C=' + str(C)) 29 | 30 | # Cfn and Ctp are set to 1 31 | # bayes_error_min_act_plot(scores_append, SVM_labels, appendToTitle + 'SVM, K=' + str(K) + ', C=' + str(C), 0.4) 32 | 33 | t = PrettyTable(["Type", "minDCF"]) 34 | t.title = "minDCF: π=0.5" 35 | t.add_row(['SVM, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 36 | print(t) 37 | 38 | ############################### 39 | 40 | # π = 0.1 41 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.1, 1, 1) 42 | 43 | t = PrettyTable(["Type", "minDCF"]) 44 | t.title = "minDCF: π=0.1" 45 | t.add_row(['SVM, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 46 | 47 | print(t) 48 | 49 | ############################### 50 | 51 | # π = 0.9 52 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.9, 1, 1) 53 | 54 | t = PrettyTable(["Type", "minDCF"]) 55 | t.title = "minDCF: π=0.9" 56 | t.add_row(['SVM, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 57 | 58 | print(t) 59 | 60 | 61 | def svm_tuning(DTR, LTR,DTE, LTE, K, C): 62 | scores_append = [] 63 | labels = [] 64 | 65 | wStar, _ = train_SVM_linear(DTR, LTR, C=C, K=K) 66 | DTEEXT = numpy.vstack([DTE, K * numpy.ones((1, DTE.shape[1]))]) 67 | 68 | scores = numpy.dot(wStar.T, DTEEXT).ravel() 69 | scores_append.append(scores) 70 | 71 | labels = np.append(labels, LTE, axis=0) 72 | labels = np.hstack(labels) 73 | 74 | return np.hstack(scores_append), labels 75 | 76 | 77 | def evaluation_SVM(DTR, LTR, DTE, LTE, K_arr, C_arr, appendToTitle, PCA_Flag=True): 78 | for K in K_arr: 79 | for C in C_arr: 80 | evaluate_SVM(DTR, LTR, DTE, LTE, K, C, appendToTitle, PCA_Flag=False) 81 | x = numpy.logspace(-3, 2, 14) 82 | y = numpy.array([]) 83 | y_05 = numpy.array([]) 84 | y_09 = numpy.array([]) 85 | y_01 = numpy.array([]) 86 | for xi in x: 87 | scores, labels = svm_tuning(DTR, LTR, DTE, LTE, 1.0, xi) 88 | y_05 = numpy.hstack((y_05, bayes_error_plot_compare(0.5, scores, labels))) 89 | y_09 = numpy.hstack((y_09, bayes_error_plot_compare(0.9, scores, labels))) 90 | y_01 = numpy.hstack((y_01, bayes_error_plot_compare(0.1, scores, labels))) 91 | 92 | y = numpy.hstack((y, y_05)) 93 | y = numpy.vstack((y, y_09)) 94 | y = numpy.vstack((y, y_01)) 95 | 96 | plot_DCF(x, y, 'C', appendToTitle + 'Linear_SVM_minDCF_comparison') 97 | -------------------------------------------------------------------------------- /code/evaluators/evaluation_SVM_RBF.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | 4 | import numpy as np 5 | 6 | sys.path.append('../') 7 | from validators import * 8 | from prettytable import PrettyTable 9 | 10 | 11 | def evaluate_SVM_RBF(DTR, LTR, DTE, LTE, appendToTitle, C=1.0, K=1.0, gamma=0.01, PCA_Flag=False): 12 | SVM_labels = [] 13 | Z = numpy.zeros(LTR.shape) 14 | Z[LTR == 1] = 1 15 | Z[LTR == 0] = -1 16 | aStar, loss = train_SVM_RBF(DTR, LTR, C=C, K=K, gamma=gamma) 17 | 18 | kern = numpy.zeros((DTR.shape[1], DTE.shape[1])) 19 | for i in range(DTR.shape[1]): 20 | for j in range(DTE.shape[1]): 21 | kern[i, j] = numpy.exp(-gamma * (numpy.linalg.norm(DTR[:, i] - DTE[:, j]) ** 2)) + K * K 22 | 23 | score = numpy.sum(numpy.dot(aStar * mrow(Z), kern), axis=0) 24 | 25 | SVM_labels = np.append(SVM_labels, LTE, axis=0) 26 | SVM_labels = np.hstack(SVM_labels) 27 | 28 | scores_append = np.hstack(score) 29 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.5, 1, 1) 30 | 31 | # plot_ROC(scores_append, SVM_labels, appendToTitle + 'SVM, K=' + str(K) + ', C=' + str(C)) 32 | 33 | # Cfn and Ctp are set to 1 34 | # bayes_error_min_act_plot(scores_append, SVM_labels, appendToTitle + 'SVM, K=' + str(K) + ', C=' + str(C), 0.4) 35 | 36 | t = PrettyTable(["Type", "minDCF"]) 37 | t.title = "minDCF: π=0.5" 38 | t.add_row(['SVM_RBF, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 39 | print(t) 40 | 41 | ############################### 42 | 43 | # π = 0.1 44 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.1, 1, 1) 45 | 46 | t = PrettyTable(["Type", "minDCF"]) 47 | t.title = "minDCF: π=0.1" 48 | t.add_row(['SVM_RBF, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 49 | 50 | print(t) 51 | 52 | ############################### 53 | 54 | # π = 0.9 55 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.9, 1, 1) 56 | 57 | t = PrettyTable(["Type", "minDCF"]) 58 | t.title = "minDCF: π=0.9" 59 | t.add_row(['SVM_RBF, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 60 | 61 | print(t) 62 | 63 | def svm_rbf_calibration(DTR, LTR, DTE, LTE, c, gamma): 64 | scores_append = [] 65 | SVM_labels = [] 66 | 67 | K = 1.0 68 | Z = numpy.zeros(LTR.shape) 69 | Z[LTR == 1] = 1 70 | Z[LTR == 0] = -1 71 | aStar, loss = train_SVM_RBF(DTR, LTR, C=c, K=K, gamma=gamma) 72 | 73 | kern = numpy.zeros((DTR.shape[1], DTE.shape[1])) 74 | for i in range(DTR.shape[1]): 75 | for j in range(DTE.shape[1]): 76 | kern[i, j] = numpy.exp(-gamma * (numpy.linalg.norm(DTR[:, i] - DTE[:, j]) ** 2)) + K * K 77 | 78 | scores = numpy.sum(numpy.dot(aStar * mrow(Z), kern), axis=0) 79 | scores_append.append(scores) 80 | 81 | SVM_labels = np.append(SVM_labels, LTE, axis=0) 82 | SVM_labels = np.hstack(SVM_labels) 83 | 84 | return np.hstack(scores_append), SVM_labels 85 | 86 | def evaluation_SVM_RBF(DTR, LTR, DTE, LTE, K_arr, gamma_arr, appendToTitle, PCA_Flag=True): 87 | for K in K_arr: 88 | for gamma in gamma_arr: 89 | evaluate_SVM_RBF(DTR, LTR, DTE, LTE, appendToTitle, C=1.0, K=K, gamma=gamma, PCA_Flag=False) 90 | 91 | x = numpy.logspace(-4, 2, 15) #x contains different values of C 92 | y = numpy.array([]) 93 | gamma_minus_3 = numpy.array([]) 94 | gamma_minus_2 = numpy.array([]) 95 | gamma_minus_1 = numpy.array([]) 96 | gamma_minus_0 = numpy.array([]) 97 | 98 | for xi in x: 99 | print(xi) 100 | scores_gamma_minus_3, labels = svm_rbf_calibration(DTR, LTR, DTE, LTE, xi, 1e-3) 101 | scores_gamma_minus_2, _ = svm_rbf_calibration(DTR, LTR, DTE, LTE, xi, 1e-2) 102 | scores_gamma_minus_1, _ = svm_rbf_calibration(DTR, LTR, DTE, LTE, xi, 1e-1) 103 | scores_gamma_minus_0, _ = svm_rbf_calibration(DTR, LTR, DTE, LTE, xi, 1e-0) 104 | 105 | gamma_minus_3 = numpy.hstack((gamma_minus_3, bayes_error_plot_compare(0.5, scores_gamma_minus_3, labels))) 106 | gamma_minus_2 = numpy.hstack((gamma_minus_2, bayes_error_plot_compare(0.5, scores_gamma_minus_2, labels))) 107 | gamma_minus_1 = numpy.hstack((gamma_minus_1, bayes_error_plot_compare(0.5, scores_gamma_minus_1, labels))) 108 | gamma_minus_0 = numpy.hstack((gamma_minus_0, bayes_error_plot_compare(0.5, scores_gamma_minus_0, labels))) 109 | 110 | y = numpy.hstack((y, gamma_minus_3)) 111 | y = numpy.vstack((y, gamma_minus_2)) 112 | y = numpy.vstack((y, gamma_minus_1)) 113 | y = numpy.vstack((y, gamma_minus_0)) 114 | 115 | plot_DCF_for_SVM_RBF_calibration(x, y, 'C', appendToTitle + 'EVAL_SVM_RBF_minDCF_comparison') 116 | 117 | -------------------------------------------------------------------------------- /code/evaluators/evaluation_SVM_polynomial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | 4 | import numpy as np 5 | 6 | sys.path.append('../') 7 | from validators import * 8 | from prettytable import PrettyTable 9 | 10 | 11 | def evaluate_SVM_polynomial(DTR, LTR, DTE, LTE, K, costant, appendToTitle, C=1.0, degree=2, PCA_Flag=True): 12 | scores_append = [] 13 | SVM_labels = [] 14 | 15 | aStar, loss = train_SVM_polynomial(DTR, LTR, C=C, constant=costant, degree=degree, K=K) 16 | Z = numpy.zeros(LTR.shape) 17 | Z[LTR == 1] = 1 18 | Z[LTR == 0] = -1 19 | kernel = (numpy.dot(DTR.T, DTE) + costant) ** degree + K * K 20 | scores = numpy.sum(numpy.dot(aStar * mrow(Z), kernel), axis=0) 21 | scores_append.append(scores) 22 | 23 | SVM_labels = np.append(SVM_labels, LTE, axis=0) 24 | SVM_labels = np.hstack(SVM_labels) 25 | 26 | scores_append = np.hstack(scores_append) 27 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.5, 1, 1) 28 | 29 | # plot_ROC(scores_append, SVM_labels, appendToTitle + 'SVM, K=' + str(K) + ', C=' + str(C)) 30 | 31 | # Cfn and Ctp are set to 1 32 | # bayes_error_min_act_plot(scores_append, SVM_labels, appendToTitle + 'SVM, K=' + str(K) + ', C=' + str(C), 0.4) 33 | 34 | t = PrettyTable(["Type", "minDCF"]) 35 | t.title = "minDCF: π=0.5" 36 | t.add_row(['SVM_POLYNOMIAL, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 37 | print(t) 38 | 39 | ############################### 40 | 41 | # π = 0.1 42 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.1, 1, 1) 43 | 44 | t = PrettyTable(["Type", "minDCF"]) 45 | t.title = "minDCF: π=0.1" 46 | t.add_row(['SVM_POLYNOMIAL, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 47 | 48 | print(t) 49 | 50 | ############################### 51 | 52 | # π = 0.9 53 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.9, 1, 1) 54 | 55 | t = PrettyTable(["Type", "minDCF"]) 56 | t.title = "minDCF: π=0.9" 57 | t.add_row(['SVM_POLYNOMIAL, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 58 | 59 | print(t) 60 | 61 | 62 | def kfold_SVM_calibration(DTR, LTR, K, C): 63 | k = 5 64 | Dtr = numpy.split(DTR, k, axis=1) 65 | Ltr = numpy.split(LTR, k) 66 | 67 | scores_append = [] 68 | LR_labels = [] 69 | 70 | for i in range(k): 71 | D = [] 72 | L = [] 73 | if i == 0: 74 | D.append(np.hstack(Dtr[i + 1:])) 75 | L.append(np.hstack(Ltr[i + 1:])) 76 | elif i == k - 1: 77 | D.append(np.hstack(Dtr[:i])) 78 | L.append(np.hstack(Ltr[:i])) 79 | else: 80 | D.append(np.hstack(Dtr[:i])) 81 | D.append(np.hstack(Dtr[i + 1:])) 82 | L.append(np.hstack(Ltr[:i])) 83 | L.append(np.hstack(Ltr[i + 1:])) 84 | 85 | D = np.hstack(D) 86 | L = np.hstack(L) 87 | 88 | Dte = Dtr[i] 89 | Lte = Ltr[i] 90 | print(i) 91 | wStar, primal, dual, gap = train_SVM_linear(D, L, C=C, K=K) 92 | DTEEXT = numpy.vstack([Dte, K * numpy.ones((1, Dte.shape[1]))]) 93 | 94 | scores = numpy.dot(wStar.T, DTEEXT).ravel() 95 | scores_append.append(scores) 96 | 97 | LR_labels = np.append(LR_labels, Lte, axis=0) 98 | LR_labels = np.hstack(LR_labels) 99 | 100 | return np.hstack(scores_append), LR_labels 101 | 102 | 103 | def evaluation_SVM_polynomial(DTR, LTR, DTE, LTE, K_arr, C, appendToTitle, CON_array, PCA_Flag=True): 104 | for costant in CON_array: 105 | for degree in [2]: 106 | for K in K_arr: 107 | evaluate_SVM_polynomial(DTR, LTR, DTE, LTE, K, costant, appendToTitle, C=C, degree=degree, PCA_Flag=False) 108 | -------------------------------------------------------------------------------- /code/evaluators/evaluation_quad_LR.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | from os import path 4 | import numpy as np 5 | 6 | from validation.validation_quad_LR import kfold_QUAD_LR_tuning 7 | 8 | sys.path.append('../') 9 | from validators import * 10 | from prettytable import PrettyTable 11 | 12 | def compare_QLR_val_eval(x, D, title, base=10): 13 | plt.figure() 14 | plt.plot(x, D[0][0], color='r', label='minDCF(π=0.5)[Eval]') 15 | plt.plot(x, D[0][2], color='b', label='minDCF(π=0.1)[Eval]') 16 | plt.plot(x, D[0][1], color='g', label='minDCF(π=0.9)[Eval]') 17 | plt.plot(x, D[1][0], color='r', linestyle='dashed', label='minDCF(π=0.5)[Val]') 18 | plt.plot(x, D[1][2], color='b', linestyle='dashed', label='minDCF(π=0.1)[Val]') 19 | plt.plot(x, D[1][1], color='g', linestyle='dashed', label='minDCF(π=0.9)[Val]') 20 | plt.xscale("log", base=base) 21 | plt.xlim([min(x), max(x)]) 22 | #plt.ylim(0, ylim) 23 | plt.legend() 24 | plt.savefig('./images/QuadLogReg_eval_' + title + '.svg') 25 | plt.show() 26 | 27 | def validate_LR(scores, LR_labels, appendToTitle, l, pi): 28 | scores_tot_05 = compute_min_DCF(scores, LR_labels, 0.5, 1, 1) 29 | scores_tot_01 = compute_min_DCF(scores, LR_labels, 0.1, 1, 1) 30 | scores_tot_09 = compute_min_DCF(scores, LR_labels, 0.9, 1, 1) 31 | # plot_ROC(scores_append, LR_labels, appendToTitle + 'WEIGHTED_LR, lambda=' + str(l)) 32 | 33 | # Cfn and Ctp are set to 1 34 | # bayes_error_min_act_plot(scores_append, LR_labels, appendToTitle + 'WEIGHTED_LR, lambda=' + str(l), 0.4) 35 | 36 | t = PrettyTable(["Type", "π=0.5", "π=0.1", "π=0.9"]) 37 | t.title = appendToTitle 38 | t.add_row(['QUAD_LR, lambda=' + str(l) + " π_t=" + str(pi), round(scores_tot_05, 3), round(scores_tot_01, 3), round(scores_tot_09, 3)]) 39 | print(t) 40 | 41 | 42 | def evaluate_LR(DTR, LTR, DTE, LTE, l, pi, appendToTitle, PCA_Flag=True, zscore_Flag=False, gauss_Flag=False): 43 | 44 | if zscore_Flag is True: 45 | DTR, DTE = znorm(DTR, DTE) 46 | 47 | if gauss_Flag is True: 48 | D_training = DTR 49 | DTR = gaussianize_features(DTR, DTR) 50 | DTE = gaussianize_features(D_training, DTE) 51 | 52 | def vecxxT(x): 53 | x = x[:, None] 54 | xxT = x.dot(x.T).reshape(x.size ** 2, order='F') 55 | return xxT 56 | 57 | expanded_DTR = numpy.apply_along_axis(vecxxT, 0, DTR) 58 | expanded_DTE = numpy.apply_along_axis(vecxxT, 0, DTE) 59 | phi = numpy.vstack([expanded_DTR, DTR]) 60 | 61 | phi_DTE = numpy.vstack([expanded_DTE, DTE]) 62 | 63 | scores = quad_logistic_reg_score(phi, LTR, phi_DTE, l, pi=pi) 64 | validate_LR(scores, LTE, appendToTitle, l, pi=pi) 65 | 66 | # PCA m=10 67 | P = PCA(DTR, LTR, m=10) 68 | DTR_PCA = numpy.dot(P.T, DTR) 69 | DTE_PCA = numpy.dot(P.T, DTE) 70 | 71 | PCA_LR_scores = quad_logistic_reg_score(DTR_PCA, LTR, DTE_PCA, l, pi=pi) 72 | validate_LR(PCA_LR_scores, LTE, appendToTitle + 'PCA_m10_', l, pi=pi) 73 | 74 | 75 | 76 | def quadlr_tuning(DTR, LTR, DTE, LTE, xi, zscore_Flag=False, gauss_Flag=False): 77 | 78 | if zscore_Flag is True: 79 | DTR, DTE = znorm(DTR, DTE) 80 | 81 | if gauss_Flag is True: 82 | D_training = DTR 83 | DTR = gaussianize_features(DTR, DTR) 84 | DTE = gaussianize_features(D_training, DTE) 85 | 86 | def vecxxT(x): 87 | x = x[:, None] 88 | xxT = x.dot(x.T).reshape(x.size ** 2, order='F') 89 | return xxT 90 | 91 | expanded_DTR = numpy.apply_along_axis(vecxxT, 0, DTR) 92 | expanded_DTE = numpy.apply_along_axis(vecxxT, 0, DTE) 93 | phi = numpy.vstack([expanded_DTR, DTR]) 94 | 95 | phi_DTE = numpy.vstack([expanded_DTE, DTE]) 96 | 97 | scores = quad_logistic_reg_score(phi, LTR, phi_DTE, xi) 98 | 99 | return scores, LTE 100 | 101 | 102 | def evaluation_quad_LR(DTR, LTR, DTE, LTE, L, appendToTitle, gauss_Flag=False, zscore_Flag=False): 103 | for l in L: # l is a constant, not an array 104 | evaluate_LR(DTR, LTR, DTE, LTE, l, 0.5, appendToTitle, gauss_Flag=gauss_Flag, zscore_Flag=zscore_Flag) 105 | evaluate_LR(DTR, LTR, DTE, LTE, l, 0.1, appendToTitle, gauss_Flag=gauss_Flag, zscore_Flag=zscore_Flag) 106 | evaluate_LR(DTR, LTR, DTE, LTE, l, 0.9, appendToTitle, gauss_Flag=gauss_Flag, zscore_Flag=zscore_Flag) 107 | x = numpy.logspace(-5, 1, 24) 108 | y = numpy.array([]) 109 | eval_05 = numpy.array([]) 110 | eval_09 = numpy.array([]) 111 | eval_01 = numpy.array([]) 112 | 113 | val = numpy.array([]) 114 | val_05 = numpy.array([]) 115 | val_09 = numpy.array([]) 116 | val_01 = numpy.array([]) 117 | filepath = './evaluators/evaluation_QLR_' + appendToTitle + '.npz' 118 | if path.exists(filepath): 119 | arrays = np.load(filepath) 120 | y = arrays['eval'] 121 | val = arrays['val'] 122 | else: 123 | 124 | for xi in x: 125 | scores, labels = quadlr_tuning(DTR, LTR, DTE, LTE, xi, zscore_Flag, gauss_Flag) 126 | eval_05 = numpy.hstack((eval_05, bayes_error_plot_compare(0.5, scores, labels))) 127 | eval_09 = numpy.hstack((eval_09, bayes_error_plot_compare(0.9, scores, labels))) 128 | eval_01 = numpy.hstack((eval_01, bayes_error_plot_compare(0.1, scores, labels))) 129 | 130 | scores, labels = kfold_QUAD_LR_tuning(DTR, LTR, xi, zscore_Flag=zscore_Flag, gauss_Flag=gauss_Flag) 131 | val_05 = numpy.hstack((val_05, bayes_error_plot_compare(0.5, scores, labels))) 132 | val_09 = numpy.hstack((val_09, bayes_error_plot_compare(0.9, scores, labels))) 133 | val_01 = numpy.hstack((val_01, bayes_error_plot_compare(0.1, scores, labels))) 134 | 135 | y = numpy.hstack((y, eval_05)) 136 | y = numpy.vstack((y, eval_09)) 137 | y = numpy.vstack((y, eval_01)) 138 | 139 | val = numpy.hstack((val, val_05)) 140 | val = numpy.vstack((val, val_09)) 141 | val = numpy.vstack((val, val_01)) 142 | 143 | np.savez('./evaluators/evaluation_QLR_' + appendToTitle + '.npz', val=val, eval=y) 144 | 145 | compare_QLR_val_eval(x, [y, val], appendToTitle) 146 | 147 | -------------------------------------------------------------------------------- /code/evaluators/evaluation_weighted_LR.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | 4 | import numpy as np 5 | 6 | from validation.validation_weighted_LR import kfold_WEIGHTED_LR_tuning 7 | 8 | sys.path.append('../') 9 | from validators import * 10 | from prettytable import PrettyTable 11 | import pylab 12 | import matplotlib.pyplot as plt 13 | 14 | def compare_LR_val_eval(x, D, title, base=10): 15 | plt.figure() 16 | plt.plot(x, D[0][0], color='r', label='minDCF(π=0.5)[Eval]') 17 | plt.plot(x, D[0][2], color='b', label='minDCF(π=0.1)[Eval]') 18 | plt.plot(x, D[0][1], color='g', label='minDCF(π=0.9)[Eval]') 19 | plt.plot(x, D[1][0], color='r', linestyle='dashed', label='minDCF(π=0.5)[Val]') 20 | plt.plot(x, D[1][2], color='b', linestyle='dashed', label='minDCF(π=0.1)[Val]') 21 | plt.plot(x, D[1][1], color='g', linestyle='dashed', label='minDCF(π=0.9)[Val]') 22 | plt.xscale("log", base=base) 23 | plt.xlim([min(x), max(x)]) 24 | plt.legend() 25 | plt.savefig('./images/LogReg_eval_' + title + '.svg') 26 | plt.show() 27 | 28 | def validate_LR(scores, LR_labels, appendToTitle, l, pi): 29 | scores_tot_05 = compute_min_DCF(scores, LR_labels, 0.5, 1, 1) 30 | scores_tot_01 = compute_min_DCF(scores, LR_labels, 0.1, 1, 1) 31 | scores_tot_09 = compute_min_DCF(scores, LR_labels, 0.9, 1, 1) 32 | 33 | t = PrettyTable(["Type", "π=0.5", "π=0.1", "π=0.9"]) 34 | t.title = appendToTitle 35 | t.add_row(['WEIGHTED_LR, lambda=' + str(l) + " π_t=" + str(pi), round(scores_tot_05, 3), round(scores_tot_01, 3), round(scores_tot_09, 3)]) 36 | print(t) 37 | 38 | 39 | def evaluate_LR(DTR, LTR, DTE, LTE, l, pi, appendToTitle, PCA_Flag=True, zscore_Flag=False, gauss_Flag=False): 40 | 41 | if zscore_Flag is True: 42 | DTR, DTE = znorm(DTR, DTE) 43 | 44 | if gauss_Flag is True: 45 | D_training = DTR 46 | DTR = gaussianize_features(DTR, DTR) 47 | DTE = gaussianize_features(D_training, DTE) 48 | 49 | scores = weighted_logistic_reg_score(DTR, LTR, DTE, l, pi) 50 | validate_LR(scores, LTE, appendToTitle, l, pi) 51 | 52 | # PCA m=10 53 | P = PCA(DTR, LTR, m=10) 54 | DTR_PCA = numpy.dot(P.T, DTR) 55 | DTE_PCA = numpy.dot(P.T, DTE) 56 | 57 | PCA_LR_scores = weighted_logistic_reg_score(DTR_PCA, LTR, DTE_PCA, l, pi=pi) 58 | validate_LR(PCA_LR_scores, LTE, appendToTitle + 'PCA_m10_', l, pi=pi) 59 | 60 | 61 | def lr_tuning(DTR, LTR, DTE, LTE, xi, zscore_Flag=False, gauss_Flag=False): 62 | 63 | if zscore_Flag is True: 64 | DTR, DTE = znorm(DTR, DTE) 65 | 66 | if gauss_Flag is True: 67 | D_training = DTR 68 | DTR = gaussianize_features(DTR, DTR) 69 | DTE = gaussianize_features(D_training, DTE) 70 | 71 | scores = weighted_logistic_reg_score(DTR, LTR, DTE, xi) 72 | 73 | return scores, LTE 74 | 75 | 76 | def evaluation_weighted_LR(DTR, LTR, DTE, LTE, L, appendToTitle, gauss_Flag=False, zscore_Flag=False): 77 | 78 | for l in L: # l is a constant, not an array 79 | evaluate_LR(DTR, LTR, DTE, LTE, l, 0.5, appendToTitle, gauss_Flag=gauss_Flag, zscore_Flag=zscore_Flag) 80 | evaluate_LR(DTR, LTR, DTE, LTE, l, 0.1, appendToTitle, gauss_Flag=gauss_Flag, zscore_Flag=zscore_Flag) 81 | evaluate_LR(DTR, LTR, DTE, LTE, l, 0.9, appendToTitle, gauss_Flag=gauss_Flag, zscore_Flag=zscore_Flag) 82 | 83 | x = numpy.logspace(-5, 1, 30) 84 | y = numpy.array([]) 85 | val = numpy.array([]) 86 | eval_05 = numpy.array([]) 87 | eval_09 = numpy.array([]) 88 | eval_01 = numpy.array([]) 89 | 90 | val_05 = numpy.array([]) 91 | val_09 = numpy.array([]) 92 | val_01 = numpy.array([]) 93 | 94 | for xi in x: 95 | scores, labels_val = lr_tuning(DTR, LTR, DTE, LTE, xi, zscore_Flag, gauss_Flag) 96 | eval_05 = numpy.hstack((eval_05, bayes_error_plot_compare(0.5, scores, labels_val))) 97 | eval_09 = numpy.hstack((eval_09, bayes_error_plot_compare(0.9, scores, labels_val))) 98 | eval_01 = numpy.hstack((eval_01, bayes_error_plot_compare(0.1, scores, labels_val))) 99 | 100 | scores, labels = kfold_WEIGHTED_LR_tuning(DTR, LTR, xi, zscore_Flag=zscore_Flag, gauss_Flag=gauss_Flag) 101 | val_05 = numpy.hstack((val_05, bayes_error_plot_compare(0.5, scores, labels))) 102 | val_09 = numpy.hstack((val_09, bayes_error_plot_compare(0.9, scores, labels))) 103 | val_01 = numpy.hstack((val_01, bayes_error_plot_compare(0.1, scores, labels))) 104 | y = numpy.hstack((y, eval_05)) 105 | y = numpy.vstack((y, eval_09)) 106 | y = numpy.vstack((y, eval_01)) 107 | 108 | val = numpy.hstack((val, val_05)) 109 | val = numpy.vstack((val, val_09)) 110 | val = numpy.vstack((val, val_01)) 111 | 112 | print("y shape: ", y.shape) 113 | print("val shape: ", val.shape) 114 | 115 | compare_LR_val_eval(x, [y, val], appendToTitle) 116 | # plot_DCF(x, y, 'lambda', appendToTitle + 'EVAL_WLR_minDCF_comparison') 117 | -------------------------------------------------------------------------------- /code/functions/__pycache__/calibrationFunc.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/functions/__pycache__/calibrationFunc.cpython-310.pyc -------------------------------------------------------------------------------- /code/functions/__pycache__/calibrationFunc.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/functions/__pycache__/calibrationFunc.cpython-39.pyc -------------------------------------------------------------------------------- /code/functions/__pycache__/mlFunc.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/functions/__pycache__/mlFunc.cpython-310.pyc -------------------------------------------------------------------------------- /code/functions/__pycache__/mlFunc.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/functions/__pycache__/mlFunc.cpython-39.pyc -------------------------------------------------------------------------------- /code/images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/.DS_Store -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_LR, lambda=0.0001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_LR, lambda=0.0001.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_LR, lambda=0.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_LR, lambda=0.01.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_LR, lambda=1e-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_LR, lambda=1e-06.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.1__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.1__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.1__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.1__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.1__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.1__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.1__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.1__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.5__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.5__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.5__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.5__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.5__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.5__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.5__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.5__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_GAUSSIANIZED_minDCF_π=0.9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GAUSSIANIZED_minDCF_π=0.9__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_GMM_diag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GMM_diag.png -------------------------------------------------------------------------------- /code/images/DCF_GMM_diag2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GMM_diag2.png -------------------------------------------------------------------------------- /code/images/DCF_GMM_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GMM_full.png -------------------------------------------------------------------------------- /code/images/DCF_GMM_full2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GMM_full2.png -------------------------------------------------------------------------------- /code/images/DCF_GMM_tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GMM_tied.png -------------------------------------------------------------------------------- /code/images/DCF_GMM_tied2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GMM_tied2.png -------------------------------------------------------------------------------- /code/images/DCF_GMM_tied_diag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GMM_tied_diag.png -------------------------------------------------------------------------------- /code/images/DCF_GMM_tied_diag2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_GMM_tied_diag2.png -------------------------------------------------------------------------------- /code/images/DCF_LR, lambda=0.0001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_LR, lambda=0.0001.png -------------------------------------------------------------------------------- /code/images/DCF_LR, lambda=0.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_LR, lambda=0.01.png -------------------------------------------------------------------------------- /code/images/DCF_LR, lambda=1.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_LR, lambda=1.0.png -------------------------------------------------------------------------------- /code/images/DCF_LR, lambda=1e-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_LR, lambda=1e-06.png -------------------------------------------------------------------------------- /code/images/DCF_MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_MVG.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_LR, lambda=0.0001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_LR, lambda=0.0001.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_LR, lambda=0.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_LR, lambda=0.01.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_LR, lambda=1.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_LR, lambda=1.0.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_LR, lambda=1e-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_LR, lambda=1e-06.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_LR_minDCF_comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_LR_minDCF_comparison.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_QUAD_LR_minDCF_comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_QUAD_LR_minDCF_comparison.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_SVM, K=0.1, C=0.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_SVM, K=0.1, C=0.01.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_SVM, K=0.1, C=0.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_SVM, K=0.1, C=0.1.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_SVM, K=0.1, C=1.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_SVM, K=0.1, C=1.0.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_SVM, K=0.1, C=10.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_SVM, K=0.1, C=10.0.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_SVM, K=1.0, C=0.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_SVM, K=1.0, C=0.01.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_SVM, K=1.0, C=0.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_SVM, K=1.0, C=0.1.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_SVM, K=1.0, C=1.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_SVM, K=1.0, C=1.0.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_SVM, K=1.0, C=10.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_SVM, K=1.0, C=10.0.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_SVM, K=10.0, C=0.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_SVM, K=10.0, C=0.01.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_SVM, K=10.0, C=0.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_SVM, K=10.0, C=0.1.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_SVM, K=10.0, C=1.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_SVM, K=10.0, C=1.0.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_SVM, K=10.0, C=10.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_SVM, K=10.0, C=10.0.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.1_PCA m=10__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.1_PCA m=10__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.1_PCA m=10__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.1_PCA m=10__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.1_PCA m=10__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.1_PCA m=10__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.1_PCA m=10__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.1_PCA m=10__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.1_PCA m=9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.1_PCA m=9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.1_PCA m=9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.1_PCA m=9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.1_PCA m=9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.1_PCA m=9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.1_PCA m=9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.1_PCA m=9__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.1__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.1__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.1__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.1__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.1__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.1__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.1__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.1__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.5_PCA m=10__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.5_PCA m=10__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.5_PCA m=10__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.5_PCA m=10__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.5_PCA m=10__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.5_PCA m=10__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.5_PCA m=10__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.5_PCA m=10__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.5_PCA m=9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.5_PCA m=9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.5_PCA m=9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.5_PCA m=9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.5_PCA m=9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.5_PCA m=9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.5_PCA m=9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.5_PCA m=9__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.5__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.5__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.5__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.5__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.5__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.5__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.5__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.5__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.9_PCA m=10__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.9_PCA m=10__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.9_PCA m=10__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.9_PCA m=10__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.9_PCA m=10__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.9_PCA m=10__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.9_PCA m=10__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.9_PCA m=10__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.9_PCA m=9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.9_PCA m=9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.9_PCA m=9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.9_PCA m=9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.9_PCA m=9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.9_PCA m=9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.9_PCA m=9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.9_PCA m=9__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/DCF_RAW_minDCF_π=0.9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_RAW_minDCF_π=0.9__MVG.png -------------------------------------------------------------------------------- /code/images/DCF_gauss_GMM_diag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_gauss_GMM_diag.png -------------------------------------------------------------------------------- /code/images/DCF_gauss_GMM_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_gauss_GMM_full.png -------------------------------------------------------------------------------- /code/images/DCF_gauss_GMM_tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_gauss_GMM_tied.png -------------------------------------------------------------------------------- /code/images/DCF_gauss_GMM_tied_diag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_gauss_GMM_tied_diag.png -------------------------------------------------------------------------------- /code/images/DCF_raw_GMM_diag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_raw_GMM_diag.png -------------------------------------------------------------------------------- /code/images/DCF_raw_GMM_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_raw_GMM_full.png -------------------------------------------------------------------------------- /code/images/DCF_raw_GMM_tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_raw_GMM_tied.png -------------------------------------------------------------------------------- /code/images/DCF_raw_GMM_tied_diag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/DCF_raw_GMM_tied_diag.png -------------------------------------------------------------------------------- /code/images/GAUSSIANIZED_PCA_m=2 + LDA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GAUSSIANIZED_PCA_m=2 + LDA.png -------------------------------------------------------------------------------- /code/images/GAUSSIANIZED_PCA_m=2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GAUSSIANIZED_PCA_m=2.png -------------------------------------------------------------------------------- /code/images/GAUSSIANIZED_PCA_m=3 + LDA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GAUSSIANIZED_PCA_m=3 + LDA.png -------------------------------------------------------------------------------- /code/images/GAUSSIANIZED_PCA_m=3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GAUSSIANIZED_PCA_m=3.png -------------------------------------------------------------------------------- /code/images/GMM/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GMM/.DS_Store -------------------------------------------------------------------------------- /code/images/GMM/diag-cov.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GMM/diag-cov.png -------------------------------------------------------------------------------- /code/images/GMM/full-cov.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GMM/full-cov.png -------------------------------------------------------------------------------- /code/images/GMM/gmm/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GMM/gmm/.DS_Store -------------------------------------------------------------------------------- /code/images/GMM/gmm/diag_cov.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GMM/gmm/diag_cov.png -------------------------------------------------------------------------------- /code/images/GMM/gmm/full_cov.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GMM/gmm/full_cov.png -------------------------------------------------------------------------------- /code/images/GMM/gmm/tied_diag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GMM/gmm/tied_diag.png -------------------------------------------------------------------------------- /code/images/GMM/gmm/tied_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GMM/gmm/tied_full.png -------------------------------------------------------------------------------- /code/images/GMM/tied diag-cov.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GMM/tied diag-cov.png -------------------------------------------------------------------------------- /code/images/GMM/tied full-cov.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/GMM/tied full-cov.png -------------------------------------------------------------------------------- /code/images/PCA_m=2 + LDA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/PCA_m=2 + LDA.png -------------------------------------------------------------------------------- /code/images/PCA_m=2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/PCA_m=2.png -------------------------------------------------------------------------------- /code/images/PCA_m=3 + LDA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/PCA_m=3 + LDA.png -------------------------------------------------------------------------------- /code/images/PCA_m=3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/PCA_m=3.png -------------------------------------------------------------------------------- /code/images/RAW_PCA_m=2 + LDA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/RAW_PCA_m=2 + LDA.png -------------------------------------------------------------------------------- /code/images/RAW_PCA_m=2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/RAW_PCA_m=2.png -------------------------------------------------------------------------------- /code/images/RAW_PCA_m=3 + LDA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/RAW_PCA_m=3 + LDA.png -------------------------------------------------------------------------------- /code/images/RAW_PCA_m=3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/RAW_PCA_m=3.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_LR, lambda=0.0001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_LR, lambda=0.0001.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_LR, lambda=0.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_LR, lambda=0.01.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_LR, lambda=1e-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_LR, lambda=1e-06.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=10__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.1_PCA m=9__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.1__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.1__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.1__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.1__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.1__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.1__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.1__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.1__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=10__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.5_PCA m=9__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.5__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.5__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.5__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.5__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.5__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.5__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.5__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.5__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=10__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.9_PCA m=9__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_GAUSSIANIZED_minDCF_π=0.9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GAUSSIANIZED_minDCF_π=0.9__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_GMM_diag2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GMM_diag2.png -------------------------------------------------------------------------------- /code/images/ROC_GMM_diag_raw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GMM_diag_raw.png -------------------------------------------------------------------------------- /code/images/ROC_GMM_full2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GMM_full2.png -------------------------------------------------------------------------------- /code/images/ROC_GMM_full_raw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GMM_full_raw.png -------------------------------------------------------------------------------- /code/images/ROC_GMM_tied2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GMM_tied2.png -------------------------------------------------------------------------------- /code/images/ROC_GMM_tied_diag2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GMM_tied_diag2.png -------------------------------------------------------------------------------- /code/images/ROC_GMM_tied_diag_raw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GMM_tied_diag_raw.png -------------------------------------------------------------------------------- /code/images/ROC_GMM_tied_raw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_GMM_tied_raw.png -------------------------------------------------------------------------------- /code/images/ROC_LR, lambda=0.0001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_LR, lambda=0.0001.png -------------------------------------------------------------------------------- /code/images/ROC_LR, lambda=0.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_LR, lambda=0.01.png -------------------------------------------------------------------------------- /code/images/ROC_LR, lambda=1.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_LR, lambda=1.0.png -------------------------------------------------------------------------------- /code/images/ROC_LR, lambda=1e-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_LR, lambda=1e-06.png -------------------------------------------------------------------------------- /code/images/ROC_MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_MVG.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_LR, lambda=0.0001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_LR, lambda=0.0001.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_LR, lambda=0.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_LR, lambda=0.01.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_LR, lambda=1.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_LR, lambda=1.0.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_LR, lambda=1e-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_LR, lambda=1e-06.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.1_PCA m=10__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.1_PCA m=10__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.1_PCA m=10__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.1_PCA m=10__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.1_PCA m=10__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.1_PCA m=10__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.1_PCA m=10__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.1_PCA m=10__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.1_PCA m=9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.1_PCA m=9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.1_PCA m=9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.1_PCA m=9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.1_PCA m=9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.1_PCA m=9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.1_PCA m=9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.1_PCA m=9__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.1__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.1__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.1__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.1__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.1__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.1__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.1__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.1__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.5_PCA m=10__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.5_PCA m=10__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.5_PCA m=10__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.5_PCA m=10__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.5_PCA m=10__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.5_PCA m=10__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.5_PCA m=10__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.5_PCA m=10__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.5_PCA m=9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.5_PCA m=9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.5_PCA m=9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.5_PCA m=9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.5_PCA m=9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.5_PCA m=9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.5_PCA m=9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.5_PCA m=9__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.5__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.5__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.5__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.5__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.5__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.5__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.5__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.5__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.9_PCA m=10__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.9_PCA m=10__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.9_PCA m=10__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.9_PCA m=10__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.9_PCA m=10__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.9_PCA m=10__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.9_PCA m=10__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.9_PCA m=10__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.9_PCA m=9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.9_PCA m=9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.9_PCA m=9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.9_PCA m=9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.9_PCA m=9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.9_PCA m=9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.9_PCA m=9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.9_PCA m=9__MVG.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.9__MVG + Naive + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.9__MVG + Naive + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.9__MVG + Naive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.9__MVG + Naive.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.9__MVG + Tied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.9__MVG + Tied.png -------------------------------------------------------------------------------- /code/images/ROC_RAW_minDCF_π=0.9__MVG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/ROC_RAW_minDCF_π=0.9__MVG.png -------------------------------------------------------------------------------- /code/images/comparison/ciao.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/comparison/ciao.txt -------------------------------------------------------------------------------- /code/images/heatmap_GAUSSIANIZED_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/heatmap_GAUSSIANIZED_.png -------------------------------------------------------------------------------- /code/images/heatmap_RAW_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/heatmap_RAW_.png -------------------------------------------------------------------------------- /code/images/heatmap_no_gauss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/heatmap_no_gauss.png -------------------------------------------------------------------------------- /code/images/histLDA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/histLDA.png -------------------------------------------------------------------------------- /code/images/histNo manipulation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/histNo manipulation.png -------------------------------------------------------------------------------- /code/images/histPCA + LDA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/histPCA + LDA.png -------------------------------------------------------------------------------- /code/images/histPCA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/histPCA.png -------------------------------------------------------------------------------- /code/images/histPCA_m=2 + LDA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/histPCA_m=2 + LDA.png -------------------------------------------------------------------------------- /code/images/histPCA_m=3 + LDA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/histPCA_m=3 + LDA.png -------------------------------------------------------------------------------- /code/images/hist_feature_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/hist_feature_0.png -------------------------------------------------------------------------------- /code/images/hist_feature_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/hist_feature_1.png -------------------------------------------------------------------------------- /code/images/hist_feature_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/hist_feature_10.png -------------------------------------------------------------------------------- /code/images/hist_feature_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/hist_feature_11.png -------------------------------------------------------------------------------- /code/images/hist_feature_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/hist_feature_2.png -------------------------------------------------------------------------------- /code/images/hist_feature_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/hist_feature_3.png -------------------------------------------------------------------------------- /code/images/hist_feature_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/hist_feature_4.png -------------------------------------------------------------------------------- /code/images/hist_feature_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/hist_feature_5.png -------------------------------------------------------------------------------- /code/images/hist_feature_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/hist_feature_6.png -------------------------------------------------------------------------------- /code/images/hist_feature_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/hist_feature_7.png -------------------------------------------------------------------------------- /code/images/hist_feature_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/hist_feature_8.png -------------------------------------------------------------------------------- /code/images/hist_feature_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/images/hist_feature_9.png -------------------------------------------------------------------------------- /code/main.py: -------------------------------------------------------------------------------- 1 | from evaluators.compare_best_2 import compute_2best_plots 2 | from evaluators.evaluation_GMM import evaluation_GMM_ncomp, experimental_GMM 3 | from evaluators.evaluation_LR import evaluation_LR 4 | from evaluators.evaluation_MVG import evaluation_MVG 5 | from evaluators.evaluation_SVM import evaluation_SVM 6 | from evaluators.evaluation_SVM_RBF import evaluation_SVM_RBF 7 | from evaluators.evaluation_SVM_polynomial import evaluation_SVM_polynomial 8 | from evaluators.evaluation_quad_LR import evaluation_quad_LR 9 | from evaluators.evaluation_weighted_LR import evaluation_weighted_LR 10 | from plot_features import plot_features 11 | from score_calibration.SVM_RBF_scores_calibration import SVM_RBF_score_calibration 12 | from score_calibration.SVM_scores_calibration import SVM_score_calibration 13 | from mlFunc import * 14 | from validation.validation_GMM import validation_GMM_ncomp, validation_GMM_tot 15 | from validation.validation_LR import validation_LR 16 | from validation.validation_MVG import validation_MVG 17 | from validation.validation_SVM import validation_SVM 18 | from validation.validation_SVM_RBF import validation_SVM_RBF 19 | from validation.validation_SVM_polynomial import validation_SVM_polynomial 20 | from validation.validation_compare import compare_2_validation 21 | from validation.validation_quad_LR import validation_quad_LR 22 | from validation.validation_weighted_LR import validation_weighted_LR 23 | 24 | 25 | def validation(DTR, LTR): 26 | print("############ MVG ##############") 27 | validation_MVG(DTR, LTR, 'RAW_') 28 | validation_MVG(DTR, LTR, 'GAUSSIANIZED_', Gauss_flag=True) 29 | validation_MVG(DTR, LTR, 'ZNORM_', zscore=True) 30 | 31 | print("############ Prior Weighted Logistic Regression ##############") 32 | L = [1e-5] 33 | validation_weighted_LR(DTR, LTR, L, 'RAW_', PCA_Flag=True, gauss_Flag=False, zscore_Flag=False) 34 | validation_weighted_LR(DTR, LTR, L, 'ZNORM_', PCA_Flag=True, gauss_Flag=False, zscore_Flag=True) 35 | validation_weighted_LR(DTR, LTR, L, 'GAUSSIANIZED_', PCA_Flag=True, gauss_Flag=True, zscore_Flag=False) 36 | 37 | print("############ Quadratic Logistic Regression ##############") 38 | validation_quad_LR(DTR, LTR, L, 'QUAD_', PCA_Flag=True, gauss_Flag=False, zscore_Flag=False) 39 | 40 | print("############ Support Vector Machine - Linear ##############") 41 | K_arr = [0.1, 1.0, 10.0] 42 | C_arr = [0.01, 0.1, 1.0, 10.0] 43 | validation_SVM(DTR, LTR, K_arr, C_arr, 'RAW_', gauss_Flag=False, zscore_Flag=False) 44 | validation_SVM(DTR, LTR, K_arr, C_arr, 'GAUSSIANIZED_', gauss_Flag=True, zscore_Flag=False) 45 | validation_SVM(DTR, LTR, K_arr, C_arr, 'ZNORMALIZED_', gauss_Flag=False, zscore_Flag=True) 46 | K_arr = [1.0] 47 | C_arr = [1.0] 48 | SVM_score_calibration(DTR, LTR, K_arr, C_arr, appendToTitle="SVM_SCORE_CALIBRATION_", PCA_Flag=True, 49 | gauss_Flag=False, zscore_Flag=False) 50 | 51 | print("############ Support Vector Machine - Quadratic ##############") 52 | K_arr = [1., 10.] 53 | validation_SVM_polynomial(DTR, LTR, K_arr, 1.0, 'RAW_', [1000], PCA_Flag=False, gauss_Flag=False, 54 | zscore_Flag=False) 55 | 56 | K_arr = [0.1, 1., 10.] 57 | C_arr = [1., 10.] 58 | 59 | print("############ Support Vector Machine - RBF ##############") 60 | validation_SVM_RBF(DTR, LTR, K_arr, [0.001], 'RAW_', PCA_Flag=False, gauss_Flag=False, zscore_Flag=False) 61 | K_arr = [1.0] 62 | SVM_RBF_score_calibration(DTR, LTR, K_arr, [0.001], 'SVM_RBF_SCORE_CALIBRATION_', PCA_Flag=False, gauss_Flag=False, 63 | zscore_Flag=False) 64 | 65 | print("############ Gaussian Mixture Models ##############") 66 | 67 | validation_GMM_tot(DTR, LTR, 0.5) 68 | validation_GMM_ncomp(DTR, LTR, 0.5, 2) 69 | validation_GMM_ncomp(DTR, LTR, 0.1, 2) 70 | validation_GMM_ncomp(DTR, LTR, 0.9, 2) 71 | 72 | 73 | def evaluation(DTR, LTR, DTE, LTE): 74 | DTR_GAUSS = gaussianize_features(DTR, DTR) 75 | DTE_GAUSS = gaussianize_features(DTR, DTE) 76 | DTR_ZNORM, DTE_ZNORM = znorm(DTR, DTE) 77 | 78 | print("############ MVG ##############") 79 | evaluation_MVG(DTR, LTR, DTE, LTE, 'RAW_') 80 | evaluation_MVG(DTR_GAUSS, LTR, DTE_GAUSS, LTE, 'GAUSSIANIZED_') 81 | evaluation_MVG(DTR_ZNORM, LTR, DTE_ZNORM, LTE, 'Z-NORM') 82 | 83 | print("############ Logistic Regression ##############") 84 | evaluation_weighted_LR(DTR, LTR, DTE, LTE, [1e-5], 'EVAL_RAW_WEIGHTED_LR_') 85 | evaluation_weighted_LR(DTR_GAUSS, LTR, DTE_GAUSS, LTE, [1e-5], 'EVAL_GAUSS_WEIGHTED_LR_') 86 | evaluation_weighted_LR(DTR_ZNORM, LTR, DTE_ZNORM, LTE, [1e-5], 'EVAL_ZNORM_WEIGHTED_LR_') 87 | 88 | print("############ Quadratic Logistic Regression ##############") 89 | evaluation_quad_LR(DTR, LTR, DTE, LTE, [1e-5], 'EVAL_WEIGHTED_LR_') 90 | 91 | print("############ Support Vector Machine - Linear ##############") 92 | evaluation_SVM(DTR, LTR, DTE, LTE, [1.0], [1.0], 'EVAL_SVM_LR', PCA_Flag=False) 93 | 94 | print("############ Support Vector Machine - Quadratic ##############") 95 | evaluation_SVM_polynomial(DTR, LTR, DTE, LTE, [1.0], 10.0, 'EVAL_SVM_POLY', [1], PCA_Flag=False) 96 | 97 | print("############ Support Vector Machine - RBF ##############") 98 | evaluation_SVM_RBF(DTR, LTR, DTE, LTE, [1.0], [0.001], 'EVAL_SVM_RFB', PCA_Flag=False) 99 | 100 | print("############ Gaussian Mixture Model - RAW ##############") 101 | evaluation_GMM_ncomp("RAW", DTR, LTR, DTE, LTE, 0.5, 2) 102 | evaluation_GMM_ncomp("RAW", DTR, LTR, DTE, LTE, 0.1, 2) 103 | evaluation_GMM_ncomp("RAW", DTR, LTR, DTE, LTE, 0.9, 2) 104 | evaluation_GMM_ncomp("gauss.", DTR_GAUSS, LTR, DTE_GAUSS, LTE, 0.5, 2) 105 | evaluation_GMM_ncomp("gauss.", DTR_GAUSS, LTR, DTE_GAUSS, LTE, 0.1, 2) 106 | evaluation_GMM_ncomp("gauss.", DTR_GAUSS, LTR, DTE_GAUSS, LTE, 0.9, 2) 107 | 108 | 109 | if __name__ == "__main__": 110 | DTR, LTR = load("Train.txt") 111 | DTR, LTR = randomize(DTR, LTR) 112 | DTE, LTE = load("Test.txt") 113 | DTE, LTE = randomize(DTE, LTE) 114 | DTR_GAUSS = gaussianize_features(DTR, DTR) 115 | plot_features(DTR, LTR, appendToTitle='RAW_') 116 | plot_features(DTR, LTR, appendToTitle='GAUSSIANIZED_') 117 | print("############ Validation ##############") 118 | validation(DTR, LTR) 119 | print("############ Evaluation ##############") 120 | evaluation(DTR, LTR, DTE, LTE) 121 | 122 | experimental_GMM(DTR, LTR, DTE, LTE) 123 | # Creates bayes error and ROC plots for 2 best models chosen (see inside) 124 | # compute_2best_plots(DTR, LTR, DTE, LTE) 125 | # compare_2_validation(DTR, LTR, [1e-4]) 126 | -------------------------------------------------------------------------------- /code/plot_features.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | import matplotlib.pyplot 4 | import scipy.stats 5 | import seaborn as sns 6 | 7 | sys.path.append("./") 8 | from mlFunc import * 9 | 10 | 11 | def compute_correlation(X, Y): 12 | x_sum = numpy.sum(X) 13 | y_sum = numpy.sum(Y) 14 | 15 | x2_sum = numpy.sum(X ** 2) 16 | y2_sum = numpy.sum(Y ** 2) 17 | 18 | sum_cross_prod = numpy.sum(X * Y.T) 19 | 20 | n = X.shape[0] 21 | numerator = n * sum_cross_prod - x_sum * y_sum 22 | denominator = numpy.sqrt((n * x2_sum - x_sum ** 2) * (n * y2_sum - y_sum ** 2)) 23 | 24 | corr = numerator / denominator 25 | return corr 26 | 27 | 28 | def plot_correlations(DTR, title, cmap="Greys"): 29 | corr = numpy.zeros((12, 12)) 30 | for x in range(12): 31 | for y in range(12): 32 | X = DTR[x, :] 33 | Y = DTR[y, :] 34 | pearson_elem = compute_correlation(X, Y) 35 | corr[x][y] = pearson_elem 36 | 37 | sns.set() 38 | heatmap = sns.heatmap(numpy.abs(corr), linewidth=0.2, cmap=cmap, square=True, cbar=False) 39 | fig = heatmap.get_figure() 40 | fig.savefig("./images/" + title + ".svg") 41 | 42 | 43 | def plot_features_histograms(DTR, LTR, _title): 44 | matplotlib.rcParams.update(matplotlib.rcParamsDefault) 45 | for i in range(12): 46 | labels = ["male", "female"] 47 | title = _title + str(i) 48 | plt.figure() 49 | plt.title(title) 50 | 51 | y = DTR[:, LTR == 0][i] 52 | plt.hist(y, bins=60, density=True, alpha=0.4, linewidth=1.0, color='red', edgecolor='black', 53 | label=labels[0]) 54 | y = DTR[:, LTR == 1][i] 55 | plt.hist(y, bins=60, density=True, alpha=0.4, linewidth=1.0, color='blue', edgecolor='black', 56 | label=labels[1]) 57 | plt.legend() 58 | plt.savefig('./images/hist_' + title + '.svg') 59 | plt.show() 60 | 61 | 62 | def plot_PCA(DTR, LTR, m, appendToTitle=''): 63 | PCA(DTR, LTR, m, appendToTitle + 'PCA_m=' + str(m)) 64 | 65 | 66 | def plot_PCA_LDA(DTR, LTR, m, appendToTitle=''): 67 | P = PCA(DTR, LTR, m, filename=appendToTitle + 'PCA_m=' + str(m) + ' + LDA', LDA_flag=True) 68 | DTR = numpy.dot(P.T, -DTR) 69 | 70 | W = LDA(DTR, LTR, 1, m) 71 | DTR = numpy.dot(W.T, DTR) 72 | plot_histogram(DTR, LTR, ['male', 'female'], 'PCA_m=' + str(m) + ' + LDA') 73 | 74 | def plot_features(DTR, LTR, m=2, appendToTitle=''): 75 | plot_features_histograms(DTR, LTR, appendToTitle + "feature_") 76 | plot_correlations(DTR, "heatmap_" + appendToTitle) 77 | plot_correlations(DTR[:, LTR == 0], "heatmap_male_" + appendToTitle, cmap="Blues") 78 | plot_correlations(DTR[:, LTR == 1], "heatmap_female_" + appendToTitle, cmap="Reds") 79 | matplotlib.rcParams.update(matplotlib.rcParamsDefault) 80 | 81 | plot_PCA(DTR, LTR, m, appendToTitle) 82 | plot_PCA(DTR, LTR, m, appendToTitle) 83 | 84 | plot_PCA_LDA(DTR, LTR, m, appendToTitle) 85 | plot_PCA_LDA(DTR, LTR, m, appendToTitle) 86 | -------------------------------------------------------------------------------- /code/score_calibration/SVM_RBF_scores_calibration.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | 4 | import numpy as np 5 | 6 | sys.path.append('../') 7 | from validators import * 8 | 9 | 10 | def calibrate_scores(scores, labels): 11 | scores_70 = scores[:int(len(scores) * 0.7)] 12 | scores_30 = scores[int(len(scores) * 0.7):] 13 | labels_70 = labels[:int(len(labels) * 0.7)] 14 | labels_30 = labels[int(len(labels) * 0.7):] 15 | 16 | S, estimated_w, estimated_b = logistic_reg_calibration(numpy.array([scores_70]), labels_70, 17 | numpy.array([scores_30]), 1e-3) 18 | 19 | return numpy.array(S), labels_30, estimated_w, estimated_b 20 | 21 | def kfold_SVM_RBF(DTR, LTR, appendToTitle, C=1.0, K=1, gamma=1, PCA_Flag=False, gauss_Flag=False, zscore_Flag=False): 22 | k = 5 23 | Dtr = numpy.split(DTR, k, axis=1) 24 | Ltr = numpy.split(LTR, k) 25 | 26 | scores_append = [] 27 | PCA_SVM_scores_append = [] 28 | PCA2_SVM_scores_append = [] 29 | SVM_labels = [] 30 | 31 | for i in range(k): 32 | D = [] 33 | L = [] 34 | if i == 0: 35 | D.append(np.hstack(Dtr[i + 1:])) 36 | L.append(np.hstack(Ltr[i + 1:])) 37 | elif i == k - 1: 38 | D.append(np.hstack(Dtr[:i])) 39 | L.append(np.hstack(Ltr[:i])) 40 | else: 41 | D.append(np.hstack(Dtr[:i])) 42 | D.append(np.hstack(Dtr[i + 1:])) 43 | L.append(np.hstack(Ltr[:i])) 44 | L.append(np.hstack(Ltr[i + 1:])) 45 | 46 | D = np.hstack(D) 47 | L = np.hstack(L) 48 | 49 | Dte = Dtr[i] 50 | Lte = Ltr[i] 51 | 52 | if zscore_Flag is True: 53 | D, Dte = znorm(D, Dte) 54 | 55 | if gauss_Flag is True: 56 | D = gaussianize_features(D, D) 57 | Dte = gaussianize_features(D, Dte) 58 | 59 | print(i) 60 | 61 | Z = L * 2 - 1 62 | aStar, loss = train_SVM_RBF(D, L, C=C, K=K, gamma=gamma) 63 | kern = numpy.zeros((D.shape[1], Dte.shape[1])) 64 | for i in range(D.shape[1]): 65 | for j in range(Dte.shape[1]): 66 | kern[i, j] = numpy.exp(-gamma * (numpy.linalg.norm(D[:, i] - Dte[:, j]) ** 2)) + K * K 67 | scores = numpy.sum(numpy.dot(aStar * mrow(Z), kern), axis=0) 68 | 69 | scores_append.append(scores) 70 | 71 | SVM_labels = np.append(SVM_labels, Lte, axis=0) 72 | SVM_labels = np.hstack(SVM_labels) 73 | 74 | if PCA_Flag is True: 75 | # PCA m=10 76 | P = PCA(D, L, m=10) 77 | DTR_PCA = numpy.dot(P.T, D) 78 | DTE_PCA = numpy.dot(P.T, Dte) 79 | 80 | PCA_SVM_scores = 0 # todo 81 | PCA_SVM_scores_append.append(PCA_SVM_scores) 82 | 83 | # PCA m=9 84 | P = PCA(D, L, m=9) 85 | DTR_PCA = numpy.dot(P.T, D) 86 | DTE_PCA = numpy.dot(P.T, Dte) 87 | 88 | PCA2_SVM_scores = 0 # todo 89 | PCA2_SVM_scores_append.append(PCA2_SVM_scores) 90 | 91 | scores_append = np.hstack(scores_append) 92 | cal_scores, cal_labels, w, b = calibrate_scores(scores_append, SVM_labels) 93 | scores_append = scores_append.reshape((1, 6000)) 94 | final_score = numpy.dot(w.T, scores_append) + b 95 | 96 | # plot_ROC(scores_append, SVM_labels, appendToTitle + 'SVM, K=' + str(K) + ', C=' + str(C)) 97 | 98 | # Cfn and Ctp are set to 1 99 | bayes_error_min_act_plot(final_score, SVM_labels, appendToTitle + 'RAW_, K=' + str(K) + ', C=' + str(C), 0.4) 100 | 101 | 102 | def SVM_RBF_score_calibration(DTR, LTR, K_arr, gamma_arr, appendToTitle, PCA_Flag=False, gauss_Flag=False, zscore_Flag=False): 103 | for K in K_arr: 104 | for gamma in gamma_arr: 105 | kfold_SVM_RBF(DTR, LTR, appendToTitle, C=1.0, K=K, gamma=gamma, PCA_Flag=False, gauss_Flag=gauss_Flag, 106 | zscore_Flag=zscore_Flag) 107 | -------------------------------------------------------------------------------- /code/score_calibration/SVM_scores_calibration.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | 4 | import numpy as np 5 | 6 | sys.path.append('../') 7 | from validators import * 8 | 9 | 10 | def calibrate_scores(scores, labels): 11 | scores_70 = scores[:int(len(scores) * 0.7)] 12 | scores_30 = scores[int(len(scores) * 0.7):] 13 | labels_70 = labels[:int(len(labels) * 0.7)] 14 | labels_30 = labels[int(len(labels) * 0.7):] 15 | 16 | S, estimated_w, estimated_b = logistic_reg_calibration(numpy.array([scores_70]), labels_70, 17 | numpy.array([scores_30]), 1e-3) 18 | 19 | return numpy.array(S), labels_30, estimated_w, estimated_b 20 | 21 | 22 | def kfold_SVM(DTR, LTR, K, C, appendToTitle, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 23 | k = 5 24 | Dtr = numpy.split(DTR, k, axis=1) 25 | Ltr = numpy.split(LTR, k) 26 | 27 | scores_append = [] 28 | SVM_labels = [] 29 | 30 | for i in range(k): 31 | D = [] 32 | L = [] 33 | if i == 0: 34 | D.append(np.hstack(Dtr[i + 1:])) 35 | L.append(np.hstack(Ltr[i + 1:])) 36 | elif i == k - 1: 37 | D.append(np.hstack(Dtr[:i])) 38 | L.append(np.hstack(Ltr[:i])) 39 | else: 40 | D.append(np.hstack(Dtr[:i])) 41 | D.append(np.hstack(Dtr[i + 1:])) 42 | L.append(np.hstack(Ltr[:i])) 43 | L.append(np.hstack(Ltr[i + 1:])) 44 | 45 | D = np.hstack(D) 46 | L = np.hstack(L) 47 | 48 | Dte = Dtr[i] 49 | Lte = Ltr[i] 50 | if zscore_Flag is True: 51 | D, Dte = znorm(D, Dte) 52 | 53 | if gauss_Flag is True: 54 | Dte = gaussianize_features(D, Dte) 55 | D = gaussianize_features(D, D) 56 | 57 | print(i) 58 | wStar, primal = train_SVM_linear(D, L, C=C, K=K) 59 | 60 | DTEEXT = numpy.vstack([Dte, K * numpy.ones((1, Dte.shape[1]))]) 61 | 62 | scores = numpy.dot(wStar.T, DTEEXT).ravel() 63 | scores_append.append(scores) 64 | 65 | SVM_labels = np.append(SVM_labels, Lte, axis=0) 66 | SVM_labels = np.hstack(SVM_labels) 67 | 68 | scores_append = np.hstack(scores_append) 69 | cal_scores, cal_labels, w, b = calibrate_scores(scores_append, SVM_labels) 70 | scores_append = scores_append.reshape((1, 6000)) 71 | final_score = numpy.dot(w.T, scores_append) + b 72 | 73 | # plot_ROC(scores_append, SVM_labels, appendToTitle + 'SVM, K=' + str(K) + ', C=' + str(C)) 74 | 75 | # Cfn and Ctp are set to 1 76 | bayes_error_min_act_plot(final_score, SVM_labels, appendToTitle + 'RAW_, K=' + str(K) + ', C=' + str(C), 0.4) 77 | 78 | 79 | def SVM_score_calibration(DTR, LTR, K_arr, C_arr, appendToTitle, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 80 | for K in K_arr: 81 | for C in C_arr: 82 | kfold_SVM(DTR, LTR, K, C, appendToTitle, PCA_Flag, gauss_Flag, zscore_Flag) 83 | -------------------------------------------------------------------------------- /code/score_calibration/__pycache__/SVM_RBF_scores_calibration.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/score_calibration/__pycache__/SVM_RBF_scores_calibration.cpython-39.pyc -------------------------------------------------------------------------------- /code/score_calibration/__pycache__/SVM_scores_calibration.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/score_calibration/__pycache__/SVM_scores_calibration.cpython-39.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/compare_best_2.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/compare_best_2.cpython-39.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_GMM.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_GMM.cpython-310.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_GMM.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_GMM.cpython-39.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_LR.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_LR.cpython-310.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_LR.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_LR.cpython-39.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_MVG.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_MVG.cpython-310.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_MVG.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_MVG.cpython-39.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_SVM.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_SVM.cpython-310.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_SVM.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_SVM.cpython-39.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_SVM_RBF.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_SVM_RBF.cpython-39.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_SVM_RFB.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_SVM_RFB.cpython-310.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_SVM_RFB.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_SVM_RFB.cpython-39.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_SVM_polynomial.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_SVM_polynomial.cpython-310.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_SVM_polynomial.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_SVM_polynomial.cpython-39.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_compare.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_compare.cpython-39.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_quad_LR.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_quad_LR.cpython-310.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_quad_LR.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_quad_LR.cpython-39.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_weighted_LR.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_weighted_LR.cpython-310.pyc -------------------------------------------------------------------------------- /code/validation/__pycache__/validation_weighted_LR.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Peipi98/Gender_Detection/364c6aae258988e67e46ba9351f22a73ebf08079/code/validation/__pycache__/validation_weighted_LR.cpython-39.pyc -------------------------------------------------------------------------------- /code/validation/validation_LR.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | 4 | import numpy 5 | import numpy as np 6 | 7 | sys.path.append('../') 8 | from validators import * 9 | from prettytable import PrettyTable 10 | 11 | 12 | def validate_LR(scores, LR_labels, appendToTitle, l): 13 | scores_append = np.hstack(scores) 14 | scores_tot = compute_min_DCF(scores_append, LR_labels, 0.5, 1, 1) 15 | 16 | plot_ROC(scores_append, LR_labels, appendToTitle + 'LR, lambda=' + str(l)) 17 | 18 | # Cfn and Ctp are set to 1 19 | # bayes_error_min_act_plot(scores_append, LR_labels, appendToTitle + 'LR, lambda=' + str(l), 0.4) 20 | 21 | t = PrettyTable(["Type", "minDCF"]) 22 | t.title = appendToTitle + "minDCF: π=0.5" 23 | t.add_row(['LR, lambda=' + str(l), round(scores_tot, 3)]) 24 | print(t) 25 | 26 | ############################### 27 | 28 | # π = 0.1 29 | scores_tot = compute_min_DCF(scores_append, LR_labels, 0.1, 1, 1) 30 | 31 | t = PrettyTable(["Type", "minDCF"]) 32 | t.title = appendToTitle + "minDCF: π=0.1" 33 | t.add_row(['LR, lambda=' + str(l), round(scores_tot, 3)]) 34 | 35 | print(t) 36 | 37 | ############################### 38 | 39 | # π = 0.9 40 | scores_tot = compute_min_DCF(scores_append, LR_labels, 0.9, 1, 1) 41 | 42 | t = PrettyTable(["Type", "minDCF"]) 43 | t.title = appendToTitle + "minDCF: π=0.9" 44 | t.add_row(['LR, lambda=' + str(l), round(scores_tot, 3)]) 45 | 46 | print(t) 47 | 48 | 49 | def kfold_LR(DTR, LTR, l, appendToTitle, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 50 | k = 5 51 | Dtr = numpy.split(DTR, k, axis=1) 52 | Ltr = numpy.split(LTR, k) 53 | 54 | scores_append = [] 55 | PCA_LR_scores_append = [] 56 | PCA2_LR_scores_append = [] 57 | LR_labels = [] 58 | 59 | for i in range(k): 60 | D = [] 61 | L = [] 62 | if i == 0: 63 | D.append(np.hstack(Dtr[i + 1:])) 64 | L.append(np.hstack(Ltr[i + 1:])) 65 | elif i == k - 1: 66 | D.append(np.hstack(Dtr[:i])) 67 | L.append(np.hstack(Ltr[:i])) 68 | else: 69 | D.append(np.hstack(Dtr[:i])) 70 | D.append(np.hstack(Dtr[i + 1:])) 71 | L.append(np.hstack(Ltr[:i])) 72 | L.append(np.hstack(Ltr[i + 1:])) 73 | 74 | D = np.hstack(D) 75 | L = np.hstack(L) 76 | 77 | Dte = Dtr[i] 78 | Lte = Ltr[i] 79 | 80 | if zscore_Flag is True: 81 | D, Dte = znorm(D, Dte) 82 | 83 | if gauss_Flag is True: 84 | Dte = gaussianize_features(D, Dte) 85 | D = gaussianize_features(D, D) 86 | 87 | scores = logistic_reg_score(D, L, Dte, l) 88 | scores_append.append(scores) 89 | 90 | LR_labels = np.append(LR_labels, Lte, axis=0) 91 | LR_labels = np.hstack(LR_labels) 92 | 93 | if PCA_Flag is True: 94 | # PCA m=10 95 | P = PCA(D, L, m=10) 96 | DTR_PCA = numpy.dot(P.T, D) 97 | DTE_PCA = numpy.dot(P.T, Dte) 98 | 99 | PCA_LR_scores = logistic_reg_score(DTR_PCA, L, DTE_PCA, l) 100 | PCA_LR_scores_append.append(PCA_LR_scores) 101 | 102 | # PCA m=9 103 | P = PCA(D, L, m=9) 104 | DTR_PCA = numpy.dot(P.T, D) 105 | DTE_PCA = numpy.dot(P.T, Dte) 106 | 107 | PCA2_LR_scores = logistic_reg_score(DTR_PCA, L, DTE_PCA, l) 108 | PCA2_LR_scores_append.append(PCA2_LR_scores) 109 | 110 | validate_LR(scores_append, LR_labels, appendToTitle, l) 111 | 112 | if PCA_Flag is True: 113 | validate_LR(PCA_LR_scores_append, LR_labels, appendToTitle + 'PCA_m10_', l) 114 | 115 | validate_LR(PCA2_LR_scores_append, LR_labels, appendToTitle + 'PCA_m9_', l) 116 | 117 | 118 | def kfold_LR_calibration(DTR, LTR, l, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 119 | k = 5 120 | Dtr = numpy.split(DTR, k, axis=1) 121 | Ltr = numpy.split(LTR, k) 122 | 123 | scores_append = [] 124 | LR_labels = [] 125 | 126 | for i in range(k): 127 | D = [] 128 | L = [] 129 | if i == 0: 130 | D.append(np.hstack(Dtr[i + 1:])) 131 | L.append(np.hstack(Ltr[i + 1:])) 132 | elif i == k - 1: 133 | D.append(np.hstack(Dtr[:i])) 134 | L.append(np.hstack(Ltr[:i])) 135 | else: 136 | D.append(np.hstack(Dtr[:i])) 137 | D.append(np.hstack(Dtr[i + 1:])) 138 | L.append(np.hstack(Ltr[:i])) 139 | L.append(np.hstack(Ltr[i + 1:])) 140 | 141 | D = np.hstack(D) 142 | L = np.hstack(L) 143 | 144 | Dte = Dtr[i] 145 | Lte = Ltr[i] 146 | 147 | 148 | if zscore_Flag is True: 149 | D, Dte = znorm(D, Dte) 150 | 151 | if gauss_Flag is True: 152 | Dte = gaussianize_features(D, Dte) 153 | D = gaussianize_features(D, D) 154 | 155 | 156 | scores = logistic_reg_score(D, L, Dte, l) 157 | scores_append.append(scores) 158 | 159 | LR_labels = np.append(LR_labels, Lte, axis=0) 160 | LR_labels = np.hstack(LR_labels) 161 | 162 | return np.hstack(scores_append), LR_labels 163 | 164 | 165 | def validation_LR(DTR, LTR, L, appendToTitle, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 166 | for l in L: 167 | kfold_LR(DTR, LTR, l, appendToTitle, PCA_Flag, gauss_Flag, zscore_Flag) 168 | 169 | x = numpy.logspace(-5, 1, 30) 170 | y = numpy.array([]) 171 | y_05 = numpy.array([]) 172 | y_09 = numpy.array([]) 173 | y_01 = numpy.array([]) 174 | for xi in x: 175 | scores, labels = kfold_LR_calibration(DTR, LTR, xi, PCA_Flag, gauss_Flag, zscore_Flag) 176 | y_05 = numpy.hstack((y_05, bayes_error_plot_compare(0.5, scores, labels))) 177 | y_09 = numpy.hstack((y_09, bayes_error_plot_compare(0.9, scores, labels))) 178 | y_01 = numpy.hstack((y_01, bayes_error_plot_compare(0.1, scores, labels))) 179 | 180 | y = numpy.hstack((y, y_05)) 181 | y = numpy.vstack((y, y_09)) 182 | y = numpy.vstack((y, y_01)) 183 | 184 | plot_DCF(x, y, 'lambda', appendToTitle + 'LR_minDCF_comparison') 185 | -------------------------------------------------------------------------------- /code/validation/validation_MVG.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | import numpy as np 4 | 5 | sys.path.append('../') 6 | from mlFunc import * 7 | from validators import * 8 | from classifiers import * 9 | from classifiers import * 10 | from validators import * 11 | from prettytable import PrettyTable 12 | from plot_features import plot_features 13 | 14 | def compute_MVG_score(Dte, D, L, MVG_res, MVG_naive, MVG_t, MVG_nt, MVG_labels): 15 | _, _, llrs = MVG(Dte, D, L) 16 | _, _, llrsn = naive_MVG(Dte, D, L) 17 | _, _, llrst = tied_cov_GC(Dte, D, L) 18 | _, _, llrsnt = tied_cov_naive_GC(Dte, D, L) 19 | 20 | MVG_res.append(llrs) 21 | MVG_naive.append(llrsn) 22 | MVG_t.append(llrst) 23 | MVG_nt.append(llrsnt) 24 | # MVG_labels.append(Lte) 25 | # MVG_labels = np.append(MVG_labels, Lte, axis=0) 26 | # MVG_labels = np.hstack(MVG_labels) 27 | return MVG_res, MVG_naive, MVG_t, MVG_nt 28 | 29 | 30 | def evaluation(title, pi, MVG_res, MVG_naive, MVG_t, MVG_nt, MVG_labels, appendToTitle): 31 | MVG_res = np.hstack(MVG_res) 32 | MVG_naive = np.hstack(MVG_naive) 33 | MVG_t = np.hstack(MVG_t) 34 | MVG_nt = np.hstack(MVG_nt) 35 | 36 | llrs_tot = compute_min_DCF(MVG_res, MVG_labels, pi, 1, 1) 37 | llrsn_tot = compute_min_DCF(MVG_naive, MVG_labels, pi, 1, 1) 38 | llrst_tot = compute_min_DCF(MVG_t, MVG_labels, pi, 1, 1) 39 | llrsnt_tot = compute_min_DCF(MVG_nt, MVG_labels, pi, 1, 1) 40 | 41 | # plot_ROC(MVG_res, MVG_labels, appendToTitle + 'MVG') 42 | # plot_ROC(MVG_naive, MVG_labels, appendToTitle + 'MVG + Naive') 43 | # plot_ROC(MVG_t, MVG_labels, appendToTitle + 'MVG + Tied') 44 | # plot_ROC(MVG_nt, MVG_labels, appendToTitle + 'MVG + Naive + Tied') 45 | 46 | # # Cfn and Ctp are set to 1 47 | # bayes_error_min_act_plot(MVG_res, MVG_labels, appendToTitle + 'MVG', 0.4) 48 | # bayes_error_min_act_plot(MVG_naive, MVG_labels, appendToTitle + 'MVG + Naive', 1) 49 | # bayes_error_min_act_plot(MVG_t, MVG_labels, appendToTitle + 'MVG + Tied', 0.4) 50 | # bayes_error_min_act_plot(MVG_nt, MVG_labels, appendToTitle + 'MVG + Naive + Tied', 1) 51 | 52 | t = PrettyTable(["Type", "minDCF"]) 53 | t.title = title 54 | t.add_row(["MVG", round(llrs_tot, 3)]) 55 | t.add_row(["MVG naive", round(llrsn_tot, 3)]) 56 | t.add_row(["MVG tied", round(llrst_tot, 3)]) 57 | t.add_row(["MVG naive + tied", round(llrsnt_tot, 3)]) 58 | print(t) 59 | 60 | 61 | def validation_MVG(DTR, LTR, appendToTitle, PCA_Flag=True, Gauss_flag = False, zscore=False): 62 | k = 5 63 | Dtr = numpy.split(DTR, k, axis=1) 64 | Ltr = numpy.split(LTR, k) 65 | 66 | MVG_res = [] 67 | MVG_naive = [] 68 | MVG_t = [] 69 | MVG_nt = [] 70 | MVG_labels = [] 71 | 72 | PCA_mvg = [] 73 | PCA_mvg_naive = [] 74 | PCA_mvg_t = [] 75 | PCA_mvg_nt = [] 76 | 77 | PCA2_mvg = [] 78 | PCA2_mvg_naive = [] 79 | PCA2_mvg_t = [] 80 | PCA2_mvg_nt = [] 81 | 82 | for i in range(k): 83 | D = [] 84 | L = [] 85 | if i == 0: 86 | D.append(np.hstack(Dtr[i + 1:])) 87 | L.append(np.hstack(Ltr[i + 1:])) 88 | elif i == k - 1: 89 | D.append(np.hstack(Dtr[:i])) 90 | L.append(np.hstack(Ltr[:i])) 91 | else: 92 | D.append(np.hstack(Dtr[:i])) 93 | D.append(np.hstack(Dtr[i + 1:])) 94 | L.append(np.hstack(Ltr[:i])) 95 | L.append(np.hstack(Ltr[i + 1:])) 96 | 97 | D = np.hstack(D) 98 | L = np.hstack(L) 99 | 100 | Dte = Dtr[i] 101 | Lte = Ltr[i] 102 | 103 | if (zscore): 104 | D, Dte = znorm(D, Dte) 105 | 106 | if (Gauss_flag): 107 | D_training = D 108 | D = gaussianize_features(D, D) 109 | Dte = gaussianize_features(D_training, Dte) 110 | 111 | MVG_labels = np.append(MVG_labels, Lte, axis=0) 112 | MVG_labels = np.hstack(MVG_labels) 113 | # Once we have computed our folds, we can try different models 114 | # RAW DATA 115 | 116 | MVG_res, MVG_naive, MVG_t, MVG_nt = compute_MVG_score( 117 | Dte, 118 | D, 119 | L, 120 | MVG_res, 121 | MVG_naive, 122 | MVG_t, 123 | MVG_nt, 124 | MVG_labels) 125 | 126 | if PCA_Flag is True: 127 | # PCA m=10 128 | P = PCA(D, L, m=10) 129 | DTR_PCA = numpy.dot(P.T, D) 130 | DTE_PCA = numpy.dot(P.T, Dte) 131 | 132 | PCA_mvg, PCA_mvg_naive, PCA_mvg_t, PCA_mvg_nt = compute_MVG_score( 133 | DTE_PCA, 134 | DTR_PCA, 135 | L, 136 | PCA_mvg, 137 | PCA_mvg_naive, 138 | PCA_mvg_t, 139 | PCA_mvg_nt, 140 | MVG_labels) 141 | 142 | # PCA m=9 143 | P = PCA(D, L, m=9) 144 | DTR_PCA = numpy.dot(P.T, D) 145 | DTE_PCA = numpy.dot(P.T, Dte) 146 | 147 | PCA2_mvg, PCA2_mvg_naive, PCA_2mvg_t, PCA2_mvg_nt = compute_MVG_score( 148 | DTE_PCA, 149 | DTR_PCA, 150 | L, 151 | PCA2_mvg, 152 | PCA2_mvg_naive, 153 | PCA2_mvg_t, 154 | PCA2_mvg_nt, 155 | MVG_labels) 156 | 157 | # π = 0.5 (our application prior) 158 | evaluation("minDCF: π=0.5", 0.5, MVG_res, MVG_naive, MVG_t, MVG_nt, MVG_labels, appendToTitle + 'minDCF_π=0.5__') 159 | 160 | ############################### 161 | 162 | # π = 0.1 163 | evaluation("minDCF: π=0.1", 0.1, MVG_res, MVG_naive, MVG_t, MVG_nt, MVG_labels, appendToTitle + 'minDCF_π=0.1__') 164 | 165 | ############################### 166 | 167 | # π = 0.9 168 | evaluation("minDCF: π=0.9", 0.9, MVG_res, MVG_naive, MVG_t, MVG_nt, MVG_labels, appendToTitle + "minDCF_π=0.9__") 169 | 170 | if PCA_Flag is True: 171 | # PCA m=10 172 | # π = 0.5 (our application prior) 173 | evaluation("minDCF: π=0.5 | PCA m=10", 0.5, PCA_mvg, 174 | PCA_mvg_naive, 175 | PCA_mvg_t, 176 | PCA_mvg_nt, 177 | MVG_labels, appendToTitle + "minDCF_π=0.5_PCA m=10__") 178 | 179 | ############################### 180 | 181 | # π = 0.1 182 | evaluation("minDCF: π=0.1 | PCA m=10", 0.1, PCA_mvg, 183 | PCA_mvg_naive, 184 | PCA_mvg_t, 185 | PCA_mvg_nt, 186 | MVG_labels, appendToTitle + "minDCF_π=0.1_PCA m=10__") 187 | 188 | ############################### 189 | 190 | # π = 0.9 191 | evaluation("minDCF: π=0.9 | PCA m=10", 0.9, PCA_mvg, 192 | PCA_mvg_naive, 193 | PCA_mvg_t, 194 | PCA_mvg_nt, 195 | MVG_labels, appendToTitle + "minDCF_π=0.9_PCA m=10__") 196 | 197 | # PCA m=9 198 | # π = 0.5 (our application prior) 199 | evaluation("minDCF: π=0.5 | PCA m=9", 0.5, PCA2_mvg, 200 | PCA2_mvg_naive, 201 | PCA2_mvg_t, 202 | PCA2_mvg_nt, 203 | MVG_labels, appendToTitle + "minDCF_π=0.5_PCA m=9__") 204 | 205 | ############################### 206 | 207 | # π = 0.1 208 | evaluation("minDCF: π=0.1 | PCA m=9", 0.1, PCA2_mvg, 209 | PCA2_mvg_naive, 210 | PCA2_mvg_t, 211 | PCA2_mvg_nt, 212 | MVG_labels, appendToTitle + "minDCF_π=0.1_PCA m=9__") 213 | 214 | ############################### 215 | 216 | # π = 0.9 217 | evaluation("minDCF: π=0.9 | PCA m=9", 0.9, PCA2_mvg, 218 | PCA2_mvg_naive, 219 | PCA2_mvg_t, 220 | PCA2_mvg_nt, 221 | MVG_labels, appendToTitle + "minDCF_π=0.9_PCA m=9__") 222 | 223 | -------------------------------------------------------------------------------- /code/validation/validation_SVM.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | 4 | import numpy as np 5 | 6 | sys.path.append('../') 7 | from validators import * 8 | from prettytable import PrettyTable 9 | 10 | 11 | def kfold_SVM(DTR, LTR, K, C, appendToTitle, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 12 | k = 5 13 | Dtr = numpy.split(DTR, k, axis=1) 14 | Ltr = numpy.split(LTR, k) 15 | 16 | scores_append = [] 17 | PCA_SVM_scores_append = [] 18 | PCA2_SVM_scores_append = [] 19 | SVM_labels = [] 20 | 21 | for i in range(k): 22 | D = [] 23 | L = [] 24 | if i == 0: 25 | D.append(np.hstack(Dtr[i + 1:])) 26 | L.append(np.hstack(Ltr[i + 1:])) 27 | elif i == k - 1: 28 | D.append(np.hstack(Dtr[:i])) 29 | L.append(np.hstack(Ltr[:i])) 30 | else: 31 | D.append(np.hstack(Dtr[:i])) 32 | D.append(np.hstack(Dtr[i + 1:])) 33 | L.append(np.hstack(Ltr[:i])) 34 | L.append(np.hstack(Ltr[i + 1:])) 35 | 36 | D = np.hstack(D) 37 | L = np.hstack(L) 38 | 39 | Dte = Dtr[i] 40 | Lte = Ltr[i] 41 | 42 | if zscore_Flag is True: 43 | D, Dte = znorm(D, Dte) 44 | 45 | if gauss_Flag is True: 46 | Dte = gaussianize_features(D, Dte) 47 | D = gaussianize_features(D, D) 48 | 49 | print(i) 50 | wStar, primal = train_SVM_linear(D, L, C=C, K=K) 51 | DTEEXT = numpy.vstack([Dte, K * numpy.ones((1, Dte.shape[1]))]) 52 | 53 | scores = numpy.dot(wStar.T, DTEEXT).ravel() 54 | scores_append.append(scores) 55 | 56 | SVM_labels = np.append(SVM_labels, Lte, axis=0) 57 | SVM_labels = np.hstack(SVM_labels) 58 | 59 | if PCA_Flag is True: 60 | # PCA m=10 61 | P = PCA(D, L, m=10) 62 | DTR_PCA = numpy.dot(P.T, D) 63 | DTE_PCA = numpy.dot(P.T, Dte) 64 | 65 | wStar, primal = train_SVM_linear(DTR_PCA, L, C=C, K=K) 66 | DTEEXT = numpy.vstack([DTE_PCA, K * numpy.ones((1, Dte.shape[1]))]) 67 | PCA_SVM_scores = numpy.dot(wStar.T, DTEEXT).ravel() 68 | PCA_SVM_scores_append.append(PCA_SVM_scores) 69 | 70 | # PCA m=9 71 | P = PCA(D, L, m=9) 72 | DTR_PCA = numpy.dot(P.T, D) 73 | DTE_PCA = numpy.dot(P.T, Dte) 74 | 75 | wStar, primal = train_SVM_linear(DTR_PCA, L, C=C, K=K) 76 | DTEEXT = numpy.vstack([DTE_PCA, K * numpy.ones((1, Dte.shape[1]))]) 77 | PCA2_SVM_scores = numpy.dot(wStar.T, DTEEXT).ravel() 78 | PCA2_SVM_scores_append.append(PCA2_SVM_scores) 79 | 80 | 81 | scores_append = np.hstack(scores_append) 82 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.5, 1, 1) 83 | 84 | # plot_ROC(scores_append, SVM_labels, appendToTitle + 'SVM, K=' + str(K) + ', C=' + str(C)) 85 | 86 | # Cfn and Ctp are set to 1 87 | #bayes_error_min_act_plot(scores_append, SVM_labels, appendToTitle + 'SVM, K=' + str(K) + ', C=' + str(C), 0.4) 88 | 89 | t = PrettyTable(["Type", "minDCF"]) 90 | t.title = "minDCF: π=0.5" 91 | t.add_row(['SVM, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 92 | print(t) 93 | 94 | ############################### 95 | 96 | # π = 0.1 97 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.1, 1, 1) 98 | 99 | t = PrettyTable(["Type", "minDCF"]) 100 | t.title = "minDCF: π=0.1" 101 | t.add_row(['SVM, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 102 | 103 | print(t) 104 | 105 | ############################### 106 | 107 | # π = 0.9 108 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.9, 1, 1) 109 | 110 | t = PrettyTable(["Type", "minDCF"]) 111 | t.title = "minDCF: π=0.9" 112 | t.add_row(['SVM, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 113 | 114 | print(t) 115 | 116 | def kfold_SVM_calibration(DTR, LTR, K, C, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 117 | k = 5 118 | Dtr = numpy.split(DTR, k, axis=1) 119 | Ltr = numpy.split(LTR, k) 120 | 121 | scores_append = [] 122 | LR_labels = [] 123 | 124 | for i in range(k): 125 | D = [] 126 | L = [] 127 | if i == 0: 128 | D.append(np.hstack(Dtr[i + 1:])) 129 | L.append(np.hstack(Ltr[i + 1:])) 130 | elif i == k - 1: 131 | D.append(np.hstack(Dtr[:i])) 132 | L.append(np.hstack(Ltr[:i])) 133 | else: 134 | D.append(np.hstack(Dtr[:i])) 135 | D.append(np.hstack(Dtr[i + 1:])) 136 | L.append(np.hstack(Ltr[:i])) 137 | L.append(np.hstack(Ltr[i + 1:])) 138 | 139 | D = np.hstack(D) 140 | L = np.hstack(L) 141 | 142 | Dte = Dtr[i] 143 | Lte = Ltr[i] 144 | 145 | if zscore_Flag is True: 146 | D, Dte = znorm(D, Dte) 147 | 148 | if gauss_Flag is True: 149 | Dte = gaussianize_features(D, Dte) 150 | D = gaussianize_features(D, D) 151 | 152 | print(i) 153 | wStar, primal = train_SVM_linear(D, L, C=C, K=K) 154 | DTEEXT = numpy.vstack([Dte, K * numpy.ones((1, Dte.shape[1]))]) 155 | 156 | scores = numpy.dot(wStar.T, DTEEXT).ravel() 157 | scores_append.append(scores) 158 | 159 | LR_labels = np.append(LR_labels, Lte, axis=0) 160 | LR_labels = np.hstack(LR_labels) 161 | 162 | return np.hstack(scores_append), LR_labels 163 | 164 | def validation_SVM(DTR, LTR, K_arr, C_arr, appendToTitle, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 165 | for K in K_arr: 166 | for C in C_arr: 167 | kfold_SVM(DTR, LTR, K, C, appendToTitle, PCA_Flag, gauss_Flag, zscore_Flag) 168 | 169 | x = numpy.logspace(-3, 2, 12) 170 | y = numpy.array([]) 171 | y_05 = numpy.array([]) 172 | y_09 = numpy.array([]) 173 | y_01 = numpy.array([]) 174 | for xi in x: 175 | scores, labels = kfold_SVM_calibration(DTR, LTR, 1.0, xi, PCA_Flag, gauss_Flag, zscore_Flag) 176 | y_05 = numpy.hstack((y_05, bayes_error_plot_compare(0.5, scores, labels))) 177 | y_09 = numpy.hstack((y_09, bayes_error_plot_compare(0.9, scores, labels))) 178 | y_01 = numpy.hstack((y_01, bayes_error_plot_compare(0.1, scores, labels))) 179 | 180 | y = numpy.hstack((y, y_05)) 181 | y = numpy.vstack((y, y_09)) 182 | y = numpy.vstack((y, y_01)) 183 | 184 | plot_DCF(x, y, 'C', appendToTitle + 'SVM_minDCF_comparison') 185 | -------------------------------------------------------------------------------- /code/validation/validation_SVM_polynomial.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | import numpy as np 4 | 5 | sys.path.append('../') 6 | from validators import * 7 | from prettytable import PrettyTable 8 | 9 | 10 | def kfold_SVM_polynomial(DTR, LTR, K, costant, appendToTitle, C=1.0, degree=2, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 11 | k = 5 12 | Dtr = numpy.split(DTR, k, axis=1) 13 | Ltr = numpy.split(LTR, k) 14 | 15 | scores_append = [] 16 | PCA_SVM_scores_append = [] 17 | PCA2_SVM_scores_append = [] 18 | SVM_labels = [] 19 | 20 | for i in range(k): 21 | D = [] 22 | L = [] 23 | if i == 0: 24 | D.append(np.hstack(Dtr[i + 1:])) 25 | L.append(np.hstack(Ltr[i + 1:])) 26 | elif i == k - 1: 27 | D.append(np.hstack(Dtr[:i])) 28 | L.append(np.hstack(Ltr[:i])) 29 | else: 30 | D.append(np.hstack(Dtr[:i])) 31 | D.append(np.hstack(Dtr[i + 1:])) 32 | L.append(np.hstack(Ltr[:i])) 33 | L.append(np.hstack(Ltr[i + 1:])) 34 | 35 | D = np.hstack(D) 36 | L = np.hstack(L) 37 | Dte = Dtr[i] 38 | Lte = Ltr[i] 39 | 40 | if zscore_Flag is True: 41 | D, Dte = znorm(D, Dte) 42 | 43 | if gauss_Flag is True: 44 | Dte = gaussianize_features(D, Dte) 45 | D = gaussianize_features(D, D) 46 | 47 | print(i) 48 | 49 | aStar, loss = train_SVM_polynomial(D, L, C=C, constant=costant, degree=degree, K=K) 50 | Z = numpy.zeros(L.shape) 51 | Z[L == 1] = 1 52 | Z[L == 0] = -1 53 | kernel = (numpy.dot(D.T, Dte) + costant) ** degree + K * K 54 | scores = numpy.sum(numpy.dot(aStar * mrow(Z), kernel), axis=0) 55 | scores_append.append(scores) 56 | 57 | SVM_labels = np.append(SVM_labels, Lte, axis=0) 58 | SVM_labels = np.hstack(SVM_labels) 59 | 60 | if PCA_Flag is True: 61 | # PCA m=10 62 | P = PCA(D, L, m=10) 63 | DTR_PCA = numpy.dot(P.T, D) 64 | DTE_PCA = numpy.dot(P.T, Dte) 65 | 66 | PCA_SVM_scores = 0 # todo 67 | PCA_SVM_scores_append.append(PCA_SVM_scores) 68 | 69 | # PCA m=9 70 | P = PCA(D, L, m=9) 71 | DTR_PCA = numpy.dot(P.T, D) 72 | DTE_PCA = numpy.dot(P.T, Dte) 73 | 74 | PCA2_SVM_scores = 0 # todo 75 | PCA2_SVM_scores_append.append(PCA2_SVM_scores) 76 | 77 | scores_append = np.hstack(scores_append) 78 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.5, 1, 1) 79 | 80 | # plot_ROC(scores_append, SVM_labels, appendToTitle + 'SVM, K=' + str(K) + ', C=' + str(C)) 81 | 82 | # Cfn and Ctp are set to 1 83 | # bayes_error_min_act_plot(scores_append, SVM_labels, appendToTitle + 'SVM_POLY, K=' + str(K) + ', C=' + str(C), 0.4) 84 | 85 | t = PrettyTable(["Type", "minDCF"]) 86 | t.title = "minDCF: π=0.5" 87 | t.add_row(['SVM_POLY, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 88 | print(t) 89 | 90 | ############################### 91 | 92 | # π = 0.1 93 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.1, 1, 1) 94 | 95 | t = PrettyTable(["Type", "minDCF"]) 96 | t.title = "minDCF: π=0.1" 97 | t.add_row(['SVM_POLY, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 98 | 99 | print(t) 100 | 101 | ############################### 102 | 103 | # π = 0.9 104 | scores_tot = compute_min_DCF(scores_append, SVM_labels, 0.9, 1, 1) 105 | 106 | t = PrettyTable(["Type", "minDCF"]) 107 | t.title = "minDCF: π=0.9" 108 | t.add_row(['SVM_POLY, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 109 | 110 | print(t) 111 | 112 | 113 | def single_F_POLY(D, L, C, K, costant=1.0, degree=2): 114 | nTrain = int(D.shape[1] * 0.8) 115 | numpy.random.seed(0) 116 | idx = numpy.random.permutation(D.shape[1]) 117 | idxTrain = idx[0:nTrain] 118 | idxTest = idx[nTrain:] 119 | DTR = D[:, idxTrain] 120 | DTE = D[:, idxTest] 121 | LTR = L[idxTrain] 122 | LTE = L[idxTest] 123 | Z = numpy.zeros(LTR.shape) 124 | Z[LTR == 1] = 1 125 | Z[LTR == 0] = -1 126 | 127 | aStar, loss = train_SVM_polynomial(DTR, LTR, C=1.0, constant=costant, degree=degree, K=K) 128 | kernel = (numpy.dot(DTR.T, DTE) + costant) ** degree + K * K 129 | score = numpy.sum(numpy.dot(aStar * mrow(Z), kernel), axis=0) 130 | 131 | errorRate = (1 - numpy.sum((score > 0) == LTE) / len(LTE)) * 100 132 | print("K = %d, costant = %d, loss = %e, error = %.1f" % (K, costant, loss, errorRate)) 133 | 134 | scores_append = numpy.hstack(score) 135 | scores_tot = compute_min_DCF(scores_append, LTE, 0.5, 1, 1) 136 | t = PrettyTable(["Type", "minDCF"]) 137 | t.title = "minDCF: π=0.5" 138 | t.add_row(['SVM, K=' + str(K) + ', C=' + str(C), round(scores_tot, 3)]) 139 | print(t) 140 | 141 | 142 | def validation_SVM_polynomial(DTR, LTR, K_arr, C, appendToTitle, CON_array, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 143 | for costant in CON_array: 144 | for degree in [2]: 145 | for K in K_arr: 146 | kfold_SVM_polynomial(DTR, LTR, K, costant, appendToTitle, C=C, degree=degree, PCA_Flag=PCA_Flag, gauss_Flag=gauss_Flag, zscore_Flag=zscore_Flag) -------------------------------------------------------------------------------- /code/validation/validation_compare.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | 4 | import numpy 5 | import numpy as np 6 | 7 | from evaluators.compare_best_2 import bayes_error_plot_2best, ROC_2best 8 | from evaluators.evaluation_GMM import evaluation_GMM_ncomp, evaluation_scores_GMM_ncomp 9 | 10 | sys.path.append('../') 11 | from validators import * 12 | 13 | def calibrate_scores(scores, labels): 14 | scores_70 = scores[:int(len(scores) * 0.7)] 15 | scores_30 = scores[int(len(scores) * 0.7):] 16 | labels_70 = labels[:int(len(labels) * 0.7)] 17 | labels_30 = labels[int(len(labels) * 0.7):] 18 | 19 | S, estimated_w, estimated_b = logistic_reg_calibration(numpy.array([scores_70]), labels_70, 20 | numpy.array([scores_30]), 1e-3) 21 | 22 | return numpy.array(S), labels_30, estimated_w, estimated_b 23 | 24 | def compare(scores, scores2, LTE): 25 | scores = np.hstack(scores) 26 | scores2 = np.hstack(scores2) 27 | 28 | 29 | bayes_error_plot_2best([scores, scores2], LTE, 0.5, '', 0.4) 30 | ROC_2best([scores, scores2], LTE, 0.5, '') 31 | 32 | 33 | 34 | def kfold_validation_compare(DTR, LTR, l=None): 35 | k = 5 36 | Dtr = numpy.split(DTR, k, axis=1) 37 | Ltr = numpy.split(LTR, k) 38 | 39 | scores_append = [] 40 | scores2_append = [] 41 | LR_labels = [] 42 | 43 | for i in range(k): 44 | D = [] 45 | L = [] 46 | if i == 0: 47 | D.append(np.hstack(Dtr[i + 1:])) 48 | L.append(np.hstack(Ltr[i + 1:])) 49 | elif i == k - 1: 50 | D.append(np.hstack(Dtr[:i])) 51 | L.append(np.hstack(Ltr[:i])) 52 | else: 53 | D.append(np.hstack(Dtr[:i])) 54 | D.append(np.hstack(Dtr[i + 1:])) 55 | L.append(np.hstack(Ltr[:i])) 56 | L.append(np.hstack(Ltr[i + 1:])) 57 | 58 | D = np.hstack(D) 59 | L = np.hstack(L) 60 | 61 | Dte = Dtr[i] 62 | Lte = Ltr[i] 63 | 64 | if l is not None: 65 | # GMM_llrst_raw = evaluation_scores_GMM_ncomp('', D, L, Dte, Lte, 0.5, 2) 66 | # scores_append.append(GMM_llrst_raw) 67 | Z = L * 2 - 1 68 | C = 1.0 69 | K = 1.0 70 | aStar, loss = train_SVM_RBF(D, L, C=C, K=K, gamma=0.001) 71 | kern = numpy.zeros((D.shape[1], Dte.shape[1])) 72 | for i in range(D.shape[1]): 73 | for j in range(Dte.shape[1]): 74 | kern[i, j] = numpy.exp(-0.001 * (numpy.linalg.norm(D[:, i] - Dte[:, j]) ** 2)) + K * K 75 | scores = numpy.sum(numpy.dot(aStar * mrow(Z), kern), axis=0) 76 | 77 | scores_append.append(scores) 78 | 79 | 80 | 81 | #GMM_llrst_raw = evaluation_scores_GMM_ncomp('', D, L, Dte, Lte, 0.5, 2) 82 | _, _, llrs_tied = tied_cov_GC(Dte, D, L) 83 | scores2_append.append(llrs_tied) 84 | 85 | LR_labels = np.append(LR_labels, Lte, axis=0) 86 | LR_labels = np.hstack(LR_labels) 87 | 88 | scores_append = np.hstack(scores_append) 89 | cal_scores, cal_labels, w, b = calibrate_scores(scores_append, LR_labels) 90 | scores_append = scores_append.reshape((1, 6000)) 91 | final_score = numpy.dot(w.T, scores_append) + b 92 | compare(final_score, scores2_append, LR_labels) 93 | 94 | 95 | def compare_2_validation(DTR, LTR, L): 96 | for l in L: 97 | kfold_validation_compare(DTR, LTR, l) 98 | -------------------------------------------------------------------------------- /code/validation/validation_quad_LR.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | 4 | import numpy as np 5 | 6 | sys.path.append('../') 7 | from validators import * 8 | from prettytable import PrettyTable 9 | 10 | 11 | def validate_LR(scores, LR_labels, appendToTitle, l, pi): 12 | scores_append = np.hstack(scores) 13 | scores_tot_05 = compute_min_DCF(scores_append, LR_labels, 0.5, 1, 1) 14 | scores_tot_01 = compute_min_DCF(scores_append, LR_labels, 0.1, 1, 1) 15 | scores_tot_09 = compute_min_DCF(scores_append, LR_labels, 0.9, 1, 1) 16 | # plot_ROC(scores_append, LR_labels, appendToTitle + 'WEIGHTED_LR, lambda=' + str(l)) 17 | 18 | # Cfn and Ctp are set to 1 19 | # bayes_error_min_act_plot(scores_append, LR_labels, appendToTitle + 'WEIGHTED_LR, lambda=' + str(l), 0.4) 20 | 21 | t = PrettyTable(["Type", "π=0.5", "π=0.1", "π=0.9"]) 22 | t.title = appendToTitle 23 | t.add_row(['QUAD_LR, lambda=' + str(l) + " π_t=" + str(pi), round(scores_tot_05, 3), round(scores_tot_01, 3), round(scores_tot_09, 3)]) 24 | print(t) 25 | 26 | 27 | def kfold_QUAD_LR(DTR, LTR, l, pi, appendToTitle, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 28 | k = 5 29 | Dtr = numpy.split(DTR, k, axis=1) 30 | Ltr = numpy.split(LTR, k) 31 | 32 | scores_append = [] 33 | PCA_LR_scores_append = [] 34 | PCA2_LR_scores_append = [] 35 | LR_labels = [] 36 | 37 | for i in range(k): 38 | D = [] 39 | L = [] 40 | if i == 0: 41 | D.append(np.hstack(Dtr[i + 1:])) 42 | L.append(np.hstack(Ltr[i + 1:])) 43 | elif i == k - 1: 44 | D.append(np.hstack(Dtr[:i])) 45 | L.append(np.hstack(Ltr[:i])) 46 | else: 47 | D.append(np.hstack(Dtr[:i])) 48 | D.append(np.hstack(Dtr[i + 1:])) 49 | L.append(np.hstack(Ltr[:i])) 50 | L.append(np.hstack(Ltr[i + 1:])) 51 | 52 | def vecxxT(x): 53 | x = x[:, None] 54 | xxT = x.dot(x.T).reshape(x.size ** 2, order='F') 55 | return xxT 56 | 57 | D = np.hstack(D) 58 | L = np.hstack(L) 59 | 60 | Dte = Dtr[i] 61 | Lte = Ltr[i] 62 | 63 | if zscore_Flag is True: 64 | D, Dte = znorm(D, Dte) 65 | 66 | if gauss_Flag is True: 67 | Dte = gaussianize_features(D, Dte) 68 | D = gaussianize_features(D, D) 69 | 70 | expanded_DTR = numpy.apply_along_axis(vecxxT, 0, D) 71 | expanded_DTE = numpy.apply_along_axis(vecxxT, 0, Dte) 72 | phi = numpy.vstack([expanded_DTR, D]) 73 | 74 | phi_DTE = numpy.vstack([expanded_DTE, Dte]) 75 | 76 | scores = quad_logistic_reg_score(phi, L, phi_DTE, l, pi) 77 | scores_append.append(scores) 78 | 79 | LR_labels = np.append(LR_labels, Lte, axis=0) 80 | LR_labels = np.hstack(LR_labels) 81 | 82 | if PCA_Flag is True: 83 | # PCA m=10 84 | P = PCA(D, L, m=10) 85 | DTR_PCA = numpy.dot(P.T, D) 86 | DTE_PCA = numpy.dot(P.T, Dte) 87 | 88 | PCA_LR_scores = quad_logistic_reg_score(DTR_PCA, L, DTE_PCA, l, pi) 89 | PCA_LR_scores_append.append(PCA_LR_scores) 90 | 91 | # PCA m=9 92 | P = PCA(D, L, m=9) 93 | DTR_PCA = numpy.dot(P.T, D) 94 | DTE_PCA = numpy.dot(P.T, Dte) 95 | 96 | PCA2_LR_scores = quad_logistic_reg_score(DTR_PCA, L, DTE_PCA, l) 97 | PCA2_LR_scores_append.append(PCA2_LR_scores) 98 | 99 | validate_LR(scores_append, LR_labels, appendToTitle, l, pi) 100 | 101 | if PCA_Flag is True: 102 | validate_LR(PCA_LR_scores_append, LR_labels, appendToTitle + 'PCA_m10_', l, pi) 103 | 104 | validate_LR(PCA2_LR_scores_append, LR_labels, appendToTitle + 'PCA_m9_', l, pi) 105 | 106 | 107 | def kfold_QUAD_LR_tuning(DTR, LTR, l, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 108 | k = 5 109 | Dtr = numpy.split(DTR, k, axis=1) 110 | Ltr = numpy.split(LTR, k) 111 | 112 | scores_append = [] 113 | LR_labels = [] 114 | 115 | for i in range(k): 116 | D = [] 117 | L = [] 118 | if i == 0: 119 | D.append(np.hstack(Dtr[i + 1:])) 120 | L.append(np.hstack(Ltr[i + 1:])) 121 | elif i == k - 1: 122 | D.append(np.hstack(Dtr[:i])) 123 | L.append(np.hstack(Ltr[:i])) 124 | else: 125 | D.append(np.hstack(Dtr[:i])) 126 | D.append(np.hstack(Dtr[i + 1:])) 127 | L.append(np.hstack(Ltr[:i])) 128 | L.append(np.hstack(Ltr[i + 1:])) 129 | 130 | def vecxxT(x): 131 | x = x[:, None] 132 | xxT = x.dot(x.T).reshape(x.size ** 2, order='F') 133 | return xxT 134 | 135 | D = np.hstack(D) 136 | L = np.hstack(L) 137 | 138 | Dte = Dtr[i] 139 | Lte = Ltr[i] 140 | 141 | if zscore_Flag is True: 142 | D, Dte = znorm(D, Dte) 143 | 144 | if gauss_Flag is True: 145 | Dte = gaussianize_features(D, Dte) 146 | D = gaussianize_features(D, D) 147 | 148 | expanded_DTR = numpy.apply_along_axis(vecxxT, 0, D) 149 | expanded_DTE = numpy.apply_along_axis(vecxxT, 0, Dte) 150 | phi = numpy.vstack([expanded_DTR, D]) 151 | 152 | phi_DTE = numpy.vstack([expanded_DTE, Dte]) 153 | 154 | scores = quad_logistic_reg_score(phi, L, phi_DTE, l) 155 | scores_append.append(scores) 156 | 157 | LR_labels = np.append(LR_labels, Lte, axis=0) 158 | LR_labels = np.hstack(LR_labels) 159 | 160 | return np.hstack(scores_append), LR_labels 161 | 162 | 163 | def validation_quad_LR(DTR, LTR, L, appendToTitle, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 164 | for l in L: 165 | kfold_QUAD_LR(DTR, LTR, l, 0.5, appendToTitle, PCA_Flag, gauss_Flag, zscore_Flag) 166 | kfold_QUAD_LR(DTR, LTR, l, 0.1, appendToTitle, PCA_Flag, gauss_Flag, zscore_Flag) 167 | kfold_QUAD_LR(DTR, LTR, l, 0.9, appendToTitle, PCA_Flag, gauss_Flag, zscore_Flag) 168 | 169 | x = numpy.logspace(-5, 1, 20) 170 | y = numpy.array([]) 171 | y_05 = numpy.array([]) 172 | y_09 = numpy.array([]) 173 | y_01 = numpy.array([]) 174 | for xi in x: 175 | scores, labels = kfold_QUAD_LR_tuning(DTR, LTR, xi, PCA_Flag, gauss_Flag, zscore_Flag) 176 | y_05 = numpy.hstack((y_05, bayes_error_plot_compare(0.5, scores, labels))) 177 | y_09 = numpy.hstack((y_09, bayes_error_plot_compare(0.9, scores, labels))) 178 | y_01 = numpy.hstack((y_01, bayes_error_plot_compare(0.1, scores, labels))) 179 | 180 | y = numpy.hstack((y, y_05)) 181 | y = numpy.vstack((y, y_09)) 182 | y = numpy.vstack((y, y_01)) 183 | 184 | plot_DCF(x, y, 'lambda', appendToTitle + 'QUAD_LR_minDCF_comparison') 185 | -------------------------------------------------------------------------------- /code/validation/validation_weighted_LR.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | 4 | import numpy 5 | import numpy as np 6 | 7 | sys.path.append('../') 8 | from validators import * 9 | from prettytable import PrettyTable 10 | 11 | 12 | def validate_LR(scores, LR_labels, appendToTitle, l, pi=0.5): 13 | scores_append = np.hstack(scores) 14 | scores_tot_05 = compute_min_DCF(scores_append, LR_labels, 0.5, 1, 1) 15 | scores_tot_01 = compute_min_DCF(scores_append, LR_labels, 0.1, 1, 1) 16 | scores_tot_09 = compute_min_DCF(scores_append, LR_labels, 0.9, 1, 1) 17 | # plot_ROC(scores_append, LR_labels, appendToTitle + 'WEIGHTED_LR, lambda=' + str(l)) 18 | 19 | # Cfn and Ctp are set to 1 20 | # bayes_error_min_act_plot(scores_append, LR_labels, appendToTitle + 'WEIGHTED_LR, lambda=' + str(l), 0.4) 21 | 22 | t = PrettyTable(["Type", "π=0.5", "π=0.1", "π=0.9"]) 23 | t.title = appendToTitle 24 | t.add_row(['WEIGHTED_LR, lambda=' + str(l) + " π_t=" + str(pi), round(scores_tot_05, 3), round(scores_tot_01, 3), round(scores_tot_09, 3)]) 25 | print(t) 26 | 27 | 28 | def kfold_WEIGHTED_LR(DTR, LTR, l, appendToTitle, pi, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 29 | k = 5 30 | Dtr = numpy.split(DTR, k, axis=1) 31 | Ltr = numpy.split(LTR, k) 32 | 33 | scores_append = [] 34 | PCA_LR_scores_append = [] 35 | PCA2_LR_scores_append = [] 36 | LR_labels = [] 37 | 38 | for i in range(k): 39 | D = [] 40 | L = [] 41 | if i == 0: 42 | D.append(np.hstack(Dtr[i + 1:])) 43 | L.append(np.hstack(Ltr[i + 1:])) 44 | elif i == k - 1: 45 | D.append(np.hstack(Dtr[:i])) 46 | L.append(np.hstack(Ltr[:i])) 47 | else: 48 | D.append(np.hstack(Dtr[:i])) 49 | D.append(np.hstack(Dtr[i + 1:])) 50 | L.append(np.hstack(Ltr[:i])) 51 | L.append(np.hstack(Ltr[i + 1:])) 52 | 53 | D = np.hstack(D) 54 | L = np.hstack(L) 55 | 56 | Dte = Dtr[i] 57 | Lte = Ltr[i] 58 | 59 | if zscore_Flag is True: 60 | D, Dte = znorm(D, Dte) 61 | 62 | if gauss_Flag is True: 63 | D_training = D 64 | D = gaussianize_features(D, D) 65 | Dte = gaussianize_features(D_training, Dte) 66 | 67 | 68 | scores = weighted_logistic_reg_score(D, L, Dte, l, pi) 69 | 70 | scores_append.append(scores) 71 | 72 | LR_labels = np.append(LR_labels, Lte, axis=0) 73 | LR_labels = np.hstack(LR_labels) 74 | 75 | if PCA_Flag is True: 76 | # PCA m=10 77 | P = PCA(D, L, m=10) 78 | DTR_PCA = numpy.dot(P.T, D) 79 | DTE_PCA = numpy.dot(P.T, Dte) 80 | 81 | PCA_LR_scores = weighted_logistic_reg_score(DTR_PCA, L, DTE_PCA, l, pi) 82 | PCA_LR_scores_append.append(PCA_LR_scores) 83 | 84 | # PCA m=9 85 | P = PCA(D, L, m=9) 86 | DTR_PCA = numpy.dot(P.T, D) 87 | DTE_PCA = numpy.dot(P.T, Dte) 88 | 89 | PCA2_LR_scores = weighted_logistic_reg_score(DTR_PCA, L, DTE_PCA, l) 90 | PCA2_LR_scores_append.append(PCA2_LR_scores) 91 | 92 | validate_LR(scores_append, LR_labels, appendToTitle, l, pi=pi) 93 | 94 | if PCA_Flag is True: 95 | validate_LR(PCA_LR_scores_append, LR_labels, appendToTitle + 'PCA_m10_', l, pi=pi) 96 | 97 | validate_LR(PCA2_LR_scores_append, LR_labels, appendToTitle + 'PCA_m9_', l, pi=pi) 98 | 99 | 100 | def kfold_WEIGHTED_LR_tuning(DTR, LTR, l, PCA_Flag=False, gauss_Flag=False, zscore_Flag=False, pi=0.5): 101 | k = 5 102 | Dtr = numpy.split(DTR, k, axis=1) 103 | Ltr = numpy.split(LTR, k) 104 | 105 | scores_append = [] 106 | LR_labels = [] 107 | 108 | for i in range(k): 109 | D = [] 110 | L = [] 111 | if i == 0: 112 | D.append(np.hstack(Dtr[i + 1:])) 113 | L.append(np.hstack(Ltr[i + 1:])) 114 | elif i == k - 1: 115 | D.append(np.hstack(Dtr[:i])) 116 | L.append(np.hstack(Ltr[:i])) 117 | else: 118 | D.append(np.hstack(Dtr[:i])) 119 | D.append(np.hstack(Dtr[i + 1:])) 120 | L.append(np.hstack(Ltr[:i])) 121 | L.append(np.hstack(Ltr[i + 1:])) 122 | 123 | D = np.hstack(D) 124 | L = np.hstack(L) 125 | 126 | Dte = Dtr[i] 127 | Lte = Ltr[i] 128 | 129 | if zscore_Flag is True: 130 | D, Dte = znorm(D, Dte) 131 | 132 | if gauss_Flag is True: 133 | D_training = D 134 | D = gaussianize_features(D, D) 135 | Dte = gaussianize_features(D_training, Dte) 136 | 137 | scores = weighted_logistic_reg_score(D, L, Dte, l, pi) 138 | scores_append.append(scores) 139 | 140 | LR_labels = np.append(LR_labels, Lte, axis=0) 141 | LR_labels = np.hstack(LR_labels) 142 | 143 | return np.hstack(scores_append), LR_labels 144 | 145 | 146 | def validation_weighted_LR(DTR, LTR, L, appendToTitle, PCA_Flag=True, gauss_Flag=False, zscore_Flag=False): 147 | for l in L: 148 | kfold_WEIGHTED_LR(DTR, LTR, l, appendToTitle, 0.5, PCA_Flag, gauss_Flag, zscore_Flag) 149 | kfold_WEIGHTED_LR(DTR, LTR, l, appendToTitle, 0.1, PCA_Flag, gauss_Flag, zscore_Flag) 150 | kfold_WEIGHTED_LR(DTR, LTR, l, appendToTitle, 0.9, PCA_Flag, gauss_Flag, zscore_Flag) 151 | 152 | x = numpy.logspace(-5, 1, 24) 153 | y = numpy.array([]) 154 | y_05 = numpy.array([]) 155 | y_09 = numpy.array([]) 156 | y_01 = numpy.array([]) 157 | for xi in x: 158 | scores, labels = kfold_WEIGHTED_LR_tuning(DTR, LTR, xi, PCA_Flag, gauss_Flag, zscore_Flag) 159 | y_05 = numpy.hstack((y_05, bayes_error_plot_compare(0.5, scores, labels))) 160 | y_09 = numpy.hstack((y_09, bayes_error_plot_compare(0.9, scores, labels))) 161 | y_01 = numpy.hstack((y_01, bayes_error_plot_compare(0.1, scores, labels))) 162 | 163 | y = numpy.hstack((y, y_05)) 164 | y = numpy.vstack((y, y_09)) 165 | y = numpy.vstack((y, y_01)) 166 | 167 | plot_DCF(x, y, 'lambda', appendToTitle + 'WEIGHTED_LR_minDCF_comparison') 168 | -------------------------------------------------------------------------------- /code/validators.py: -------------------------------------------------------------------------------- 1 | import numpy 2 | from mlFunc import * 3 | from classifiers import * 4 | 5 | 6 | def kfold_cross(func, DTR, LTR, k): 7 | accuracy = [] 8 | Dtr = numpy.split(DTR, k, axis=1) 9 | Ltr = numpy.split(LTR, k) 10 | 11 | for i in range(k): 12 | D = [] 13 | L = [] 14 | if i == 0: 15 | D.append(numpy.hstack(Dtr[i + 1:])) 16 | L.append(numpy.hstack(Ltr[i + 1:])) 17 | elif i == k - 1: 18 | D.append(numpy.hstack(Dtr[:i])) 19 | L.append(numpy.hstack(Ltr[:i])) 20 | else: 21 | D.append(numpy.hstack(Dtr[:i])) 22 | D.append(numpy.hstack(Dtr[i + 1:])) 23 | L.append(numpy.hstack(Ltr[:i])) 24 | L.append(numpy.hstack(Ltr[i + 1:])) 25 | 26 | D = numpy.hstack(D) 27 | L = numpy.hstack(L) 28 | 29 | DTE = Dtr[i] 30 | LTE = Ltr[i] 31 | # print(str(DTE) + " " + str(i)) 32 | _, lpred = func(DTE, D, L) 33 | acc, _ = test(LTE, lpred) 34 | accuracy.append(acc) 35 | 36 | return numpy.mean(accuracy) 37 | 38 | 39 | def holdout_validation(func, D, L, seed=0, trainPerc=0.8): 40 | nTrain = int(D.shape[1] * trainPerc) 41 | numpy.random.seed(seed) 42 | idx = numpy.random.permutation(D.shape[1]) 43 | idxTrain = idx[0:nTrain] 44 | idxTest = idx[nTrain:] 45 | DTR = D[:, idxTrain] 46 | DTE = D[:, idxTest] 47 | LTR = L[idxTrain] 48 | LTE = L[idxTest] 49 | 50 | _, lpred = func(DTE, DTR, LTR) 51 | acc, _ = test(LTE, lpred) 52 | 53 | return acc 54 | 55 | 56 | def leave_one_out(func, DTR, LTR): 57 | accuracy = [] 58 | 59 | for i in range(DTR.shape[1]): 60 | D = [] 61 | L = [] 62 | D.append(DTR[:, :i]) 63 | D.append(DTR[:, i + 1:]) 64 | D = numpy.hstack(D) 65 | 66 | L.append(LTR[:i]) 67 | L.append(LTR[i + 1:]) 68 | L = numpy.hstack(L) 69 | 70 | DTE = DTR[:, i] 71 | LTE = LTR[i] 72 | # print(str(DTE) + " " + str(i)) 73 | _, lpred = func(mcol(DTE), D, L) 74 | acc, _ = test(LTE, lpred) 75 | accuracy.append(acc) 76 | return numpy.mean(accuracy) 77 | 78 | 79 | def confusion_matrix(Lpred, LTE, k=2): 80 | # k = number of classes 81 | conf = numpy.zeros((k, k)) 82 | for i in range(k): 83 | for j in range(k): 84 | conf[i][j] = ((Lpred == i) * (LTE == j)).sum() 85 | return conf 86 | 87 | 88 | def assign_labels(scores, pi, Cfn, Cfp, th=None): 89 | if th is None: 90 | th = -numpy.log(pi * Cfn) + numpy.log((1 - pi) * Cfp) 91 | P = scores > th 92 | return numpy.int32(P) 93 | 94 | 95 | def confusion_matrix_binary(Lpred, LTE): 96 | C = numpy.zeros((2, 2)) 97 | C[0, 0] = ((Lpred == 0) * (LTE == 0)).sum() 98 | C[0, 1] = ((Lpred == 0) * (LTE == 1)).sum() 99 | C[1, 0] = ((Lpred == 1) * (LTE == 0)).sum() 100 | C[1, 1] = ((Lpred == 1) * (LTE == 1)).sum() 101 | return C 102 | 103 | 104 | def compute_emp_Bayes_binary(CM, pi, Cfn, Cfp): 105 | fnr = CM[0, 1] / (CM[0, 1] + CM[1, 1]) 106 | fpr = CM[1, 0] / (CM[0, 0] + CM[1, 0]) 107 | return pi * Cfn * fnr + (1 - pi) * Cfp * fpr 108 | 109 | 110 | def compute_normalized_emp_Bayes(CM, pi, Cfn, Cfp): 111 | empBayes = compute_emp_Bayes_binary(CM, pi, Cfn, Cfp) 112 | return empBayes / min(pi * Cfn, (1 - pi) * Cfp) 113 | 114 | 115 | def compute_act_DCF(scores, labels, pi, Cfn, Cfp, th=None): 116 | Pred = assign_labels(scores, pi, Cfn, Cfp, th=th) 117 | CM = confusion_matrix_binary(Pred, labels) 118 | return compute_normalized_emp_Bayes(CM, pi, Cfn, Cfp) 119 | 120 | 121 | def compute_min_DCF(scores, labels, pi, Cfn, Cfp): 122 | t = numpy.array(scores) 123 | t.sort() 124 | numpy.concatenate([numpy.array([-numpy.inf]), t, numpy.array([numpy.inf])]) 125 | dcfList = [] 126 | for _th in t: 127 | dcfList.append(compute_act_DCF(scores, labels, pi, Cfn, Cfp, th=_th)) 128 | return numpy.array(dcfList).min() 129 | 130 | 131 | def bayes_error_plot(pArray, scores, labels, minCost=False, th=None): 132 | y = [] 133 | for p in pArray: 134 | pi = 1.0 / (1.0 + numpy.exp(-p)) 135 | if minCost: 136 | y.append(compute_min_DCF(scores, labels, pi, 1, 1)) 137 | else: 138 | y.append(compute_act_DCF(scores, labels, pi, 1, 1, th)) 139 | return numpy.array(y) 140 | 141 | def bayes_error_plot_compare(pi, scores, labels): 142 | y = [] 143 | # pi = 1.0 / (1.0 + numpy.exp(-pi)) #todo 144 | y.append(compute_min_DCF(scores, labels, pi, 1, 1)) 145 | return numpy.array(y) 146 | 147 | 148 | def bayes_error_min_act_plot(D, LTE, title, ylim): 149 | p = numpy.linspace(-3, 3, 21) 150 | pylab.title(title) 151 | pylab.plot(p, bayes_error_plot(p, D, LTE, minCost=False), color='r') 152 | pylab.plot(p, bayes_error_plot(p, D, LTE, minCost=True), color='b') 153 | pylab.ylim(0, ylim) 154 | pylab.savefig('./images/DCF_' + title + '.svg') 155 | pylab.show() 156 | 157 | 158 | def plot_DCF(x, y, xlabel, title, base=10): 159 | plt.figure() 160 | plt.plot(x, y[0], label= 'min DCF prior=0.5', color='b') 161 | plt.plot(x, y[1], label= 'min DCF prior=0.9', color='g') 162 | plt.plot(x, y[2], label= 'min DCF prior=0.1', color='r') 163 | plt.xlim([min(x), max(x)]) 164 | plt.xscale("log", base=base) 165 | plt.legend([ "min DCF prior=0.5", "min DCF prior=0.9", "min DCF prior=0.1"]) 166 | plt.xlabel(xlabel) 167 | plt.ylabel("min DCF") 168 | plt.savefig('./images/DCF_' + title+ '.svg') 169 | plt.show() 170 | return 171 | 172 | def plot_DCF_for_SVM_RBF_calibration(x, y, xlabel, title, base=10): 173 | plt.figure() 174 | plt.plot(x, y[0], label= 'logγ=-3', color='b') 175 | plt.plot(x, y[1], label= 'logγ=-2', color='g') 176 | plt.plot(x, y[2], label= 'logγ=-1', color='r') 177 | plt.plot(x, y[3], label= 'logγ=-0', color='y') 178 | 179 | plt.xlim([min(x), max(x)]) 180 | plt.ylim([0.0, 0.7]) 181 | plt.xscale("log", base=base) 182 | plt.legend([ "logγ=-3", "logγ=-2", "logγ=-1", "logγ=0"]) 183 | plt.xlabel(xlabel) 184 | plt.ylabel("minDCF") 185 | plt.savefig('./images/DCF_' + title+ '.svg') 186 | plt.show() 187 | return 188 | 189 | 190 | def plot_ROC(llrs, LTE, title): 191 | thresholds = numpy.array(llrs) 192 | thresholds.sort() 193 | thresholds = numpy.concatenate([numpy.array([-numpy.inf]), thresholds, numpy.array([numpy.inf])]) 194 | FPR = numpy.zeros(thresholds.size) 195 | TPR = numpy.zeros(thresholds.size) 196 | for idx, t in enumerate(thresholds): 197 | Pred = numpy.int32(llrs > t) 198 | conf = confusion_matrix_binary(Pred, LTE) 199 | TPR[idx] = conf[1, 1] / (conf[1, 1] + conf[0, 1]) 200 | FPR[idx] = conf[1, 0] / (conf[1, 0] + conf[0, 0]) 201 | pylab.plot(FPR, TPR) 202 | pylab.title(title) 203 | pylab.savefig('./images/ROC_' + title + '.png') 204 | pylab.show() 205 | 206 | 207 | def generative_acc_err(DTE, DTR, LTE, LTR, title): 208 | _, LPred2, llrs = MVG(DTE, DTR, LTR) 209 | _, LP2n, llrsn = naive_MVG(DTE, DTR, LTR) 210 | _, LP2t, llrst = tied_cov_GC(DTE, DTR, LTR) 211 | _, LP2nt, llrsnt = tied_cov_naive_GC(DTE, DTR, LTR) 212 | # logMVG accuracy 213 | log_acc, log_err = test(LTE, LPred2) 214 | log_acc_n, log_err_n = test(LTE, LP2n) 215 | log_acc_t, log_err_t = test(LTE, LP2t) 216 | log_acc_nt, log_err_nt = test(LTE, LP2nt) 217 | 218 | table = PrettyTable(["", "Accuracy %", "Error "]) 219 | table.title = title 220 | table.add_row(["MVG", round(log_acc * 100, 3), round(log_err * 100, 3)]) 221 | table.add_row(["Naive MVG", round(log_acc_n * 100, 3), round(log_err_n * 100, 3)]) 222 | table.add_row(["Tied GC", round(log_acc_t * 100, 3), round(log_err_t * 100, 3)]) 223 | table.add_row(["Naive Tied GC", round(log_acc_nt * 100, 3), round(log_err_nt * 100, 3)]) 224 | print(table) 225 | --------------------------------------------------------------------------------