Spaces:
Runtime error
Runtime error
Download src/mlProject/components/data_transformation.py from RasoulSahibzadah/Machine-Learning-MLflow: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/spaces/RasoulSahibzadah/Machine-Learning-MLflow/resolve/main/src/mlProject/components/data_transformation.py
- Command line
-
hf download hf://spaces/RasoulSahibzadah/Machine-Learning-MLflow/src/mlProject/components/data_transformation.py
-
curl -L -o data_transformation.py https://huggingface.co/spaces/RasoulSahibzadah/Machine-Learning-MLflow/resolve/main/src/mlProject/components/data_transformation.py
1.17 kB
| import os | |
| from mlProject import logger | |
| from sklearn.model_selection import train_test_split | |
| import pandas as pd | |
| from mlProject.entity.config_entity import DataTransformationConfig | |
| class DataTransformation: | |
| def __init__(self, config: DataTransformationConfig): | |
| self.config = config | |
| ## Note: You can add different data transformation techniques such as Scaler, PCA and all | |
| #You can perform all kinds of EDA in ML cycle here before passing this data to the model | |
| # I am only adding train_test_spliting cz this data is already cleaned up | |
| def train_test_spliting(self): | |
| data = pd.read_csv(self.config.data_path) | |
| # Split the data into training and test sets. (0.75, 0.25) split. | |
| train, test = train_test_split(data) | |
| train.to_csv(os.path.join(self.config.root_dir, "train.csv"),index = False) | |
| test.to_csv(os.path.join(self.config.root_dir, "test.csv"),index = False) | |
| logger.info("Splited data into training and test sets") | |
| logger.info(train.shape) | |
| logger.info(test.shape) | |
| print(train.shape) | |
| print(test.shape) | |