I didn't watch much today, but I learned how to fit and predict models that contains non-numerical data in dependent variables.
One new thing that I found out before I dig in:
(Okay, assuming that I've already imported tensorflow and pandas,)
in the data section, let's compare the following two codes:
파일경로 = 'https://raw.githubusercontent.com/blackdew/tensorflow1/master/csv/iris.csv'
아이리스 = pd.read_csv(파일경로)
아이리스.head()
아이리스 = pd.read_csv('https://raw.githubusercontent.com/blackdew/tensorflow1/master/csv/iris.csv')
아이리스.head()
-> I reduced two lines into one line. Why bother separating!
아이리스 = pd.read_csv(’iris.csv’)
아이리스.head()
Onehot-encoding (used to switch categorical data into numerical data)
엔코딩 = pd.get_dummies(아이리스)
엔코딩.head()
print(엔코딩.columns)
독립 = 아이리스[['꽃잎길이', '꽃잎폭', '꽃받침길이', '꽃받침폭']]
종속 = 아이리스[['품종']]
print(독립.shape, 종속.shape)
X = tf.keras.layers.Input(shape=[4])
Y = tf.keras.layers.Dense(3, activation='softmax')(X)
model = tf.keras.models.Model(X, Y)
model.compile(loss='categorical_crossentropy',
metrics='accuracy')
model.fit(독립, 종속, epochs=100, verbose=0)
model.fit(독립, 종속, epochs=10)
model.predict(독립[0:5])
print(종속[0:5])
model.predict(독립[-5:])
print(종속[-5:])
model.get_weights()