
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
!git clone https://github.com/taehojo/data.git
df = pd.read_csv('./data/iris3.csv')
import seaborn as sns
import matplotlib.pyplot as plt
sns.pairplot(df, hue='species') # 상관도 그래프 출력. hue 옵션에는 어떤 카테고리를 중심으로 그래프를 그릴 지를 넣어주면 됨.
plt.show()
get_dummies() 함수로 간단히 처리 가능
# dividing data into X, y
X = df.iloc[:, 0:4]
y = df.iloc[:, 4] # the type is str: we need to change it into numbers
# One-Hot encoding
y = pd.get_dummies(y)
print(y[0:5])

# 모델 설정
model = Sequential()
model.add(Dense(12, input_dim = 4, activation = 'relu'))
model.add(Dense(8, activation = 'relu'))
model.add(Dense(1, activation = 'softmax'))
#model.summary() # 층과 층간의 연결을 시각화
# 모델 컴파일
model.compile(loss = 'categorical_crossentropy', optimizer = 'adam', metrics = ['accuracy'])
history = model.fit(X, y, epochs=50, batch_size = 5)
< 피마 인디언 모델과의 차이점 >
model.summary()
