Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed drevalpy/.DS_Store
Binary file not shown.
11 changes: 7 additions & 4 deletions drevalpy/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,10 +903,11 @@ def train_and_predict(

train_dataset.reduce_to(cell_line_ids=cell_lines_to_keep, drug_ids=drugs_to_keep)
prediction_dataset.reduce_to(cell_line_ids=cell_lines_to_keep, drug_ids=drugs_to_keep)
print(f"Reduced training dataset from {len_train_before} to {len(train_dataset)}, because of missing features")
print(
f"Reduced prediction dataset from {len_pred_before} to {len(prediction_dataset)}, because of missing features"
)
if len(train_dataset) < len_train_before or len(prediction_dataset) < len_pred_before:
print(f"Reduced training dataset from {len_train_before} to {len(train_dataset)}, due to of missing features")
print(
f"Reduced prediction dataset from {len_pred_before} to {len(prediction_dataset)}, due to missing features"
)

if early_stopping_dataset is not None:
len_es_before = len(early_stopping_dataset)
Expand Down Expand Up @@ -1149,6 +1150,8 @@ def get_model_name_and_drug_id(model_name: str) -> tuple[str, str | None]:
:returns: tuple of model name and, potentially drug id if it is a single drug model
:raises AssertionError: if the model name is not found in the model factory
"""
print(model_name)
print(MULTI_DRUG_MODEL_FACTORY.keys())
if model_name in MULTI_DRUG_MODEL_FACTORY:
return model_name, None
else:
Expand Down
Binary file removed drevalpy/models/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions drevalpy/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"MultiOmicsNeuralNetwork",
"MultiOmicsRandomForest",
"SingleDrugRandomForest",
"SingleDrugElasticNet",
"SingleDrugProteomicsElasticNet",
"SRMF",
"GradientBoosting",
"MOLIR",
Expand All @@ -23,6 +25,7 @@

from .baselines.multi_omics_random_forest import MultiOmicsRandomForest
from .baselines.naive_pred import NaiveCellLineMeanPredictor, NaiveDrugMeanPredictor, NaivePredictor
from .baselines.singledrug_elastic_net import SingleDrugElasticNet, SingleDrugProteomicsElasticNet
from .baselines.singledrug_random_forest import SingleDrugRandomForest
from .baselines.sklearn_models import ElasticNetModel, GradientBoosting, RandomForest, SVMRegressor
from .DIPK.dipk import DIPKModel
Expand All @@ -38,6 +41,8 @@
"SingleDrugRandomForest": SingleDrugRandomForest,
"MOLIR": MOLIR,
"SuperFELTR": SuperFELTR,
"SingleDrugElasticNet": SingleDrugElasticNet,
"SingleDrugProteomicsElasticNet": SingleDrugProteomicsElasticNet,
}

# MULTI_DRUG_MODEL_FACTORY is used in the pipeline!
Expand Down
30 changes: 30 additions & 0 deletions drevalpy/models/baselines/hyperparameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,33 @@ GradientBoosting:
- 1.0
- 0.8
- 0.5
SingleDrugElasticNet:
l1_ratio:
- 0.2
- 0.5
- 0.9
alpha:
- 1
- 0.8
- 0.6
- 0.4
- 0.2
- 0.1
- 5
- 10
- 100
SingleDrugProteomicsElasticNet:
l1_ratio:
- 0.2
- 0.5
- 0.9
alpha:
- 1
- 0.8
- 0.6
- 0.4
- 0.2
- 0.1
- 5
- 10
- 100
10 changes: 10 additions & 0 deletions drevalpy/models/baselines/singledrug_random_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,13 @@ def predict(
drug_input=None,
)
return self.model.predict(x)

def load_drug_features(self, data_path, dataset_name):
"""
Load drug features. Not needed for SingleDrugRandomForest.

:param data_path: path to the data
:param dataset_name: name of the dataset
:returns: None
"""
return None
13 changes: 11 additions & 2 deletions tests/individual_models/test_baselines.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
NaiveCellLineMeanPredictor,
NaiveDrugMeanPredictor,
NaivePredictor,
SingleDrugElasticNet,
SingleDrugProteomicsElasticNet,
SingleDrugRandomForest,
)
from drevalpy.models.baselines.sklearn_models import SklearnModel
Expand Down Expand Up @@ -93,7 +95,9 @@ def test_baselines(
)


@pytest.mark.parametrize("model_name", ["SingleDrugRandomForest"])
@pytest.mark.parametrize(
"model_name", ["SingleDrugRandomForest", "SingleDrugElasticNet", "SingleDrugProteomicsElasticNet"]
)
@pytest.mark.parametrize("test_mode", ["LPO", "LCO"])
def test_single_drug_baselines(
sample_dataset: tuple[DrugResponseDataset, FeatureDataset, FeatureDataset], model_name: str, test_mode: str
Expand Down Expand Up @@ -122,8 +126,13 @@ def test_single_drug_baselines(
random_drug = all_unique_drugs[:1]

all_predictions = np.zeros_like(val_dataset.drug_ids, dtype=float)
if model_name == "SingleDrugElasticNet":
model = SingleDrugElasticNet()
elif model_name == "SingleDrugProteomicsElasticNet":
model = SingleDrugProteomicsElasticNet()
else:
model = SingleDrugRandomForest()

model = SingleDrugRandomForest()
hpam_combi = model.get_hyperparameter_set()[0]
hpam_combi["n_estimators"] = 2 # reduce test time
hpam_combi["max_depth"] = 2 # reduce test time
Expand Down
Loading