-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataPrep.py
53 lines (33 loc) · 966 Bytes
/
dataPrep.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
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
"""
Import the required Libraries Numpy, Matplotlib and pandas.
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
"""
Import a Dataset
Returns a Dependent and independent Matrix.
"""
dataset = pd.read_csv("Data.csv")
feature_matrix = dataset.iloc[:,:-1].values #Feature Matrix
print (feature_matrix)
dependent_matrix = dataset.iloc[:,-1].values #Dependent Matrix
#print (y)
print ('#####################################################################')
"""
Taking are of missing data.
Returns Feature Matrix without missing data.
Missing data is filled by getting the average of all the other data
"""
from sklearn.impute import SimpleImputer
imputer = SimpleImputer(missing_values=np.nan, strategy='mean')
imputer.fit(feature_matrix[:, 1:3])
feature_matrix[:, 1:3] = imputer.transform(feature_matrix[:, 1:3])
print (feature_matrix)
"""
"""