-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreprocessing.py
More file actions
80 lines (41 loc) · 1.39 KB
/
preprocessing.py
File metadata and controls
80 lines (41 loc) · 1.39 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 10 10:00:43 2019
@author: sohel
"""
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder,OneHotEncoder
class scaler(object):
def __init__(self):
pass
def scalling(self,x):
sc=MinMaxScaler(feature_range=(0,1))
scaled_data=sc.fit_transform(x)
return(scaled_data)
def __del__(self):
pass
class splitter(object):
def __init__(self):
pass
def decomposition(self,x,y,test_size=0.25,random_state=0):
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=test_size,random_state=random_state)
return(x_train,x_test,y_train,y_test)
def __del__(self):
pass
class Encoder(object):
def __init__(self):
pass
def labelEncoding(self,x):
le=LabelEncoder()
x=le.fit_transform(x)
return(x)
def one_hot_encoder(self,y,cf):
ohe=OneHotEncoder(categorical_features=[cf])
ohe=OneHotEncoder(categorical_features=cf)
y=ohe.fit_transform(y).toarray()
return(y)
def __del__(self):
pass