<jupyter_start><jupyter_text>교육단계<jupyter_code>from sklearn.model_selection import train_test_split
x_train, x_val, y_train, y_val = train_test_split(x_data, y_data)
import tensorflow as tf
model = tf.keras.Sequential()

model.add(tf.keras.Input(shape=(4,)))     # input layer
model.add(tf.keras.layers.Dense(64, activation='relu'))     # hidden layer
model.add(tf.keras.layers.Dense(24, activation='relu'))     # hidden layer

model.add(tf.keras.layers.Dense(3, activation='softmax'))     # output layer

model.compile(optimizer='adam', loss = 'sparse_categorical_crossentropy', metrics = ['acc'])     # gadget

model.summary()
# model.fit(x_data, y_data, epochs = 50, validation_split = 0.3)   # 학습
model.fit(x_train, y_train, epochs=50, validation_data=(x_val,y_val)) # 학습<jupyter_output>Epoch 1/50
4/4 [==============================] - 1s 105ms/step - loss: 1.5087 - acc: 0.3482 - val_loss: 1.3750 - val_acc: 0.2895
Epoch 2/50
4/4 [==============================] - 0s 11ms/step - loss: 1.3087 - acc: 0.3482 - val_loss: 1.2283 - val_acc: 0.2895
Epoch 3/50
4/4 [==============================] - 0s 10ms/step - loss: 1.1532 - acc: 0.3482 - val_loss: 1.1158 - val_acc: 0.2895
Epoch 4/50
4/4 [==============================] - 0s 9ms/step - loss: 1.0374 - acc: 0.3482 - val_loss: 1.0416 - val_acc: 0.2895
Epoch 5/50
4/4 [==============================] - 0s 8ms/step - loss: 0.9559 - acc: 0.5268 - val_loss: 0.9828 - val_acc: 0.3947
Epoch 6/50
4/4 [==============================] - 0s 10ms/step - loss: 0.9104 - acc: 0.4464 - val_loss: 0.9457 - val_acc: 0.2632
Epoch 7/50
4/4 [==============================] - 0s 9ms/step - loss: 0.8856 - acc: 0.3750 - val_loss: 0.9018 - val_acc: 0.6316
Epoch 8/50
4/4 [==============================] - 0s 10ms/step - loss: 0.8496 - acc: 0.6071 - val_l[...]<jupyter_text>evaluation<jupyter_code># model.evaluate(x_data, y_data) # - loss: 0.7512 - acc: 0.6667
model.evaluate(x_data, y_data)
from sklearn.metrics import classification_report, confusion_matrix
y_pred = model.predict(x_data)
y_pred.shape, y_pred[4]
import numpy as np
y_pred_argmax = np.argmax(y_pred, axis=1)
y_pred_argmax.shape, y_pred_argmax[4]
y_data.shape, y_data[4]
print(classification_report(y_data, y_pred_argmax))
confusion_matrix(y_data, y_pred_argmax)
import seaborn as sns
sns.heatmap(confusion_matrix(y_data, y_pred_argmax), annot=True)<jupyter_output><empty_output><jupyter_text>서비스 단계<jupyter_code>x_data[25], y_data[25]
pred = model.predict([[5. , 3. , 1.6, 0.2]])
pred
import numpy as np
np.argmax(pred)
y_pred = model.predict(x_data)
y_pred.shape<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.23056197074672824, 'fraction_numerical': 0.09545804464973057, 'mean_word_length': 4.893424036281179, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '164658', 'license': 'Apache-2.0', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1058, 'n_words': 205, 'path': 'iris_classification.ipynb', 'repo_name': 'webdessin/test_deeplearning', 'size': '2598'}