Commit 931f24fa authored by Alessia Marcolini's avatar Alessia Marcolini
Browse files

Patient Wise DAP

parent 6474a061
......@@ -25,29 +25,30 @@ from dap.models.featuresmodel import DAPSVMClassifier, DAPRandomForestClassifier
# from dap.models.sklearnmodel import SklearnModel
from sklearn import svm
from dap.crossval import kfold_split
from dap.crossval import kfold_split, patient_wise_cv_fold
from dap.ranking import randomforest_ranking, kbest_ranking
# from dap_devel.dap.dap import DAP
# %%
SEED = 1234
LAB_COL = 'Locoregional'
FEATURESET = 'radiomics_features_CT_F_SVC_Locoregional' #'features_LR' #radiomics_features_F_SVC_Locoregional
LAB_COL = 'label'
PATIENT_COL = 'patient'
FEATURESET = 'features_noTx_AUG' #'features_LR' #radiomics_features_F_SVC_Locoregional
#%%
LABELS_FILE = f'{PATH}/data/clinical_data.csv'
LABELS_FILE = f'{PATH}/data/clinical_data_noTx.csv'
NETWORK = 'LR_noTx_branch_wise_free_aug_CT_20191027-124913'
FEATUREDIR = f'{PATH}/data/' #f'{PATH}/experiments/{NETWORK}/features' # # ##
OUT_DIR = f'{PATH}/predictions/{FEATURESET}'
FEATUREDIR = f'{PATH}/experiments/{NETWORK}/features' #f'{PATH}/data/' # ##
#OUT_DIR = f'{PATH}/predictions/{FEATURESET}'
OUT_DIR = f'{PATH}/experiments/{NETWORK}'
FEATURE_FILE_DEEP = f'{FEATUREDIR}/{FEATURESET}.csv'
FEATURE_FILE_RADIOMICS = f'{FEATUREDIR}/{FEATURESET}.csv'
# %%
dataset = FeatureLabelCSVDataset(FEATURE_FILE_RADIOMICS, LABELS_FILE, LAB_COL, problem='binary', name=FEATURESET)
dataset = CSVDataset(FEATURE_FILE_DEEP, LAB_COL, PATIENT_COL, problem='binary', name=FEATURESET)
#%%
metrics = BinaryMetrics(reference='MCC')
......@@ -56,8 +57,9 @@ dap_settings = {'stratified_test': True,
'ratio_test': 0.2,
'stratified_valid': True,
'ratio_valid': 0.2,
'fold_method': kfold_split,
'cv_n': 10}
'fold_method': patient_wise_cv_fold,
'cv_n': 10,
'patient_wise_split': True}
# %% [markdown]
# ## LSVM
......@@ -69,7 +71,7 @@ model = DAPSVMClassifier({'rank_features': False, 'scale_features': True, 'kerne
# %%
DAP = dap.DAP(dap_settings, dataset, model, metrics, name='kfold', seed=SEED)
n_feat = [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1]
n_feat = [0.25, 0.5, 0.75, 1]
parameters = {'C':[0.001, 0.01, 0.1, 1, 10, 100, 1000], 'n_feat': n_feat} # [0.001, 0.01, 0.1, 1, 10, 100, 1000]
param_grid = dap.dap.create_param_grid(parameters)
......@@ -84,24 +86,24 @@ DAP.save(OUT_DIR)
# ## Random Forest
# %%
model = DAPRandomForestClassifier({'rank_features': False, 'scale_features': True, 'n_estimators': 500, 'random_labels': False}, name='DAPRFClassifier')
# model = DAPRandomForestClassifier({'rank_features': False, 'scale_features': True, 'n_estimators': 500, 'random_labels': False}, name='DAPRFClassifier2')
# %%
DAP = dap.DAP(dap_settings, dataset, model, metrics, name='kfold')
# DAP = dap.DAP(dap_settings, dataset, model, metrics, name='kfold2')
#%%
n_feat = [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1]
parameters = {'n_feat': n_feat} # [0.001, 0.01, 0.1, 1, 10, 100, 1000]
param_grid = dap.dap.create_param_grid(parameters)
# n_feat = [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1]
# parameters = {'n_feat': n_feat} # [0.001, 0.01, 0.1, 1, 10, 100, 1000]
# param_grid = dap.dap.create_param_grid(parameters)
DAP.fit(param_grid)
# DAP.fit(param_grid)
# %%
DAP.predict_on_test()
DAP.save(OUT_DIR)
# DAP.predict_on_test()
# DAP.save(OUT_DIR)
# %%
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment