saifhmb
commited on
Applied feature scaling after splitting the dataset
Browse files
app.py
CHANGED
@@ -4,6 +4,8 @@ import numpy as np
|
|
4 |
import matplotlib.pyplot as plt
|
5 |
import pandas as pd
|
6 |
import sklearn
|
|
|
|
|
7 |
from sklearn.compose import ColumnTransformer
|
8 |
from sklearn.model_selection import train_test_split
|
9 |
from sklearn.preprocessing import OneHotEncoder, LabelEncoder, StandardScaler
|
@@ -27,10 +29,8 @@ dataset = dataset.drop(['ID'], axis = 1)
|
|
27 |
y = dataset.iloc[:, -1].values
|
28 |
dataset = dataset.drop(['RISK'], axis = 1)
|
29 |
|
30 |
-
# Encoding the Independent Variables
|
31 |
-
|
32 |
-
from sklearn.compose import make_column_selector
|
33 |
-
ct = make_column_transformer((StandardScaler(),make_column_selector(dtype_include=np.number)),[OneHotEncoder(), make_column_selector(dtype_include=object)], remainder = 'passthrough')
|
34 |
X = ct.fit_transform(dataset)
|
35 |
|
36 |
|
@@ -41,7 +41,10 @@ y = le.fit_transform(y)
|
|
41 |
# Spliting the datset into Training and Test set
|
42 |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.15, random_state = 0)
|
43 |
|
44 |
-
|
|
|
|
|
|
|
45 |
|
46 |
# Training Logit Reg Model using the Training set
|
47 |
model = LogisticRegression()
|
|
|
4 |
import matplotlib.pyplot as plt
|
5 |
import pandas as pd
|
6 |
import sklearn
|
7 |
+
from sklearn.compose import make_column_transformer
|
8 |
+
from sklearn.compose import make_column_selector
|
9 |
from sklearn.compose import ColumnTransformer
|
10 |
from sklearn.model_selection import train_test_split
|
11 |
from sklearn.preprocessing import OneHotEncoder, LabelEncoder, StandardScaler
|
|
|
29 |
y = dataset.iloc[:, -1].values
|
30 |
dataset = dataset.drop(['RISK'], axis = 1)
|
31 |
|
32 |
+
# Encoding the Independent Variables
|
33 |
+
ct = make_column_transformer([OneHotEncoder(), make_column_selector(dtype_include=object)], remainder = 'passthrough')
|
|
|
|
|
34 |
X = ct.fit_transform(dataset)
|
35 |
|
36 |
|
|
|
41 |
# Spliting the datset into Training and Test set
|
42 |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.15, random_state = 0)
|
43 |
|
44 |
+
# Feature Scaling
|
45 |
+
sc = StandardScaler()
|
46 |
+
X_train = sc.fit_transform(X_train)
|
47 |
+
X_test = sc.transform(X_test)
|
48 |
|
49 |
# Training Logit Reg Model using the Training set
|
50 |
model = LogisticRegression()
|