Templates
In this notebook we provide different code templates. Feel free to copy the contents of the cells to design your own pyanno4rt treatment plan!
Optimization components
This section covers the available optimization components, which have to be set in the components dictionary for the “instance” key. If user-dependent inputs are required, we added a string placeholder with “<>”. Further information on the component-specific parameters can be found in the API.
Conventional components
Dose Uniformity
{
'class': 'Dose Uniformity',
'parameters': {
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [None, None],
'link': None,
'identifier': None,
'display': True
}
}
Equivalent Uniform Dose
{
'class': 'Equivalent Uniform Dose',
'parameters': {
'target_eud': '<your_target_eud>',
'volume_parameter': '<your_volume_parameter>',
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [None, None],
'link': None,
'identifier': None,
'display': True
}
}
Maximum DVH
{
'class': 'Maximum DVH',
'parameters': {
'target_dose': '<your_target_dose>',
'quantile_volume': '<your_quantile_volume>',
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [None, None],
'link': None,
'identifier': None,
'display': True
}
}
Mean Dose
{
'class': 'Mean Dose',
'parameters': {
'target_dose': '<your_target_dose>',
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [None, None],
'link': None,
'identifier': None,
'display': True
}
}
Minimum DVH
{
'class': 'Minimum DVH',
'parameters': {
'target_dose': '<your_target_dose>',
'quantile_volume': '<your_quantile_volume>',
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [None, None],
'link': None,
'identifier': None,
'display': True
}
}
Squared Deviation
{
'class': 'Squared Deviation',
'parameters': {
'target_dose': '<your_target_dose>',
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [None, None],
'link': None,
'identifier': None,
'display': True
}
}
Squared Overdosing
{
'class': 'Squared Overdosing',
'parameters': {
'maximum_dose': '<your_maximum_dose>',
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [None, None],
'link': None,
'identifier': None,
'display': True
}
}
Squared Underdosing
{
'class': 'Squared Underdosing',
'parameters': {
'minimum_dose': '<your_maximum_dose>',
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [None, None],
'link': None,
'identifier': None,
'display': True
}
}
Radiobiological model-based components
LQ Poisson TCP
{
'class': 'LQ Poisson TCP',
'parameters': {
'alpha': '<your_alpha>',
'beta': '<your_beta>',
'volume_parameter': '<your_volume_parameter>',
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [0.0, 1.0],
'link': None,
'identifier': None,
'display': True
}
}
Lyman-Kutcher-Burman NTCP
{
'class': 'Lyman-Kutcher-Burman NTCP',
'parameters': {
'tolerance_dose_50': '<your_td50>',
'slope_parameter': '<your_slope_parameter>',
'volume_parameter': '<your_volume_parameter>',
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [0.0, 1.0],
'link': None,
'identifier': None,
'display': True
}
}
Machine learning model-based components
Decision Tree (N)TCP
{
'class': 'Decision Tree (N)TCP',
'parameters': {
'model_parameters': {
'model_label': '<your_model_label>',
'model_folder_path': None,
'data_path': '<your_data_path>', # Insert the path to your data file here
'feature_filter': {
'features': [],
'filter_mode': 'remove'
},
'label_name': '<your_label_name>',
'label_bounds': [1, 1],
'time_variable_name': None,
'label_viewpoint': 'long-term',
'fuzzy_matching': True,
'preprocessing_steps': ['Identity'],
'tune_space': {
'criterion': ['gini', 'entropy'],
'splitter': ['best', 'random'],
'max_depth': list(range(1, 21)),
'min_samples_split': [0.0, 1.0],
'min_samples_leaf': [0.0, 0.5],
'min_weight_fraction_leaf': [0.0, 0.5],
'max_features': list(range(1, 21)),
'class_weight': [None, 'balanced'],
'ccp_alpha': [0.0, 1.0]
},
'tune_evaluations': 50,
'tune_score': 'Logloss',
'tune_splits': 5,
'inspect_model': True,
'evaluate_model': True,
'oof_splits': 5,
'write_features': True,
'display_options': {
'graphs': ['AUC-ROC', 'AUC-PR', 'F1'],
'kpis': ['Logloss', 'Brier score',
'Subset accuracy', 'Cohen Kappa',
'Hamming loss', 'Jaccard score',
'Precision', 'Recall', 'F1 score',
'MCC', 'AUC']
},
},
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [0.0, 1.0],
'link': None,
'identifier': None,
'display': True
}
}
K-Nearest Neighbors (N)TCP
{
'class': 'K-Nearest Neighbors (N)TCP',
'parameters': {
'model_parameters': {
'model_label': '<your_model_label>',
'model_folder_path': None,
'data_path': '<your_data_path>', # Insert the path to your data file here
'feature_filter': {
'features': [],
'filter_mode': 'remove'
},
'label_name': '<your_label_name>',
'label_bounds': [1, 1],
'time_variable_name': None,
'label_viewpoint': 'long-term',
'fuzzy_matching': True,
'preprocessing_steps': ['Identity'],
'tune_space': {
'weights': ['uniform', 'distance'],
'leaf_size': list(range(1, 501)),
'p': [1, 2, 3]
},
'tune_evaluations': 50,
'tune_score': 'Logloss',
'tune_splits': 5,
'inspect_model': True,
'evaluate_model': True,
'oof_splits': 5,
'write_features': True,
'display_options': {
'graphs': ['AUC-ROC', 'AUC-PR', 'F1'],
'kpis': ['Logloss', 'Brier score',
'Subset accuracy', 'Cohen Kappa',
'Hamming loss', 'Jaccard score',
'Precision', 'Recall', 'F1 score',
'MCC', 'AUC']
},
},
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [0.0, 1.0],
'link': None,
'identifier': None,
'display': True
}
}
Logistic Regression (N)TCP
{
'class': 'Logistic Regression (N)TCP',
'parameters': {
'model_parameters': {
'model_label': '<your_model_label>',
'model_folder_path': None,
'data_path': '<your_data_path>', # Insert the path to your data file here
'feature_filter': {
'features': [],
'filter_mode': 'remove'
},
'label_name': '<your_label_name>',
'label_bounds': [1, 1],
'time_variable_name': None,
'label_viewpoint': 'long-term',
'fuzzy_matching': True,
'preprocessing_steps': ['Identity'],
'tune_space': {
'C': [2**-5, 2**10],
'penalty': ['l1', 'l2'],
'tol': [1e-4, 1e-5, 1e-6],
'class_weight': [None, 'balanced']
},
'tune_evaluations': 50,
'tune_score': 'Logloss',
'tune_splits': 5,
'inspect_model': True,
'evaluate_model': True,
'oof_splits': 5,
'write_features': True,
'display_options': {
'graphs': ['AUC-ROC', 'AUC-PR', 'F1'],
'kpis': ['Logloss', 'Brier score',
'Subset accuracy', 'Cohen Kappa',
'Hamming loss', 'Jaccard score',
'Precision', 'Recall', 'F1 score',
'MCC', 'AUC']
},
},
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [0.0, 1.0],
'link': None,
'identifier': None,
'display': True
}
}
Naive Bayes (N)TCP
{
'class': 'Naive Bayes (N)TCP',
'parameters': {
'model_parameters': {
'model_label': '<your_model_label>',
'model_folder_path': None,
'data_path': '<your_data_path>', # Insert the path to your data file here
'feature_filter': {
'features': [],
'filter_mode': 'remove'
},
'label_name': '<your_label_name>',
'label_bounds': [1, 1],
'time_variable_name': None,
'label_viewpoint': 'long-term',
'fuzzy_matching': True,
'preprocessing_steps': ['Identity'],
'tune_space': {
'priors': [0.5, 0.5],
'var_smoothing': [1e-12, 1]
},
'tune_evaluations': 50,
'tune_score': 'Logloss',
'tune_splits': 5,
'inspect_model': True,
'evaluate_model': True,
'oof_splits': 5,
'write_features': True,
'display_options': {
'graphs': ['AUC-ROC', 'AUC-PR', 'F1'],
'kpis': ['Logloss', 'Brier score',
'Subset accuracy', 'Cohen Kappa',
'Hamming loss', 'Jaccard score',
'Precision', 'Recall', 'F1 score',
'MCC', 'AUC']
},
},
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [0.0, 1.0],
'link': None,
'identifier': None,
'display': True
}
}
Neural Network (N)TCP
{
'class': 'Neural Network (N)TCP',
'parameters': {
'model_parameters': {
'model_label': '<your_model_label>',
'model_folder_path': None,
'data_path': '<your_data_path>', # Insert the path to your data file here
'feature_filter': {
'features': [],
'filter_mode': 'remove'
},
'label_name': '<your_label_name>',
'label_bounds': [1, 1],
'time_variable_name': None,
'label_viewpoint': 'long-term',
'fuzzy_matching': True,
'preprocessing_steps': ['Identity'],
'architecture': 'input-convex',
'max_hidden_layers': 2,
'tune_space': {
'input_neuron_number': [2**x for x in range(1, 12)],
'input_activation': ['elu', 'gelu', 'leaky_relu', 'linear',
'relu', 'softmax', 'softplus', 'swish'],
'hidden_neuron_number': [2**x for x in range(1, 12)],
'hidden_activation': ['elu', 'gelu', 'leaky_relu', 'linear',
'relu', 'softmax', 'softplus', 'swish'],
'input_dropout_rate': [0.0, 0.1, 0.25, 0.5, 0.75],
'hidden_dropout_rate': [0.0, 0.1, 0.25, 0.5, 0.75],
'batch_size': [4, 8, 16, 32],
'learning_rate': [1e-5, 1e-2],
'optimizer': ['Adam', 'Ftrl', 'SGD'],
'loss': ['BCE', 'FocalBCE', 'KLD']
},
'tune_evaluations': 50,
'tune_score': 'Logloss',
'tune_splits': 5,
'inspect_model': True,
'evaluate_model': True,
'oof_splits': 5,
'write_features': True,
'display_options': {
'graphs': ['AUC-ROC', 'AUC-PR', 'F1'],
'kpis': ['Logloss', 'Brier score',
'Subset accuracy', 'Cohen Kappa',
'Hamming loss', 'Jaccard score',
'Precision', 'Recall', 'F1 score',
'MCC', 'AUC']
},
},
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [0.0, 1.0],
'link': None,
'identifier': None,
'display': True
}
}
Random Forest (N)TCP
{
'class': 'Random Forest (N)TCP',
'parameters': {
'model_parameters': {
'model_label': '<your_model_label>',
'model_folder_path': None,
'data_path': '<your_data_path>', # Insert the path to your data file here
'feature_filter': {
'features': [],
'filter_mode': 'remove'
},
'label_name': '<your_label_name>',
'label_bounds': [1, 1],
'time_variable_name': None,
'label_viewpoint': 'long-term',
'fuzzy_matching': True,
'preprocessing_steps': ['Identity'],
'tune_space': {
'n_estimators': list(range(1, 51)),
'criterion': ['gini', 'entropy'],
'max_depth': list(range(1, 21)),
'min_samples_split': [0.0, 1.0],
'min_samples_leaf': [0.0, 0.5],
'min_weight_fraction_leaf': [0.0, 0.5],
'max_features': list(range(1, 11)),
'bootstrap': [False, True],
'class_weight': [None, 'balanced'],
'ccp_alpha': [0.0, 1.0]
},
'tune_evaluations': 50,
'tune_score': 'Logloss',
'tune_splits': 5,
'inspect_model': True,
'evaluate_model': True,
'oof_splits': 5,
'write_features': True,
'display_options': {
'graphs': ['AUC-ROC', 'AUC-PR', 'F1'],
'kpis': ['Logloss', 'Brier score',
'Subset accuracy', 'Cohen Kappa',
'Hamming loss', 'Jaccard score',
'Precision', 'Recall', 'F1 score',
'MCC', 'AUC']
},
},
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [0.0, 1.0],
'link': None,
'identifier': None,
'display': True
}
}
Support Vector Machine (N)TCP
{
'class': 'Support Vector Machine (N)TCP',
'parameters': {
'model_parameters': {
'model_label': '<your_model_label>',
'model_folder_path': None,
'data_path': '<your_data_path>', # Insert the path to your data file here
'feature_filter': {
'features': [],
'filter_mode': 'remove'
},
'label_name': '<your_label_name>',
'label_bounds': [1, 1],
'time_variable_name': None,
'label_viewpoint': 'long-term',
'fuzzy_matching': True,
'preprocessing_steps': ['Identity'],
'tune_space': {
'C': [2**-5, 2**10],
'kernel': ['linear', 'poly', 'rbf', 'sigmoid'],
'degree': [3, 4, 5, 6],
'gamma': [2**-15, 2**3],
'tol': [1e-4, 1e-5, 1e-6],
'class_weight': [None, 'balanced']
},
'tune_evaluations': 50,
'tune_score': 'Logloss',
'tune_splits': 5,
'inspect_model': True,
'evaluate_model': True,
'oof_splits': 5,
'write_features': True,
'display_options': {
'graphs': ['AUC-ROC', 'AUC-PR', 'F1'],
'kpis': ['Logloss', 'Brier score',
'Subset accuracy', 'Cohen Kappa',
'Hamming loss', 'Jaccard score',
'Precision', 'Recall', 'F1 score',
'MCC', 'AUC']
},
},
'embedding': 'active',
'weight': 1,
'rank': 1,
'bounds': [0.0, 1.0],
'link': None,
'identifier': None,
'display': True
}
}