Spaces:
Sleeping
Sleeping
singhjagpreet
commited on
Commit
·
eb2eadc
1
Parent(s):
ee66e58
data ingestion
Browse files
.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
venv/
|
|
|
|
1 |
+
venv/
|
2 |
+
artifacts/
|
logs/09_08_2023_20_06_15.log/09_08_2023_20_06_15.log
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
[ 2023-09-08 20:06:18,654 ] 22 root - INFO - Entered the data ingestion method or component
|
2 |
+
[ 2023-09-08 20:06:18,658 ] 25 root - INFO - read the dataset as dataframe
|
3 |
+
[ 2023-09-08 20:06:18,662 ] 34 root - INFO - Train test split initiated
|
logs/09_08_2023_20_10_02.log/09_08_2023_20_10_02.log
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
[ 2023-09-08 20:10:03,099 ] 22 root - INFO - Entered the data ingestion method or component
|
2 |
+
[ 2023-09-08 20:10:03,102 ] 25 root - INFO - read the dataset as dataframe
|
3 |
+
[ 2023-09-08 20:10:03,104 ] 34 root - INFO - Train test split initiated
|
logs/09_08_2023_20_11_36.log/09_08_2023_20_11_36.log
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[ 2023-09-08 20:11:36,808 ] 22 root - INFO - Entered the data ingestion method or component
|
2 |
+
[ 2023-09-08 20:11:36,812 ] 25 root - INFO - read the dataset as dataframe
|
3 |
+
[ 2023-09-08 20:11:36,814 ] 34 root - INFO - Train test split initiated
|
4 |
+
[ 2023-09-08 20:11:36,817 ] 41 root - INFO - ingestion of data completed
|
src/__pycache__/exception.cpython-310.pyc
ADDED
Binary file (1.27 kB). View file
|
|
src/components/data_ingestion.py
CHANGED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
from src.exception import CustomException
|
4 |
+
from src.logger import logging
|
5 |
+
|
6 |
+
import pandas as pd
|
7 |
+
from sklearn.model_selection import train_test_split
|
8 |
+
from dataclasses import dataclass
|
9 |
+
|
10 |
+
@dataclass
|
11 |
+
class DataIngestionConfig:
|
12 |
+
train_data_path: str=os.path.join('artifacts','train.csv')
|
13 |
+
test_data_path: str = os.path.join('artifacts','test.csv')
|
14 |
+
raw_data_path: str = os.path.join('artifacts','data.csv')
|
15 |
+
|
16 |
+
|
17 |
+
class DataIngestion:
|
18 |
+
def __init__(self):
|
19 |
+
self.ingestion_config = DataIngestionConfig()
|
20 |
+
|
21 |
+
def intiate_data_ingestion(self):
|
22 |
+
logging.info("Entered the data ingestion method or component")
|
23 |
+
try:
|
24 |
+
df=pd.read_csv('notebook/data/stud.csv')
|
25 |
+
logging.info('read the dataset as dataframe')
|
26 |
+
|
27 |
+
## make dir
|
28 |
+
os.makedirs(os.path.dirname(self.ingestion_config.train_data_path),exist_ok=True)
|
29 |
+
|
30 |
+
## save raw data
|
31 |
+
df.to_csv(self.ingestion_config.raw_data_path,index=False,header=True)
|
32 |
+
|
33 |
+
## train test split
|
34 |
+
logging.info('Train test split initiated')
|
35 |
+
train_set, test_set = train_test_split(df, test_size=0.2, random_state=42)
|
36 |
+
|
37 |
+
train_set.to_csv(self.ingestion_config.train_data_path,index=False,header=True)
|
38 |
+
|
39 |
+
test_set.to_csv(self.ingestion_config.test_data_path,index=False, header=True)
|
40 |
+
|
41 |
+
logging.info("ingestion of data completed")
|
42 |
+
|
43 |
+
return (
|
44 |
+
self.ingestion_config.train_data_path,
|
45 |
+
self.ingestion_config.test_data_path,
|
46 |
+
)
|
47 |
+
except Exception as e:
|
48 |
+
raise CustomException(e,sys)
|
49 |
+
|
50 |
+
if __name__ == '__main__':
|
51 |
+
obj=DataIngestion()
|
52 |
+
obj.intiate_data_ingestion()
|