{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":13836,"databundleVersionId":1718836,"sourceType":"competition"},{"sourceId":9936496,"sourceType":"datasetVersion","datasetId":6108647}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\nfrom sklearn.model_selection import train_test_split\nimport pickle\nimport tensorflow as tf\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Conv2D, MaxPooling2D, Dropout, BatchNormalization, Flatten, Dense\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\nimport joblib\n","metadata":{"execution":{"iopub.status.busy":"2024-11-18T03:20:47.960553Z","iopub.execute_input":"2024-11-18T03:20:47.961578Z","iopub.status.idle":"2024-11-18T03:20:47.968311Z","shell.execute_reply.started":"2024-11-18T03:20:47.961516Z","shell.execute_reply":"2024-11-18T03:20:47.967084Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# /kaggle/input/cifar10-ajm\nld_hist = joblib.load('/kaggle/input/dsci-598-week4/history_week4.joblib')\nld_model = joblib.load('/kaggle/input/dsci-598-week4/final_model_week4.joblib')","metadata":{"execution":{"iopub.status.busy":"2024-11-18T03:21:33.562396Z","iopub.execute_input":"2024-11-18T03:21:33.562893Z","iopub.status.idle":"2024-11-18T03:21:39.983376Z","shell.execute_reply.started":"2024-11-18T03:21:33.562847Z","shell.execute_reply":"2024-11-18T03:21:39.982194Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_datagen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1/255)","metadata":{"execution":{"iopub.status.busy":"2024-11-18T03:21:53.874230Z","iopub.execute_input":"2024-11-18T03:21:53.874734Z","iopub.status.idle":"2024-11-18T03:21:53.881790Z","shell.execute_reply.started":"2024-11-18T03:21:53.874681Z","shell.execute_reply":"2024-11-18T03:21:53.880055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.read_csv(\"/kaggle/input/cassava-leaf-disease-classification/sample_submission.csv\")\nprint(submission.shape)\nsubmission.head()","metadata":{"execution":{"iopub.status.busy":"2024-11-18T03:22:31.671097Z","iopub.execute_input":"2024-11-18T03:22:31.671511Z","iopub.status.idle":"2024-11-18T03:22:31.711605Z","shell.execute_reply.started":"2024-11-18T03:22:31.671471Z","shell.execute_reply":"2024-11-18T03:22:31.710456Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nBATCH_SIZE = 64\n\nsubmission['label'] = submission['label'].astype('str')\ntest_loader = test_datagen.flow_from_dataframe(\n    dataframe = submission,\n    directory = \"/kaggle/input/cassava-leaf-disease-classification/test_images\",\n    x_col = \"image_id\",\n    y_col = 'label',\n    batch_size = BATCH_SIZE,\n    seed = 1,\n    shuffle = True,\n    class_mode = 'categorical',\n    target_size = (600, 600),\n    interpolation='nearest',\n)","metadata":{"execution":{"iopub.status.busy":"2024-11-18T03:23:06.649815Z","iopub.execute_input":"2024-11-18T03:23:06.650236Z","iopub.status.idle":"2024-11-18T03:23:06.669416Z","shell.execute_reply.started":"2024-11-18T03:23:06.650195Z","shell.execute_reply":"2024-11-18T03:23:06.668045Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = ld_model.predict(test_loader, )","metadata":{"execution":{"iopub.status.busy":"2024-11-18T03:23:48.067803Z","iopub.execute_input":"2024-11-18T03:23:48.068263Z","iopub.status.idle":"2024-11-18T03:23:49.439802Z","shell.execute_reply.started":"2024-11-18T03:23:48.068222Z","shell.execute_reply":"2024-11-18T03:23:49.438575Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Get predicted class labels\npredicted_labels = np.argmax(prediction, axis=1) ","metadata":{"execution":{"iopub.status.busy":"2024-11-18T03:23:54.992091Z","iopub.execute_input":"2024-11-18T03:23:54.992538Z","iopub.status.idle":"2024-11-18T03:23:54.998722Z","shell.execute_reply.started":"2024-11-18T03:23:54.992493Z","shell.execute_reply":"2024-11-18T03:23:54.997403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission['label'] = predicted_labels","metadata":{"execution":{"iopub.status.busy":"2024-11-18T03:23:57.687600Z","iopub.execute_input":"2024-11-18T03:23:57.688543Z","iopub.status.idle":"2024-11-18T03:23:57.693934Z","shell.execute_reply.started":"2024-11-18T03:23:57.688492Z","shell.execute_reply":"2024-11-18T03:23:57.692701Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.head()","metadata":{"execution":{"iopub.status.busy":"2024-11-18T03:24:01.822846Z","iopub.execute_input":"2024-11-18T03:24:01.823890Z","iopub.status.idle":"2024-11-18T03:24:01.836446Z","shell.execute_reply.started":"2024-11-18T03:24:01.823831Z","shell.execute_reply":"2024-11-18T03:24:01.835027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission.csv', index=False, header=True)","metadata":{"execution":{"iopub.status.busy":"2024-11-18T03:24:08.146001Z","iopub.execute_input":"2024-11-18T03:24:08.146489Z","iopub.status.idle":"2024-11-18T03:24:08.156947Z","shell.execute_reply.started":"2024-11-18T03:24:08.146440Z","shell.execute_reply":"2024-11-18T03:24:08.155742Z"},"trusted":true},"execution_count":null,"outputs":[]}]}