new file: checkpoints_tree/task1_tr_tree/model_selection.csv new file: evaluation_outputs/task1_tr_tree/evaluation_train_all_samples.csv new file: evaluation_outputs/task1_tr_tree/evaluation_train_curve.png new file: evaluation_outputs/task1_tr_tree/evaluation_val_all_samples.csv new file: evaluation_outputs/task1_tr_tree/evaluation_val_curve.png new file: evaluation_outputs/task1_tr_tree/harmonic_5mm_1.55Hz_prediction.png new file: scripts_tree/__pycache__/config.cpython-310.pyc new file: scripts_tree/config.py new file: scripts_tree/evaluate.py new file: scripts_tree/predict_single.py new file: scripts_tree/train.py
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
|
if str(PROJECT_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
|
|
|
from scripts.config import CORE_FEATURE_NAMES, DataConfig
|
|
|
|
|
|
@dataclass
|
|
class TreeModelConfig:
|
|
candidate_models: tuple[str, ...] = ("extra_trees", "random_forest", "gradient_boosting")
|
|
random_state: int = 42
|
|
|
|
|
|
@dataclass
|
|
class TrainConfig:
|
|
checkpoint_dir: str = "checkpoints_tree"
|
|
summary_name: str = "model_selection.csv"
|
|
best_model_name: str = "best_tr_tree.pkl"
|
|
|
|
|
|
@dataclass
|
|
class ExperimentConfig:
|
|
data: DataConfig = field(default_factory=DataConfig)
|
|
model: TreeModelConfig = field(default_factory=TreeModelConfig)
|
|
train: TrainConfig = field(default_factory=TrainConfig)
|
|
|
|
|
|
def make_experiment_config() -> ExperimentConfig:
|
|
return ExperimentConfig()
|
|
|
|
|
|
def checkpoint_dir(config: ExperimentConfig) -> Path:
|
|
path = config.data.project_root / config.train.checkpoint_dir / "task1_tr_tree"
|
|
path.mkdir(parents=True, exist_ok=True)
|
|
return path
|
|
|
|
|
|
def evaluation_dir(config: ExperimentConfig) -> Path:
|
|
path = config.data.project_root / "evaluation_outputs" / "task1_tr_tree"
|
|
path.mkdir(parents=True, exist_ok=True)
|
|
return path
|
|
|
|
|
|
FEATURE_NAMES = CORE_FEATURE_NAMES
|