{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":77476,"databundleVersionId":8462666,"sourceType":"competition"}],"dockerImageVersionId":30698,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-05-14T15:58:30.900111Z","iopub.execute_input":"2024-05-14T15:58:30.900691Z","iopub.status.idle":"2024-05-14T15:58:30.914901Z","shell.execute_reply.started":"2024-05-14T15:58:30.900644Z","shell.execute_reply":"2024-05-14T15:58:30.913713Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport tensorflow as tf\nfrom tensorflow import keras\nfrom sklearn.decomposition import PCA\nimport matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:30.917486Z","iopub.execute_input":"2024-05-14T15:58:30.918352Z","iopub.status.idle":"2024-05-14T15:58:30.925116Z","shell.execute_reply.started":"2024-05-14T15:58:30.918306Z","shell.execute_reply":"2024-05-14T15:58:30.923789Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.read_csv('/kaggle/input/2024-smarcle-ks-3-fashion-mnist2/train.csv')\ndf_test = pd.read_csv('/kaggle/input/2024-smarcle-ks-3-fashion-mnist2/test.csv')","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:30.926992Z","iopub.execute_input":"2024-05-14T15:58:30.927499Z","iopub.status.idle":"2024-05-14T15:58:37.343358Z","shell.execute_reply.started":"2024-05-14T15:58:30.927455Z","shell.execute_reply":"2024-05-14T15:58:37.342172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"0 : T-shirt/top\n1 : Trouser\n2 : Pullover\n3 : Dress\n4 : Coat\n5 : Sandal\n6 : Shirt\n7 : Sneaker\n8 : Bag\n9 : Ankel boot","metadata":{}},{"cell_type":"code","source":"df_train.head()","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:37.345984Z","iopub.execute_input":"2024-05-14T15:58:37.346330Z","iopub.status.idle":"2024-05-14T15:58:37.367440Z","shell.execute_reply.started":"2024-05-14T15:58:37.346301Z","shell.execute_reply":"2024-05-14T15:58:37.366088Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test.head()","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:37.369164Z","iopub.execute_input":"2024-05-14T15:58:37.369687Z","iopub.status.idle":"2024-05-14T15:58:37.393243Z","shell.execute_reply.started":"2024-05-14T15:58:37.369644Z","shell.execute_reply":"2024-05-14T15:58:37.391707Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df_train.shape)\nprint(df_test.shape)","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:37.394670Z","iopub.execute_input":"2024-05-14T15:58:37.395108Z","iopub.status.idle":"2024-05-14T15:58:37.405874Z","shell.execute_reply.started":"2024-05-14T15:58:37.395071Z","shell.execute_reply":"2024-05-14T15:58:37.404917Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**훈련 데이터셋은 60000개 인데 column 수는 785이고**\n\n**테스트 데이터셋은 10000개 인데 column 수는 784이다.**\n\n**위에 데이터 프레임을 자세히 보니 훈련 데이터셋에는 label이 붙어있다.**","metadata":{}},{"cell_type":"markdown","source":"**<결측값을 확인>**","metadata":{}},{"cell_type":"code","source":"# 결측값 확인\nmissing_values_train = df_train.isna().sum()\nmissing_values_test = df_test.isna().sum()\n\nprint(missing_values_train)\nprint(missing_values_test)","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:37.406952Z","iopub.execute_input":"2024-05-14T15:58:37.407281Z","iopub.status.idle":"2024-05-14T15:58:37.468494Z","shell.execute_reply.started":"2024-05-14T15:58:37.407253Z","shell.execute_reply":"2024-05-14T15:58:37.467276Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"위와 같이 하면 중간에 있을 수도 있으니 info로 확인한다.","metadata":{}},{"cell_type":"code","source":"print(df_train.info())\nprint(df_test.info())","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:37.470326Z","iopub.execute_input":"2024-05-14T15:58:37.470762Z","iopub.status.idle":"2024-05-14T15:58:37.563008Z","shell.execute_reply.started":"2024-05-14T15:58:37.470722Z","shell.execute_reply":"2024-05-14T15:58:37.561727Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":" 열의 항목 수가 행 수와 일치하므로 결측값은 없다.","metadata":{}},{"cell_type":"markdown","source":"**생각해보니 이미지는 모든게 픽셀로 이루어졌으니 결측값이 없는 게 당연한 거 같다.\nGPT에게 물어보니 이렇게 답변해주었다. 하나 알아갔다. 야호**\n\n일반적으로 이미지 데이터는 결측값이 없다. 왜냐하면 보통 각 픽셀이 숫자로 표현되기 때문이다. ","metadata":{}},{"cell_type":"markdown","source":"# 데이터 분리(Seperating Data)","metadata":{}},{"cell_type":"markdown","source":"**모델을 돌릴 때 훈련 데이터셋에 대한 정답으로 label이 있는 것이다. 즉, 지도학습이라는 이야기이다.**\n\n**나중에 모델에 테스트 데이터를 넣고 이에 대한 테스트 라벨을 예측하여 csv 파일 즉, 정답 예측 파일을 만드는 것이 우리의 목표이다.**\n\n**그러므로 우리는 2가지 작업을 해야한다.**\n\n1. 우선 테스트 데이터에 대한 라벨을 생성해야 하고\n\n2. 훈련 데이터 셋을 픽셀만 존재하는 데이터와 정답이 있는 라벨 데이터로 분리해야 한다.","metadata":{}},{"cell_type":"code","source":"# 우선 훈련 데이터에서 라벨을 때고 이미지만 존재하는 코드를 df_train_images라고 이름지은 변수에 저장하기\ndf_train_images = df_train.drop(columns=[\"label\"])\n\n# 훈련 데이터의 정답이 되는 라벨을 따로 df_train_label이라고 이름지은 변수에 저장하기\ndf_train_label = df_train[\"label\"]\n\n#테스트 데이터의 'label' column을 생성하고 우선 None으로 비워두기\ndf_test[\"label\"] =  0\n\n# 테스트 데이터의 이미지는 원래 테스트 데이터 값으로 저장하기\ndf_test_images = df_test.drop(columns=[\"label\"])\n\n#테스트 데이터의 라벨 열만 있는 것을 df_test_label이라고 이름지은 변수에 저장하기\ndf_test_label = df_test[\"label\"]","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:37.564745Z","iopub.execute_input":"2024-05-14T15:58:37.565123Z","iopub.status.idle":"2024-05-14T15:58:37.759561Z","shell.execute_reply.started":"2024-05-14T15:58:37.565092Z","shell.execute_reply":"2024-05-14T15:58:37.758437Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df_train_images.shape)\nprint(df_train_label.shape)\nprint(df_test_images.shape)\nprint(df_test_label.shape)","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:37.765758Z","iopub.execute_input":"2024-05-14T15:58:37.766857Z","iopub.status.idle":"2024-05-14T15:58:37.773166Z","shell.execute_reply.started":"2024-05-14T15:58:37.766814Z","shell.execute_reply":"2024-05-14T15:58:37.771916Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**<데이터 정리>**\n\ndf_train_images : 60000개, 28x28형태의 이미지 데이터\ndf_train_label : 60000개의 라벨이 0~9사이의 정수로 있음\n\ndf_test_images : 10000개, 28x28형태의 이미지 데이터\ndf_test_label : 10000개의 라벨이 0~9사이의 정수로 있음","metadata":{}},{"cell_type":"markdown","source":"# Data processing","metadata":{}},{"cell_type":"markdown","source":"**다른 코드들을 보니 데이터 전처리를 할 때 첫 번째 이미지를 보면 픽셀 값의 범위를 알아낸다.**\n**그것은 바로 0~1사이로 스케일링 하기 위함이다.**\n\n**보통 figure함수를 쓰고 imshow함수를 이용하여 이미지를 띄우는데 나는 오류가 났다.**\n\n**찾아보니 imshow함수는 matplotlib의 시각화 도구 함수인데 이들은 넘파이 배열에서 효율적으로 사용될 수 있다.**\n\n**판다스 데이터프레임은 주로 테이블 형식의 데이터를 다루는 데 사용되어**\n**판다스 데이터 타입에 imshow를 직접적으로는 사용할 수 없다고 한다.**","metadata":{}},{"cell_type":"code","source":"# 데이터 타입 확인\nprint(\"데이터 타입:\", type(df_train))\nprint(\"데이터 타입:\", type(df_test))","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:37.774826Z","iopub.execute_input":"2024-05-14T15:58:37.775299Z","iopub.status.idle":"2024-05-14T15:58:37.787807Z","shell.execute_reply.started":"2024-05-14T15:58:37.775258Z","shell.execute_reply":"2024-05-14T15:58:37.786616Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"역시나 numpy형태가 아니었다. 그러므로 우리는 이를 넘파이 형태로 바꾸어 주도록 하자. \n\n혹시 모르니 원래 데이터는 그대로 두고 분리 시켜둔 데이터들만 우선 바꿔둔다.","metadata":{}},{"cell_type":"code","source":"df_train_images= np.array(df_train_images, dtype = 'float32')\n\ndf_test_images = np.array(df_test_images, dtype='float32')\n# 우선 라벨은 그냥 두자!","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:37.789009Z","iopub.execute_input":"2024-05-14T15:58:37.789336Z","iopub.status.idle":"2024-05-14T15:58:38.016986Z","shell.execute_reply.started":"2024-05-14T15:58:37.789309Z","shell.execute_reply":"2024-05-14T15:58:38.015735Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**여기서 드는 의문점**\n\npandas형태의 데이터 프레임을 numpy배열로 바꾸는 건 알겠다. 근데 **왜 dtype을 원래 int 64 형태에서 float32로 바꾸는가?**\n\nGPT 답 : 이미지 데이터를 신경망 모델에 입력으로 사용할 때 부동 소수점 형식(float)으로 변환하는 것이 유용할 수 있습니다.\n\n신경망 모델의 입력으로 사용되는 이미지 데이터는 일반적으로 0과 1 사이의 값을 가져야 합니다.\n\n따라서 정수형으로 저장된 이미지 데이터를 0과 1 사이의 부동 소수점으로 정규화(normalize)하여 사용하는 것이 일반적입니다.\n\n이 때 데이터 타입은 일반적으로 float32로 변환된다. \n\n\n**즉,이미지 데이터는 신경망 모델에 입력할 때 float형으로 입력해야하고, 이를 위해 int형 데이터를 float32로 변환한다.**\n","metadata":{}},{"cell_type":"code","source":"print(df_train_images.shape)\nprint(df_train_label.shape)\nprint(df_test_images.shape)\nprint(df_test_label.shape)","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:38.018563Z","iopub.execute_input":"2024-05-14T15:58:38.019467Z","iopub.status.idle":"2024-05-14T15:58:38.026569Z","shell.execute_reply.started":"2024-05-14T15:58:38.019415Z","shell.execute_reply":"2024-05-14T15:58:38.025383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**이제 df_train_images의 첫번째 이미지를 출력해보자!**","metadata":{}},{"cell_type":"markdown","source":"아악,, 무작정 **plt.imshow(df_train_images[0])**이 코드를 썼더니 **TypeError: Invalid shape (784,) for image data 가 떴다.**\n\n원일을 찾아보니 **imshow는 2차원 이미지를 다루는데** 내가 **제공한 이미지 데이터의 형태는 (784,)로 1차원 벡터**이다. \n\n따라서**reshape함수를 써서 2차원 데이터 형태인 28X28로 바꾼다.**","metadata":{}},{"cell_type":"code","source":"df_train_images=df_train_images.reshape((-1,28,28)) #-1을 사용하여 첫 번째 차원의 크기를 자동으로 결정\ndf_test_images=df_test_images.reshape((-1,28,28)) ","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:38.028077Z","iopub.execute_input":"2024-05-14T15:58:38.028477Z","iopub.status.idle":"2024-05-14T15:58:38.038010Z","shell.execute_reply.started":"2024-05-14T15:58:38.028447Z","shell.execute_reply":"2024-05-14T15:58:38.036696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"넘파이 배열 형태로 잘 바뀌었는지 그리고 28x28로 잘 바뀌었는지 확인하기 위해 0번째 데이터 이미지 출력","metadata":{}},{"cell_type":"code","source":"plt.imshow(df_train_images[0])","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:38.039892Z","iopub.execute_input":"2024-05-14T15:58:38.040351Z","iopub.status.idle":"2024-05-14T15:58:38.336686Z","shell.execute_reply.started":"2024-05-14T15:58:38.040315Z","shell.execute_reply":"2024-05-14T15:58:38.335410Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 이미지 데이터의 최솟값과 최댓값 확인\nmin_pixel_value = np.min(df_train_images)\nmax_pixel_value = np.max(df_train_images)\n\nprint(\"최솟값:\", min_pixel_value)\nprint(\"최댓값:\", max_pixel_value)","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:38.338366Z","iopub.execute_input":"2024-05-14T15:58:38.338741Z","iopub.status.idle":"2024-05-14T15:58:38.386431Z","shell.execute_reply.started":"2024-05-14T15:58:38.338711Z","shell.execute_reply":"2024-05-14T15:58:38.385414Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**최솟값이 0이고 최댓값이 255이므로 픽셀 값의 범위가 0~255 사이라는 것을 알 수 있음!!**","metadata":{}},{"cell_type":"markdown","source":"넘파이로 바꿨고 픽셀 값의 범위도 알았으니 한 번 이미지 데이터를 36개 정도 뽑아보자!\n\n코드는 6x6 그리드에 36개의 이미지를 표시하는 작업!!","metadata":{}},{"cell_type":"code","source":"class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',\n               'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']\n\nplt.figure(figsize=(10, 10)) # 가로와 세로가 각각 10인치\nfor i in range(36): \n    plt.subplot(6, 6, i + 1)\n    plt.xticks([]) #x,y 눈금 제거\n    plt.yticks([]) \n    plt.grid(False) # 배경에 grid 표기 x _ True로 해도 안 보여서 상관은 없음\n    plt.imshow(df_train_images[i]) #df_train_images의 i번째 데이터 보이기\n    label_index = df_train_label[i] \n    \n    # 문자형인 라벨이름과 숫자를 함께 title로 쓰기 위해 정수형인 라벨 인덱스를 문자형으로 변환함\n    title = class_names[label_index] + \" (\" + str(label_index) + \")\"  \n    plt.title(title)\nplt.show()\n\n#cf :그리드(grid)는 그림이나 차트의 배경에 그려지는 수평선과 수직선의 집합","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:38.387915Z","iopub.execute_input":"2024-05-14T15:58:38.388672Z","iopub.status.idle":"2024-05-14T15:58:40.330448Z","shell.execute_reply.started":"2024-05-14T15:58:38.388634Z","shell.execute_reply":"2024-05-14T15:58:40.329043Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"모델에 넣기 위해 데이터의 범위를 0~1로 바꾸주는 rescaling작업을 한다.","metadata":{}},{"cell_type":"code","source":"df_train_images = df_train_images / 255.0\n\ndf_test_images = df_test_images / 255.0","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:40.332288Z","iopub.execute_input":"2024-05-14T15:58:40.333227Z","iopub.status.idle":"2024-05-14T15:58:40.408278Z","shell.execute_reply.started":"2024-05-14T15:58:40.333182Z","shell.execute_reply":"2024-05-14T15:58:40.406979Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Modeling","metadata":{}},{"cell_type":"code","source":"model = keras.Sequential([\n    keras.layers.Flatten(input_shape=(28, 28)),\n    keras.layers.Dense(128, activation='relu'),\n    keras.layers.Dense(10, activation='softmax')\n])","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:40.409664Z","iopub.execute_input":"2024-05-14T15:58:40.410022Z","iopub.status.idle":"2024-05-14T15:58:40.443054Z","shell.execute_reply.started":"2024-05-14T15:58:40.409992Z","shell.execute_reply":"2024-05-14T15:58:40.442070Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"모델 컴파일","metadata":{}},{"cell_type":"code","source":"model.compile(optimizer='adam',\n              loss='sparse_categorical_crossentropy',\n              metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:40.444410Z","iopub.execute_input":"2024-05-14T15:58:40.444744Z","iopub.status.idle":"2024-05-14T15:58:40.455914Z","shell.execute_reply.started":"2024-05-14T15:58:40.444715Z","shell.execute_reply":"2024-05-14T15:58:40.454636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"train데이터로 모델 훈련시키기","metadata":{}},{"cell_type":"code","source":"model.fit(df_train_images, df_train_label, epochs=5)","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:58:40.457721Z","iopub.execute_input":"2024-05-14T15:58:40.458985Z","iopub.status.idle":"2024-05-14T15:59:17.872133Z","shell.execute_reply.started":"2024-05-14T15:58:40.458925Z","shell.execute_reply":"2024-05-14T15:59:17.871052Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"정확도는 약 0.89","metadata":{}},{"cell_type":"markdown","source":"test데이터로 모델의 정확도 평가","metadata":{}},{"cell_type":"code","source":"test_loss, test_acc = model.evaluate(df_test_images, df_test_label, verbose=2)\n\nprint('\\n 정확도:', test_acc)","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:59:17.873519Z","iopub.execute_input":"2024-05-14T15:59:17.873990Z","iopub.status.idle":"2024-05-14T15:59:18.734474Z","shell.execute_reply.started":"2024-05-14T15:59:17.873941Z","shell.execute_reply":"2024-05-14T15:59:18.733233Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"훈련 데이터 셋의 정확도 보다 낮으므로 과적합 발생","metadata":{}},{"cell_type":"markdown","source":"**예측하기**","metadata":{}},{"cell_type":"code","source":"predictions = model.predict(df_test_images)","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:59:18.736234Z","iopub.execute_input":"2024-05-14T15:59:18.736675Z","iopub.status.idle":"2024-05-14T15:59:19.483200Z","shell.execute_reply.started":"2024-05-14T15:59:18.736634Z","shell.execute_reply":"2024-05-14T15:59:19.481851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"첫번째 이미지 예측해보기","metadata":{}},{"cell_type":"code","source":"predictions","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:59:19.484776Z","iopub.execute_input":"2024-05-14T15:59:19.485151Z","iopub.status.idle":"2024-05-14T15:59:19.492893Z","shell.execute_reply.started":"2024-05-14T15:59:19.485121Z","shell.execute_reply":"2024-05-14T15:59:19.491596Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions[0]","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:59:19.494504Z","iopub.execute_input":"2024-05-14T15:59:19.494873Z","iopub.status.idle":"2024-05-14T15:59:19.508434Z","shell.execute_reply.started":"2024-05-14T15:59:19.494836Z","shell.execute_reply":"2024-05-14T15:59:19.507314Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 예측값을 각 이미지에 대한 확률에서 클래스로 변환\npredictions_int = np.argmax(predictions, axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:59:19.509935Z","iopub.execute_input":"2024-05-14T15:59:19.510324Z","iopub.status.idle":"2024-05-14T15:59:19.520092Z","shell.execute_reply.started":"2024-05-14T15:59:19.510294Z","shell.execute_reply":"2024-05-14T15:59:19.519012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# ImageId 생성\nimage_ids = np.arange(1, len(predictions_int) + 1)\n\n# DataFrame 생성\nsubmission_df = pd.DataFrame({'ImageId': image_ids, 'label': predictions_int})\n\n# CSV 파일로 저장\nsubmission_df.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2024-05-14T15:59:19.521418Z","iopub.execute_input":"2024-05-14T15:59:19.521744Z","iopub.status.idle":"2024-05-14T15:59:19.548462Z","shell.execute_reply.started":"2024-05-14T15:59:19.521716Z","shell.execute_reply":"2024-05-14T15:59:19.547265Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}