From f24678a3188764e5c318bff7a7f194e4aa702f52 Mon Sep 17 00:00:00 2001 From: pavlovicmilena Date: Wed, 27 Oct 2021 21:32:04 +0200 Subject: [PATCH] move Metric.py to ml_metrics package & update version --- immuneML/dsl/instruction_parsers/TrainMLModelParser.py | 3 +-- immuneML/environment/Constants.py | 2 +- .../hyperparameter_optimization/states/TrainMLModelState.py | 2 +- immuneML/{environment => ml_metrics}/Metric.py | 0 immuneML/presentation/html/HPHTMLBuilder.py | 2 +- immuneML/reports/ml_reports/TrainingPerformance.py | 2 +- immuneML/workflows/instructions/MLProcess.py | 2 +- immuneML/workflows/instructions/TrainMLModelInstruction.py | 2 +- immuneML/workflows/steps/MLMethodAssessment.py | 2 +- immuneML/workflows/steps/MLMethodAssessmentParams.py | 2 +- test/dsl/semantic_model/test_semanticModel.py | 2 +- test/integration_tests/test_receptorClassification.py | 2 +- test/integration_tests/test_sequenceClassification.py | 2 +- test/reports/analysis_reports/test_CVFeaturePerformance.py | 2 +- test/reports/ml_reports/test_TrainingPerformance.py | 3 +-- test/reports/ml_reports/test_mLSettingsPerformance.py | 2 +- test/workflows/instructions/test_HPOptimizationInstruction.py | 2 +- test/workflows/steps/test_MLMethodAssessment.py | 2 +- 18 files changed, 17 insertions(+), 19 deletions(-) rename immuneML/{environment => ml_metrics}/Metric.py (100%) diff --git a/immuneML/dsl/instruction_parsers/TrainMLModelParser.py b/immuneML/dsl/instruction_parsers/TrainMLModelParser.py index 03c310364..459afa29e 100644 --- a/immuneML/dsl/instruction_parsers/TrainMLModelParser.py +++ b/immuneML/dsl/instruction_parsers/TrainMLModelParser.py @@ -1,5 +1,4 @@ import hashlib -import warnings from inspect import signature from pathlib import Path from typing import Tuple @@ -11,13 +10,13 @@ from immuneML.dsl.symbol_table.SymbolTable import SymbolTable from immuneML.environment.EnvironmentSettings import EnvironmentSettings from immuneML.environment.LabelConfiguration import LabelConfiguration -from immuneML.environment.Metric import Metric from immuneML.hyperparameter_optimization.HPSetting import HPSetting from immuneML.hyperparameter_optimization.config.LeaveOneOutConfig import LeaveOneOutConfig from immuneML.hyperparameter_optimization.config.ManualSplitConfig import ManualSplitConfig from immuneML.hyperparameter_optimization.config.ReportConfig import ReportConfig from immuneML.hyperparameter_optimization.config.SplitConfig import SplitConfig from immuneML.hyperparameter_optimization.config.SplitType import SplitType +from immuneML.ml_metrics.Metric import Metric from immuneML.reports.train_ml_model_reports.TrainMLModelReport import TrainMLModelReport from immuneML.util.ParameterValidator import ParameterValidator from immuneML.util.ReflectionHandler import ReflectionHandler diff --git a/immuneML/environment/Constants.py b/immuneML/environment/Constants.py index af438ea7e..110f5c3c2 100644 --- a/immuneML/environment/Constants.py +++ b/immuneML/environment/Constants.py @@ -1,6 +1,6 @@ class Constants: - VERSION = "2.0.5" + VERSION = "2.0.6" # encoding constants FEATURE_DELIMITER = "///" diff --git a/immuneML/hyperparameter_optimization/states/TrainMLModelState.py b/immuneML/hyperparameter_optimization/states/TrainMLModelState.py index 0136a5ca0..baf5a7ffc 100644 --- a/immuneML/hyperparameter_optimization/states/TrainMLModelState.py +++ b/immuneML/hyperparameter_optimization/states/TrainMLModelState.py @@ -4,12 +4,12 @@ from immuneML.data_model.dataset.Dataset import Dataset from immuneML.environment.LabelConfiguration import LabelConfiguration -from immuneML.environment.Metric import Metric from immuneML.hyperparameter_optimization.HPSetting import HPSetting from immuneML.hyperparameter_optimization.config.SplitConfig import SplitConfig from immuneML.hyperparameter_optimization.states.HPAssessmentState import HPAssessmentState from immuneML.hyperparameter_optimization.states.HPItem import HPItem from immuneML.hyperparameter_optimization.strategy.HPOptimizationStrategy import HPOptimizationStrategy +from immuneML.ml_metrics.Metric import Metric from immuneML.reports.ReportResult import ReportResult diff --git a/immuneML/environment/Metric.py b/immuneML/ml_metrics/Metric.py similarity index 100% rename from immuneML/environment/Metric.py rename to immuneML/ml_metrics/Metric.py diff --git a/immuneML/presentation/html/HPHTMLBuilder.py b/immuneML/presentation/html/HPHTMLBuilder.py index bcdeb9332..cf7ff7efa 100644 --- a/immuneML/presentation/html/HPHTMLBuilder.py +++ b/immuneML/presentation/html/HPHTMLBuilder.py @@ -7,7 +7,6 @@ from immuneML.environment.Constants import Constants from immuneML.environment.EnvironmentSettings import EnvironmentSettings -from immuneML.environment.Metric import Metric from immuneML.hyperparameter_optimization.config.SplitType import SplitType from immuneML.hyperparameter_optimization.states.HPAssessmentState import HPAssessmentState from immuneML.hyperparameter_optimization.states.HPItem import HPItem @@ -15,6 +14,7 @@ from immuneML.hyperparameter_optimization.states.HPSelectionState import HPSelectionState from immuneML.hyperparameter_optimization.states.TrainMLModelState import TrainMLModelState from immuneML.ml_methods.util.Util import Util as MLUtil +from immuneML.ml_metrics.Metric import Metric from immuneML.presentation.TemplateParser import TemplateParser from immuneML.presentation.html.Util import Util from immuneML.reports.ReportResult import ReportResult diff --git a/immuneML/reports/ml_reports/TrainingPerformance.py b/immuneML/reports/ml_reports/TrainingPerformance.py index 7d421bcf8..38d32fc2f 100644 --- a/immuneML/reports/ml_reports/TrainingPerformance.py +++ b/immuneML/reports/ml_reports/TrainingPerformance.py @@ -8,10 +8,10 @@ from sklearn.preprocessing import label_binarize from immuneML.data_model.dataset.Dataset import Dataset -from immuneML.environment.Metric import Metric from immuneML.hyperparameter_optimization import HPSetting from immuneML.ml_methods.MLMethod import MLMethod from immuneML.ml_metrics import ml_metrics +from immuneML.ml_metrics.Metric import Metric from immuneML.reports.ReportOutput import ReportOutput from immuneML.reports.ReportResult import ReportResult from immuneML.reports.ml_reports.MLReport import MLReport diff --git a/immuneML/workflows/instructions/MLProcess.py b/immuneML/workflows/instructions/MLProcess.py index 2c52dd372..c1d656f0e 100644 --- a/immuneML/workflows/instructions/MLProcess.py +++ b/immuneML/workflows/instructions/MLProcess.py @@ -5,10 +5,10 @@ from immuneML.data_model.dataset.Dataset import Dataset from immuneML.environment.LabelConfiguration import LabelConfiguration -from immuneML.environment.Metric import Metric from immuneML.hyperparameter_optimization.HPSetting import HPSetting from immuneML.hyperparameter_optimization.core.HPUtil import HPUtil from immuneML.hyperparameter_optimization.states.HPItem import HPItem +from immuneML.ml_metrics.Metric import Metric from immuneML.reports.ReportUtil import ReportUtil from immuneML.reports.ml_reports.MLReport import MLReport from immuneML.util.PathBuilder import PathBuilder diff --git a/immuneML/workflows/instructions/TrainMLModelInstruction.py b/immuneML/workflows/instructions/TrainMLModelInstruction.py index 2a60b93cb..0987099f2 100644 --- a/immuneML/workflows/instructions/TrainMLModelInstruction.py +++ b/immuneML/workflows/instructions/TrainMLModelInstruction.py @@ -6,13 +6,13 @@ from immuneML.IO.ml_method.MLExporter import MLExporter from immuneML.environment.LabelConfiguration import LabelConfiguration -from immuneML.environment.Metric import Metric from immuneML.hyperparameter_optimization.config.SplitConfig import SplitConfig from immuneML.hyperparameter_optimization.config.SplitType import SplitType from immuneML.hyperparameter_optimization.core.HPAssessment import HPAssessment from immuneML.hyperparameter_optimization.core.HPUtil import HPUtil from immuneML.hyperparameter_optimization.states.TrainMLModelState import TrainMLModelState from immuneML.hyperparameter_optimization.strategy.HPOptimizationStrategy import HPOptimizationStrategy +from immuneML.ml_metrics.Metric import Metric from immuneML.reports.train_ml_model_reports.TrainMLModelReport import TrainMLModelReport from immuneML.util.ReflectionHandler import ReflectionHandler from immuneML.workflows.instructions.Instruction import Instruction diff --git a/immuneML/workflows/steps/MLMethodAssessment.py b/immuneML/workflows/steps/MLMethodAssessment.py index f81edd070..2c9637882 100644 --- a/immuneML/workflows/steps/MLMethodAssessment.py +++ b/immuneML/workflows/steps/MLMethodAssessment.py @@ -5,10 +5,10 @@ import pandas as pd from sklearn import metrics -from immuneML.environment.Metric import Metric from immuneML.ml_methods.MLMethod import MLMethod from immuneML.ml_methods.util.Util import Util from immuneML.ml_metrics import ml_metrics +from immuneML.ml_metrics.Metric import Metric from immuneML.util.PathBuilder import PathBuilder from immuneML.workflows.steps.MLMethodAssessmentParams import MLMethodAssessmentParams from immuneML.workflows.steps.Step import Step diff --git a/immuneML/workflows/steps/MLMethodAssessmentParams.py b/immuneML/workflows/steps/MLMethodAssessmentParams.py index 3c20a9066..488b6b896 100644 --- a/immuneML/workflows/steps/MLMethodAssessmentParams.py +++ b/immuneML/workflows/steps/MLMethodAssessmentParams.py @@ -1,8 +1,8 @@ from pathlib import Path from immuneML.data_model.dataset.Dataset import Dataset -from immuneML.environment.Metric import Metric from immuneML.ml_methods.MLMethod import MLMethod +from immuneML.ml_metrics.Metric import Metric from immuneML.workflows.steps.StepParams import StepParams diff --git a/test/dsl/semantic_model/test_semanticModel.py b/test/dsl/semantic_model/test_semanticModel.py index f592926cf..907c5ddee 100644 --- a/test/dsl/semantic_model/test_semanticModel.py +++ b/test/dsl/semantic_model/test_semanticModel.py @@ -10,13 +10,13 @@ from immuneML.environment.Constants import Constants from immuneML.environment.EnvironmentSettings import EnvironmentSettings from immuneML.environment.LabelConfiguration import LabelConfiguration -from immuneML.environment.Metric import Metric from immuneML.hyperparameter_optimization.HPSetting import HPSetting from immuneML.hyperparameter_optimization.config.ReportConfig import ReportConfig from immuneML.hyperparameter_optimization.config.SplitConfig import SplitConfig from immuneML.hyperparameter_optimization.config.SplitType import SplitType from immuneML.hyperparameter_optimization.strategy.GridSearch import GridSearch from immuneML.ml_methods.LogisticRegression import LogisticRegression +from immuneML.ml_metrics.Metric import Metric from immuneML.util.PathBuilder import PathBuilder from immuneML.util.RepertoireBuilder import RepertoireBuilder from immuneML.workflows.instructions.TrainMLModelInstruction import TrainMLModelInstruction diff --git a/test/integration_tests/test_receptorClassification.py b/test/integration_tests/test_receptorClassification.py index 1a1757a30..9594b308f 100644 --- a/test/integration_tests/test_receptorClassification.py +++ b/test/integration_tests/test_receptorClassification.py @@ -10,7 +10,6 @@ from immuneML.environment.Constants import Constants from immuneML.environment.EnvironmentSettings import EnvironmentSettings from immuneML.environment.LabelConfiguration import LabelConfiguration -from immuneML.environment.Metric import Metric from immuneML.environment.SequenceType import SequenceType from immuneML.hyperparameter_optimization.HPSetting import HPSetting from immuneML.hyperparameter_optimization.config.ReportConfig import ReportConfig @@ -18,6 +17,7 @@ from immuneML.hyperparameter_optimization.config.SplitType import SplitType from immuneML.hyperparameter_optimization.strategy.GridSearch import GridSearch from immuneML.ml_methods.LogisticRegression import LogisticRegression +from immuneML.ml_metrics.Metric import Metric from immuneML.simulation.dataset_generation.RandomDatasetGenerator import RandomDatasetGenerator from immuneML.workflows.instructions.TrainMLModelInstruction import TrainMLModelInstruction diff --git a/test/integration_tests/test_sequenceClassification.py b/test/integration_tests/test_sequenceClassification.py index 12c2abe67..5a691efb7 100644 --- a/test/integration_tests/test_sequenceClassification.py +++ b/test/integration_tests/test_sequenceClassification.py @@ -10,7 +10,6 @@ from immuneML.environment.Constants import Constants from immuneML.environment.EnvironmentSettings import EnvironmentSettings from immuneML.environment.LabelConfiguration import LabelConfiguration -from immuneML.environment.Metric import Metric from immuneML.environment.SequenceType import SequenceType from immuneML.hyperparameter_optimization.HPSetting import HPSetting from immuneML.hyperparameter_optimization.config.ReportConfig import ReportConfig @@ -18,6 +17,7 @@ from immuneML.hyperparameter_optimization.config.SplitType import SplitType from immuneML.hyperparameter_optimization.strategy.GridSearch import GridSearch from immuneML.ml_methods.LogisticRegression import LogisticRegression +from immuneML.ml_metrics.Metric import Metric from immuneML.simulation.dataset_generation.RandomDatasetGenerator import RandomDatasetGenerator from immuneML.workflows.instructions.TrainMLModelInstruction import TrainMLModelInstruction diff --git a/test/reports/analysis_reports/test_CVFeaturePerformance.py b/test/reports/analysis_reports/test_CVFeaturePerformance.py index 07ca73cce..e537c31fd 100644 --- a/test/reports/analysis_reports/test_CVFeaturePerformance.py +++ b/test/reports/analysis_reports/test_CVFeaturePerformance.py @@ -7,7 +7,6 @@ from immuneML.environment.EnvironmentSettings import EnvironmentSettings from immuneML.environment.Label import Label from immuneML.environment.LabelConfiguration import LabelConfiguration -from immuneML.environment.Metric import Metric from immuneML.hyperparameter_optimization.HPSetting import HPSetting from immuneML.hyperparameter_optimization.config.SplitConfig import SplitConfig from immuneML.hyperparameter_optimization.config.SplitType import SplitType @@ -18,6 +17,7 @@ from immuneML.hyperparameter_optimization.states.TrainMLModelState import TrainMLModelState from immuneML.hyperparameter_optimization.strategy.GridSearch import GridSearch from immuneML.ml_methods.ProbabilisticBinaryClassifier import ProbabilisticBinaryClassifier +from immuneML.ml_metrics.Metric import Metric from immuneML.reports.ReportResult import ReportResult from immuneML.reports.train_ml_model_reports.CVFeaturePerformance import CVFeaturePerformance diff --git a/test/reports/ml_reports/test_TrainingPerformance.py b/test/reports/ml_reports/test_TrainingPerformance.py index 3d3023dc1..205d17889 100644 --- a/test/reports/ml_reports/test_TrainingPerformance.py +++ b/test/reports/ml_reports/test_TrainingPerformance.py @@ -9,11 +9,11 @@ from immuneML.data_model.encoded_data.EncodedData import EncodedData from immuneML.environment.Constants import Constants from immuneML.environment.EnvironmentSettings import EnvironmentSettings -from immuneML.environment.Metric import Metric from immuneML.ml_methods.LogisticRegression import LogisticRegression from immuneML.reports.ReportResult import ReportResult from immuneML.reports.ml_reports.TrainingPerformance import TrainingPerformance + class TestEvaluation(unittest.TestCase): def setUp(self) -> None: @@ -29,7 +29,6 @@ def _create_dummy_lr_model(self): return dummy_lr, encoded_tr def _create_report(self, path): - report = TrainingPerformance.build_object(name='testcase') report.train_dataset = Dataset() diff --git a/test/reports/ml_reports/test_mLSettingsPerformance.py b/test/reports/ml_reports/test_mLSettingsPerformance.py index 70b80fe14..25ec1ee9e 100644 --- a/test/reports/ml_reports/test_mLSettingsPerformance.py +++ b/test/reports/ml_reports/test_mLSettingsPerformance.py @@ -12,12 +12,12 @@ from immuneML.environment.EnvironmentSettings import EnvironmentSettings from immuneML.environment.Label import Label from immuneML.environment.LabelConfiguration import LabelConfiguration -from immuneML.environment.Metric import Metric from immuneML.hyperparameter_optimization.HPSetting import HPSetting from immuneML.hyperparameter_optimization.config.SplitConfig import SplitConfig from immuneML.hyperparameter_optimization.config.SplitType import SplitType from immuneML.hyperparameter_optimization.strategy.GridSearch import GridSearch from immuneML.ml_methods.LogisticRegression import LogisticRegression +from immuneML.ml_metrics.Metric import Metric from immuneML.reports.ReportResult import ReportResult from immuneML.reports.train_ml_model_reports.MLSettingsPerformance import MLSettingsPerformance from immuneML.util.PathBuilder import PathBuilder diff --git a/test/workflows/instructions/test_HPOptimizationInstruction.py b/test/workflows/instructions/test_HPOptimizationInstruction.py index 42b3cf9ea..7c6f220ec 100644 --- a/test/workflows/instructions/test_HPOptimizationInstruction.py +++ b/test/workflows/instructions/test_HPOptimizationInstruction.py @@ -10,7 +10,6 @@ from immuneML.environment.EnvironmentSettings import EnvironmentSettings from immuneML.environment.Label import Label from immuneML.environment.LabelConfiguration import LabelConfiguration -from immuneML.environment.Metric import Metric from immuneML.hyperparameter_optimization.HPSetting import HPSetting from immuneML.hyperparameter_optimization.config.ReportConfig import ReportConfig from immuneML.hyperparameter_optimization.config.SplitConfig import SplitConfig @@ -19,6 +18,7 @@ from immuneML.hyperparameter_optimization.strategy.GridSearch import GridSearch from immuneML.ml_methods.LogisticRegression import LogisticRegression from immuneML.ml_methods.SVM import SVM +from immuneML.ml_metrics.Metric import Metric from immuneML.preprocessing.filters.ClonesPerRepertoireFilter import ClonesPerRepertoireFilter from immuneML.reports.data_reports.SequenceLengthDistribution import SequenceLengthDistribution from immuneML.util.PathBuilder import PathBuilder diff --git a/test/workflows/steps/test_MLMethodAssessment.py b/test/workflows/steps/test_MLMethodAssessment.py index 6f8e7c173..0d99fe703 100644 --- a/test/workflows/steps/test_MLMethodAssessment.py +++ b/test/workflows/steps/test_MLMethodAssessment.py @@ -11,8 +11,8 @@ from immuneML.environment.Constants import Constants from immuneML.environment.EnvironmentSettings import EnvironmentSettings from immuneML.environment.LabelConfiguration import LabelConfiguration -from immuneML.environment.Metric import Metric from immuneML.ml_methods.LogisticRegression import LogisticRegression +from immuneML.ml_metrics.Metric import Metric from immuneML.util.PathBuilder import PathBuilder from immuneML.util.RepertoireBuilder import RepertoireBuilder from immuneML.workflows.steps.MLMethodAssessment import MLMethodAssessment