-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.py
112 lines (81 loc) · 3.71 KB
/
configuration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
from mlProject.constants import *
from mlProject.utils.common import read_yaml, create_directories
from mlProject.entity.config_entity import (DataIngestionConfig,
DataValidationConfig,
DataTransformationConfig,
ModelTrainerConfig,
ModelEvaluationConfig)
class ConfigurationManager:
def __init__(
self,
config_filepath = CONFIG_FILE_PATH,
params_filepath = PARAMS_FILE_PATH,
schema_filepath = SCHEMA_FILE_PATH):
self.config = read_yaml(config_filepath)
self.params = read_yaml(params_filepath)
self.schema = read_yaml(schema_filepath)
create_directories([self.config.artifacts_root])
def get_data_ingestion_config(self) -> DataIngestionConfig:
config = self.config.data_ingestion
create_directories([config.root_dir])
data_ingestion_config = DataIngestionConfig(
root_dir=config.root_dir,
source_URL=config.source_URL,
local_data_file=config.local_data_file,
unzip_dir=config.unzip_dir
)
return data_ingestion_config
def get_data_validation_config(self) -> DataValidationConfig:
config = self.config.data_validation
schema = self.schema.COLUMNS
create_directories([config.root_dir])
data_validation_config = DataValidationConfig(
root_dir=config.root_dir,
STATUS_FILE=config.STATUS_FILE,
unzip_data_dir = config.unzip_data_dir,
all_schema=schema,
)
return data_validation_config
def get_data_transformation_config(self) -> DataTransformationConfig:
config = self.config.data_transformation
create_directories([config.root_dir])
data_transformation_config = DataTransformationConfig(
root_dir=config.root_dir,
data_path=config.data_path,
)
return data_transformation_config
def get_model_trainer_config(self) -> ModelTrainerConfig:
config = self.config.model_trainer
params = self.params.RandomForestClassifier
schema = self.schema.TARGET_COLUMN
create_directories([config.root_dir])
model_trainer_config = ModelTrainerConfig(
root_dir=config.root_dir,
train_data_path = config.train_data_path,
test_data_path = config.test_data_path,
model_name = config.model_name,
n_estimators = params.n_estimators,
criterion = params.criterion,
max_depth = params.max_depth,
min_samples_split = params.min_samples_split,
min_samples_leaf = params.min_samples_leaf,
bootstrap = params.bootstrap,
ccp_alpha = params.ccp_alpha,
target_column = schema.name
)
return model_trainer_config
def get_model_evaluation_config(self) -> ModelEvaluationConfig:
config = self.config.model_evaluation
params = self.params.RandomForestClassifier
schema = self.schema.TARGET_COLUMN
create_directories([config.root_dir])
model_evaluation_config = ModelEvaluationConfig(
root_dir=config.root_dir,
test_data_path=config.test_data_path,
model_path = config.model_path,
all_params=params,
metric_file_name = config.metric_file_name,
target_column = schema.name,
mlflow_uri="https://dagshub.com/vijayg15/Machine-Learning-project-with-MLflow-deployment.mlflow",
)
return model_evaluation_config