Skip to content

Commit 344c8a8

Browse files
committed
minor PEP8 issues fixed
1 parent 9cbff44 commit 344c8a8

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

09_classification_binary.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
# UCI의 와인 데이터 세트를 사용.
77
# 외부에서 데이터를 불러오고 정제하는 과정.
8-
red = pd.read_csv('http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv', sep=';')
9-
white = pd.read_csv('http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv', sep=';')
10-
#print(red.head())
11-
#print(white.head())
8+
red = pd.read_csv('http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv',
9+
sep=';')
10+
white = pd.read_csv('http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv',
11+
sep=';')
12+
# print(red.head())
13+
# print(white.head())
1214

1315
# 와인이 레드(0)와인인지 화이트(1)와인인지 표시하는 속성('type')을 추가한다.
1416
red['type'] = 0
@@ -23,7 +25,7 @@
2325
# 데이터프레임 wine의 type 속성만 히스토그램으로 출력한다.
2426
# 현재 데이터셋에서는 레드보다 화이트와인이 약 3배 많은 상황.
2527
plt.hist(wine['type'])
26-
plt.xticks([0,1])
28+
plt.xticks([0, 1])
2729
plt.show()
2830
# print(wine['type'].value_counts())
2931

@@ -32,7 +34,7 @@
3234
# 현재 모두 non-null이고, float64거나 int64이므로 정규화 진행 가능하다.
3335
# print(wine.info())
3436

35-
wine_norm = ( wine - wine.min() ) / ( wine.max() - wine.min() )
37+
wine_norm = (wine - wine.min()) / (wine.max() - wine.min())
3638
# print(wine_norm.head())
3739
# print(wine_norm.describe()) # 속성들의 min값이 0, max값이 1이므로 정규화가 잘 진행되었다.
3840

@@ -47,7 +49,7 @@
4749
# print(wine_np[:5])
4850

4951
# 데이터 셋의 80%를 학습 데이터로, 20%를 테스트 데이터로 분할하는 과정.
50-
train_idx = int(len(wine_np)*0.8) # 데이터셋을 나눌 구분점이 되는 인덱스. 데이터셋의 80% 지점.
52+
train_idx = int(len(wine_np)*0.8) # 데이터셋을 나눌 구분점이 되는 인덱스. 데이터셋의 80% 지점.
5153
train_X, train_Y = wine_np[:train_idx, :-1], wine_np[:train_idx, -1]
5254
# 구분점까지의 모든 IV들 (마지막 한칸을 제외한 전부)은 X에, 구분점까지의 모든 DV들 (마지막 한 칸)은 Y에 저장.
5355
test_X, test_Y = wine_np[train_idx:, :-1], wine_np[train_idx:, -1]
@@ -100,17 +102,17 @@
100102

101103
history = model.fit(train_X, train_Y, epochs=25, batch_size=32, validation_split=0.25)
102104

103-
plt.figure(figsize=(12,4))
104-
plt.subplot(1,2,1)
105+
plt.figure(figsize=(12, 4))
106+
plt.subplot(1, 2, 1)
105107
plt.plot(history.history['loss'], 'b-', label='loss')
106108
plt.plot(history.history['val_loss'], 'r--', label='val_loss')
107109
plt.xlabel('Epoch')
108110
plt.legend()
109111

110-
plt.subplot(1,2,2)
112+
plt.subplot(1, 2, 2)
111113
plt.plot(history.history['accuracy'], 'g--', label='accuracy')
112114
plt.plot(history.history['val_accuracy'], 'k--', label='val_accuracy')
113115
plt.xlabel('Epoch')
114116
plt.legend()
115117

116-
plt.show()
118+
plt.show()

0 commit comments

Comments
 (0)