-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_proc.py
More file actions
56 lines (42 loc) · 1.47 KB
/
data_proc.py
File metadata and controls
56 lines (42 loc) · 1.47 KB
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
import os
import numpy as np
import matplotlib.pyplot as plt
import cv2
# Accessing My Google Drive
## Import required libraries
import pandas as pd
## Upload dataset
from google.colab import files
uploaded =files.upload()
Choose Files no files selected Upload widget is only available when the cellhas been
executed in the current browser session. Please rerun this cell to enable.
Saving COVID_DATA5.csv to COVID_DATA5.csv
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
Dataset = pd.read_csv("COVID_DATA5.csv")
# importing an array of features
x = Dataset.iloc[:, :-1].values
# importing an array of dependent variable
y = Dataset.iloc[:, -1].values
print(x) # returns an array of features
print(y)
Dataset['Total'].fillna(Dataset['Total'].mean())
#Dataset['Total'].fillna(0)
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
ct = ColumnTransformer(transformers=[('encoder', OneHotEncoder(), [0])],
remainder=’passthrough’)
x = np.array(ct.fit_transform(x))
print(x)
fom sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size =0.3,random_state=1)
print(x_train)
print(x_test)
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
# we only aply the feature scaling on the features other than dummy variables.
x_train[:, 3:] = sc.fit_transform(x_train[:, 3:])
x_test[:, 3:] = sc.fit_transform(x_test[:, 3:])
print(x_train)
print(x_test)