{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"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)\nimport torch.nn as nn\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\nfrom tqdm import tqdm\nfrom keras.preprocessing import image\nfrom sklearn.model_selection import train_test_split\nfrom sklearn import preprocessing\nfrom tensorflow.keras import datasets, layers, models, losses\nimport matplotlib.pyplot as plt\nimport os\n\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.svm import SVC\nfrom sklearn.linear_model import LogisticRegression\n#for 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":"2022-12-07T20:10:38.310597Z","iopub.execute_input":"2022-12-07T20:10:38.311347Z","iopub.status.idle":"2022-12-07T20:10:38.318789Z","shell.execute_reply.started":"2022-12-07T20:10:38.311310Z","shell.execute_reply":"2022-12-07T20:10:38.317724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## Pseudoode\n\n#1. Load data\n    #Prep Input images\n    #Prep Output Classes\n#2. Define Tensorflow Model\n#3. Test on train and test images. \nprint(dir)","metadata":{"execution":{"iopub.status.busy":"2022-12-07T20:10:42.351563Z","iopub.execute_input":"2022-12-07T20:10:42.352051Z","iopub.status.idle":"2022-12-07T20:10:42.358580Z","shell.execute_reply.started":"2022-12-07T20:10:42.352010Z","shell.execute_reply":"2022-12-07T20:10:42.357439Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 1. Prepare dataset","metadata":{}},{"cell_type":"code","source":"path = '../input/plant-pathology-2021-fgvc8/'\nTRAIN_DIR = path + 'train_images/'\nTEST_DIR = path + 'test_images/'\n\ntrain_df = pd.read_csv(path + 'train.csv')\n#test_df=pd.read_csv()\ntrain_df['labels'].value_counts()\n\ntrain2=train_df[:5240]\n\ntrain2['labels'].value_counts()\n\n","metadata":{"execution":{"iopub.status.busy":"2022-12-07T20:10:46.203253Z","iopub.execute_input":"2022-12-07T20:10:46.203763Z","iopub.status.idle":"2022-12-07T20:10:46.246532Z","shell.execute_reply.started":"2022-12-07T20:10:46.203716Z","shell.execute_reply":"2022-12-07T20:10:46.245150Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#One hot encode the target variable\n\ntrain = train_df.copy()\ntrain['labels'] = train_df['labels'].apply(lambda string: string.split(' '))\n\ns = list(train['labels'])\nmlb = preprocessing.MultiLabelBinarizer()\ntrainx = pd.DataFrame(mlb.fit_transform(s), columns=mlb.classes_, index=train.index)\ntrainx['image'] = train['image']\n\nprint(trainx.head(10))\nprint(trainx.columns)\n\ny = np.array(trainx.drop(['image'],axis=1))","metadata":{"execution":{"iopub.status.busy":"2022-12-07T20:10:48.541889Z","iopub.execute_input":"2022-12-07T20:10:48.542284Z","iopub.status.idle":"2022-12-07T20:10:48.586599Z","shell.execute_reply.started":"2022-12-07T20:10:48.542243Z","shell.execute_reply":"2022-12-07T20:10:48.585060Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##Hyperparamters\nTARGET_SIZE = 128\nBATCH_SIZE = 64\nEPOCHS = 50\nDATA_LIMIT = 12000","metadata":{"execution":{"iopub.status.busy":"2022-12-07T20:10:49.151971Z","iopub.execute_input":"2022-12-07T20:10:49.152916Z","iopub.status.idle":"2022-12-07T20:10:49.159709Z","shell.execute_reply.started":"2022-12-07T20:10:49.152877Z","shell.execute_reply":"2022-12-07T20:10:49.158729Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Loading the Data (takes around 100 minutes) \n#Stopping Early allows for easier loading. Let run for 30 minutes (5230 images loaded)\ntrain_image = []\nfor i in tqdm(range(5240)):\n    \n    img = image.load_img(TRAIN_DIR+ trainx['image'][i],target_size=(TARGET_SIZE,TARGET_SIZE))\n    img = image.img_to_array(img)\n    img = img/255 ##Standardize pixel value between 0 and 1\n    train_image.append(img)\n\n    X = np.array(train_image)","metadata":{"execution":{"iopub.status.busy":"2022-12-07T20:10:53.220274Z","iopub.execute_input":"2022-12-07T20:10:53.220708Z","iopub.status.idle":"2022-12-07T20:35:28.648430Z","shell.execute_reply.started":"2022-12-07T20:10:53.220646Z","shell.execute_reply":"2022-12-07T20:35:28.647360Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"end=(X.shape[0])\nprint(end)\nnew_y=y[:end]\nX_train, X_test, y_train, y_test = train_test_split(X, new_y, test_size=0.3)","metadata":{"execution":{"iopub.status.busy":"2022-12-07T20:35:28.650640Z","iopub.execute_input":"2022-12-07T20:35:28.651949Z","iopub.status.idle":"2022-12-07T20:35:28.956883Z","shell.execute_reply.started":"2022-12-07T20:35:28.651908Z","shell.execute_reply":"2022-12-07T20:35:28.955817Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train.shape","metadata":{"execution":{"iopub.status.busy":"2022-12-07T20:35:28.958561Z","iopub.execute_input":"2022-12-07T20:35:28.959035Z","iopub.status.idle":"2022-12-07T20:35:28.966561Z","shell.execute_reply.started":"2022-12-07T20:35:28.958991Z","shell.execute_reply":"2022-12-07T20:35:28.965164Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 2. Create CNN Model in Keras","metadata":{}},{"cell_type":"markdown","source":"### Deep LeNet Model (NO Dropout)","metadata":{}},{"cell_type":"code","source":"from keras.models import Sequential\nfrom keras.layers import Dense, Dropout, Flatten\nfrom keras.layers import Conv2D, MaxPooling2D\n\nmodel = Sequential()\nmodel.add(Conv2D(filters=16, kernel_size=(5, 5), activation=\"relu\", input_shape=(TARGET_SIZE,TARGET_SIZE,3)))\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\n#model.add(Dropout(0.25))\nmodel.add(Conv2D(filters=32, kernel_size=(5, 5), activation='relu'))\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\n#model.add(Dropout(0.25))\nmodel.add(Conv2D(filters=64, kernel_size=(5, 5), activation=\"relu\"))\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\n#model.add(Dropout(0.25))\nmodel.add(Conv2D(filters=64, kernel_size=(5, 5), activation='relu'))\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\n#model.add(Dropout(0.25))\nmodel.add(Flatten())\nmodel.add(Dense(128, activation='relu'))\n#model.add(Dropout(0.5))\nmodel.add(Dense(64, activation='relu'))\n#model.add(Dropout(0.5))\nmodel.add(Dense(6, activation='sigmoid'))\nmodel.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])\n\nmodel.summary()\n\n\nhistory = model.fit(X_train, y_train, epochs=EPOCHS, validation_data=(X_test, y_test), batch_size=BATCH_SIZE)\nprint(history.history.keys())\n# summarize history for accuracy\n\nplt.plot(history.history['accuracy'])\nplt.plot(history.history['val_accuracy'])\nplt.title('Deep LeNet Model Accuracy')\nplt.ylabel('Accuracy')\nplt.xlabel('Epoch')\nplt.legend(['train', 'test'], loc='upper left')\nplt.show()\n# summarize history for loss\nplt.plot(history.history['loss'])\nplt.plot(history.history['val_loss'])\nplt.title('Deep LeNet Model Loss')\nplt.ylabel('Loss')\nplt.xlabel('Epoch')\nplt.legend(['train', 'test'], loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-07T22:26:35.923423Z","iopub.execute_input":"2022-12-07T22:26:35.923834Z","iopub.status.idle":"2022-12-07T22:29:11.730763Z","shell.execute_reply.started":"2022-12-07T22:26:35.923799Z","shell.execute_reply":"2022-12-07T22:29:11.729674Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Deep LeNet BAsed Model with Dropout","metadata":{}},{"cell_type":"code","source":"from keras.models import Sequential\nfrom keras.layers import Dense, Dropout, Flatten\nfrom keras.layers import Conv2D, MaxPooling2D\n\nmodel = Sequential()\nmodel.add(Conv2D(filters=16, kernel_size=(5, 5), activation=\"relu\", input_shape=(TARGET_SIZE,TARGET_SIZE,3)))\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\nmodel.add(Dropout(0.25))\nmodel.add(Conv2D(filters=32, kernel_size=(5, 5), activation='relu'))\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\nmodel.add(Dropout(0.25))\nmodel.add(Conv2D(filters=64, kernel_size=(5, 5), activation=\"relu\"))\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\nmodel.add(Dropout(0.25))\nmodel.add(Conv2D(filters=64, kernel_size=(5, 5), activation='relu'))\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\nmodel.add(Dropout(0.25))\nmodel.add(Flatten())\nmodel.add(Dense(128, activation='relu'))\nmodel.add(Dropout(0.5))\nmodel.add(Dense(64, activation='relu'))\nmodel.add(Dropout(0.5))\nmodel.add(Dense(6, activation='sigmoid'))\nmodel.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])\n\nmodel.summary()\n\n\nhistory = model.fit(X_train, y_train, epochs=EPOCHS, validation_data=(X_test, y_test), batch_size=BATCH_SIZE)\nprint(history.history.keys())\n# summarize history for accuracy\n\nplt.plot(history.history['accuracy'])\nplt.plot(history.history['val_accuracy'])\nplt.title('Deep LeNet Model Accuracy with Dropout')\nplt.ylabel('Accuracy')\nplt.xlabel('Epoch')\nplt.legend(['train', 'test'], loc='upper left')\nplt.show()\n# summarize history for loss\nplt.plot(history.history['loss'])\nplt.plot(history.history['val_loss'])\nplt.title('Deep LeNet Model Loss with Dropout')\nplt.ylabel('Loss')\nplt.xlabel('Epoch')\nplt.legend(['train', 'test'], loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-07T22:29:25.206922Z","iopub.execute_input":"2022-12-07T22:29:25.207363Z","iopub.status.idle":"2022-12-07T22:30:58.639889Z","shell.execute_reply.started":"2022-12-07T22:29:25.207306Z","shell.execute_reply":"2022-12-07T22:30:58.638776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Simple LeNet (NO DROPOUT)","metadata":{}},{"cell_type":"code","source":"##Simple LeNet Structure\nfrom keras.models import Sequential\nfrom keras.layers import Dense, Dropout, Flatten\nfrom keras.layers import Conv2D, MaxPooling2D\n\nmodel2 = Sequential()\nmodel2.add(Conv2D(filters=16, kernel_size=(5, 5), activation=\"relu\", input_shape=(TARGET_SIZE,TARGET_SIZE,3)))\nmodel2.add(MaxPooling2D(pool_size=(2, 2)))\n#model2.add(Dropout(0.25))\nmodel2.add(Conv2D(filters=32, kernel_size=(5, 5), activation='relu'))\nmodel2.add(MaxPooling2D(pool_size=(2, 2)))\n#model2.add(Dropout(0.25))\nmodel2.add(Flatten())\nmodel2.add(Dense(128, activation='relu'))\n#model2.add(Dropout(0.5))\nmodel2.add(Dense(64, activation='relu'))\n#model2.add(Dropout(0.5))\nmodel2.add(Dense(6, activation='sigmoid'))\nmodel2.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])\n\nmodel2.summary()\n\nhistory2 = model2.fit(X_train, y_train, epochs=EPOCHS, validation_data=(X_test, y_test), batch_size=BATCH_SIZE)\nprint(history2.history.keys())\n# summarize history for accuracy\n\nplt.plot(history2.history['accuracy'])\nplt.plot(history2.history['val_accuracy'])\nplt.title('LeNet Model Accuracy')\nplt.ylabel('Accuracy')\nplt.xlabel('Epoch')\nplt.legend(['train', 'test'], loc='upper left')\nplt.show()\n# summarize history for loss\nplt.plot(history2.history['loss'])\nplt.plot(history2.history['val_loss'])\nplt.title('LeNet Model Loss')\nplt.ylabel('Loss')\nplt.xlabel('Epoch')\nplt.legend(['train', 'test'], loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-07T22:31:11.431831Z","iopub.execute_input":"2022-12-07T22:31:11.432226Z","iopub.status.idle":"2022-12-07T22:32:36.085937Z","shell.execute_reply.started":"2022-12-07T22:31:11.432182Z","shell.execute_reply":"2022-12-07T22:32:36.084718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Simple LeNet WITH DROPOUT","metadata":{}},{"cell_type":"code","source":"##Simple LeNet Structure\nfrom keras.models import Sequential\nfrom keras.layers import Dense, Dropout, Flatten\nfrom keras.layers import Conv2D, MaxPooling2D\n\nmodel3 = Sequential()\nmodel3.add(Conv2D(filters=16, kernel_size=(5, 5), activation=\"relu\", input_shape=(TARGET_SIZE,TARGET_SIZE,3)))\nmodel3.add(MaxPooling2D(pool_size=(2, 2)))\nmodel3.add(Dropout(0.25))\nmodel3.add(Conv2D(filters=32, kernel_size=(5, 5), activation='relu'))\nmodel3.add(MaxPooling2D(pool_size=(2, 2)))\nmodel3.add(Dropout(0.25))\nmodel3.add(Flatten())\nmodel3.add(Dense(128, activation='relu'))\nmodel3.add(Dropout(0.5))\nmodel3.add(Dense(64, activation='relu'))\nmodel3.add(Dropout(0.5))\nmodel3.add(Dense(6, activation='sigmoid'))\nmodel3.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])\n\nmodel3.summary()\n\nhistory3 = model3.fit(X_train, y_train, epochs=EPOCHS, validation_data=(X_test, y_test), batch_size=BATCH_SIZE)\nprint(history3.history.keys())\n# summarize history for accuracy\n\nplt.plot(history3.history['accuracy'])\nplt.plot(history3.history['val_accuracy'])\nplt.title('LeNet Model Accuracy with Dropout')\nplt.ylabel('Accuracy')\nplt.xlabel('Epoch')\nplt.legend(['train', 'test'], loc='upper left')\nplt.show()\n# summarize history for loss\nplt.plot(history3.history['loss'])\nplt.plot(history3.history['val_loss'])\nplt.title('LeNet Model Loss with Dropout')\nplt.ylabel('Loss')\nplt.xlabel('Epoch')\nplt.legend(['train', 'test'], loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-07T22:33:57.455922Z","iopub.execute_input":"2022-12-07T22:33:57.457120Z","iopub.status.idle":"2022-12-07T22:35:22.137621Z","shell.execute_reply.started":"2022-12-07T22:33:57.457062Z","shell.execute_reply":"2022-12-07T22:35:22.136635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train2=trainx.head(10)\n#train2['labels'].value_counts()\nprint(train2)","metadata":{"execution":{"iopub.status.busy":"2022-12-07T18:17:21.524744Z","iopub.execute_input":"2022-12-07T18:17:21.525045Z","iopub.status.idle":"2022-12-07T18:17:21.586973Z","shell.execute_reply.started":"2022-12-07T18:17:21.525017Z","shell.execute_reply":"2022-12-07T18:17:21.585761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train.shape\nnew_Xtrain=np.reshape(X_train, (3668,49152))\nprint(new_Xtrain.shape)\n\nX_test.shape\nnew_Xtest=np.reshape(X_test, (1572,49152))\nprint(new_Xtest.shape)\n","metadata":{"execution":{"iopub.status.busy":"2022-12-07T20:40:14.391170Z","iopub.execute_input":"2022-12-07T20:40:14.391564Z","iopub.status.idle":"2022-12-07T20:40:14.398594Z","shell.execute_reply.started":"2022-12-07T20:40:14.391527Z","shell.execute_reply":"2022-12-07T20:40:14.397371Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Random Forest Classifier","metadata":{}},{"cell_type":"code","source":"##RF all one hot encoded\nclf = RandomForestClassifier(random_state=0)\nclf.fit(new_Xtrain, y_train)\n\nrf_train_score=clf.score(new_Xtrain, y_train)\nprint('Train Set Accuracy: ', rf_train_score)\n\nrf_test_score=clf.score(new_Xtest, y_test)\nprint('Test Set Accuracy: ', rf_test_score)\n\n","metadata":{"execution":{"iopub.status.busy":"2022-12-07T22:16:45.751838Z","iopub.execute_input":"2022-12-07T22:16:45.752250Z","iopub.status.idle":"2022-12-07T22:18:13.358627Z","shell.execute_reply.started":"2022-12-07T22:16:45.752207Z","shell.execute_reply":"2022-12-07T22:18:13.357218Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Accuracy is really bad when trying to predict all the classesat once. Let's try splitting them up into each category","metadata":{}},{"cell_type":"markdown","source":"#### Split Y variable into each separate binary class","metadata":{}},{"cell_type":"code","source":"y_train_complex, y_test_complex = y_train[:,0], y_test[:,0]\ny_train_frogeye, y_test_frogeye = y_train[:,1], y_test[:,1]\ny_train_healthy, y_test_healthy = y_train[:,2], y_test[:,2]\ny_train_powmildew, y_test_powmildew = y_train[:,3], y_test[:,3]\ny_train_rust, y_test_rust = y_train[:,4], y_test[:,4]\ny_train_scab, y_test_scab = y_train[:,5], y_test[:,5]","metadata":{"execution":{"iopub.status.busy":"2022-12-07T20:40:02.417160Z","iopub.execute_input":"2022-12-07T20:40:02.417651Z","iopub.status.idle":"2022-12-07T20:40:02.424910Z","shell.execute_reply.started":"2022-12-07T20:40:02.417613Z","shell.execute_reply":"2022-12-07T20:40:02.423753Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##RF of only complex\nclf = RandomForestClassifier(random_state=0)\nclf.fit(new_Xtrain, y_train_complex)\n\nrf_train_score=clf.score(new_Xtrain, y_train_complex)\nprint('Complex Train Set Accuracy: ', rf_train_score)\n\nrf_test_score=clf.score(new_Xtest, y_test_complex)\nprint('Complex Test Set Accuracy: ', rf_test_score)\n\n","metadata":{"execution":{"iopub.status.busy":"2022-12-07T22:18:19.166603Z","iopub.execute_input":"2022-12-07T22:18:19.167359Z","iopub.status.idle":"2022-12-07T22:19:12.987824Z","shell.execute_reply.started":"2022-12-07T22:18:19.167319Z","shell.execute_reply":"2022-12-07T22:19:12.986558Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##RF of only Frog Eye Leaf Spot\nclf = RandomForestClassifier(random_state=0)\nclf.fit(new_Xtrain, y_train_frogeye)\n\nrf_train_score=clf.score(new_Xtrain, y_train_frogeye)\nprint('FrogEyeLEafSpot Train Set Accuracy: ', rf_train_score)\n\nrf_test_score=clf.score(new_Xtest, y_test_frogeye)\nprint('FrogEyeLEafSpot Test Set Accuracy: ', rf_test_score)","metadata":{"execution":{"iopub.status.busy":"2022-12-07T22:19:12.990082Z","iopub.execute_input":"2022-12-07T22:19:12.991055Z","iopub.status.idle":"2022-12-07T22:20:09.779922Z","shell.execute_reply.started":"2022-12-07T22:19:12.991019Z","shell.execute_reply":"2022-12-07T22:20:09.778743Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##RF of only Healthy\nclf = RandomForestClassifier(random_state=0)\nclf.fit(new_Xtrain, y_train_healthy)\n\nrf_train_score=clf.score(new_Xtrain, y_train_healthy)\nprint('Healthy Train Set Accuracy: ', rf_train_score)\n\nrf_test_score=clf.score(new_Xtest, y_test_healthy)\nprint('Healthy Test Set Accuracy: ', rf_test_score)","metadata":{"execution":{"iopub.status.busy":"2022-12-07T22:20:09.781867Z","iopub.execute_input":"2022-12-07T22:20:09.782577Z","iopub.status.idle":"2022-12-07T22:21:28.567760Z","shell.execute_reply.started":"2022-12-07T22:20:09.782536Z","shell.execute_reply":"2022-12-07T22:21:28.566530Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##RF of only Powdery Mildew\nclf = RandomForestClassifier(random_state=0)\nclf.fit(new_Xtrain, y_train_powmildew)\n\nrf_train_score=clf.score(new_Xtrain, y_train_powmildew)\nprint('Powdery Mildew Train Set Accuracy: ', rf_train_score)\n\nrf_test_score=clf.score(new_Xtest, y_test_powmildew)\nprint('Powdery Mildew Test Set Accuracy: ', rf_test_score)","metadata":{"execution":{"iopub.status.busy":"2022-12-07T22:21:28.570428Z","iopub.execute_input":"2022-12-07T22:21:28.571097Z","iopub.status.idle":"2022-12-07T22:22:35.344780Z","shell.execute_reply.started":"2022-12-07T22:21:28.571055Z","shell.execute_reply":"2022-12-07T22:22:35.343417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##RF of only Rust\nclf = RandomForestClassifier(random_state=0)\nclf.fit(new_Xtrain, y_train_rust)\n\nrf_train_score=clf.score(new_Xtrain, y_train_rust)\nprint('Rust Train Set Accuracy: ', rf_train_score)\n\nrf_test_score=clf.score(new_Xtest, y_test_rust)\nprint('Rust Test Set Accuracy: ', rf_test_score)","metadata":{"execution":{"iopub.status.busy":"2022-12-07T22:22:35.347032Z","iopub.execute_input":"2022-12-07T22:22:35.347634Z","iopub.status.idle":"2022-12-07T22:24:43.455268Z","shell.execute_reply.started":"2022-12-07T22:22:35.347588Z","shell.execute_reply":"2022-12-07T22:24:43.453974Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##RF of only Scab\nclf = RandomForestClassifier(random_state=0)\nclf.fit(new_Xtrain, y_train_scab)\n\nrf_train_score=clf.score(new_Xtrain, y_train_scab)\nprint('Scab Train Set Accuracy: ', rf_train_score)\n\nrf_test_score=clf.score(new_Xtest, y_test_scab)\nprint('Scab Test Set Accuracy: ', rf_test_score)","metadata":{"execution":{"iopub.status.busy":"2022-12-07T22:24:43.457089Z","iopub.execute_input":"2022-12-07T22:24:43.457545Z","iopub.status.idle":"2022-12-07T22:25:38.923558Z","shell.execute_reply.started":"2022-12-07T22:24:43.457501Z","shell.execute_reply":"2022-12-07T22:25:38.922454Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## SVM\n","metadata":{}},{"cell_type":"code","source":"##SVM of only complex\nclf = SVC(random_state=0).fit(new_Xtrain, y_train_complex)\n\n\nsvm_train_score=clf.score(new_Xtrain, y_train_complex)\nprint('Complex Train Set Accuracy: ', svm_train_score)\n\nsvm_test_score=clf.score(new_Xtest, y_test_complex)\nprint('Complex Test Set Accuracy: ', svm_test_score)\n","metadata":{"execution":{"iopub.status.busy":"2022-12-07T20:40:22.673073Z","iopub.execute_input":"2022-12-07T20:40:22.673490Z","iopub.status.idle":"2022-12-07T20:50:59.979252Z","shell.execute_reply.started":"2022-12-07T20:40:22.673451Z","shell.execute_reply":"2022-12-07T20:50:59.977920Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##SVM of only froge eye leaf spot\nclf = SVC(random_state=0).fit(new_Xtrain, y_train_frogeye)\n\n\nsvm_train_score=clf.score(new_Xtrain, y_train_frogeye)\nprint('Complex Train Set Accuracy: ', svm_train_score)\n\nsvm_test_score=clf.score(new_Xtest, y_test_frogeye)\nprint('Complex Test Set Accuracy: ', svm_test_score)\n","metadata":{"execution":{"iopub.status.busy":"2022-12-07T20:50:59.982115Z","iopub.execute_input":"2022-12-07T20:50:59.982551Z","iopub.status.idle":"2022-12-07T21:12:04.221038Z","shell.execute_reply.started":"2022-12-07T20:50:59.982508Z","shell.execute_reply":"2022-12-07T21:12:04.219755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##SVM of only healthy\nclf = SVC(random_state=0).fit(new_Xtrain, y_train_healthy)\n\n\nsvm_train_score=clf.score(new_Xtrain, y_train_healthy)\nprint('Healthy Train Set Accuracy: ', svm_train_score)\n\nsvm_test_score=clf.score(new_Xtest, y_test_healthy)\nprint('Healthy Test Set Accuracy: ', svm_test_score)\n","metadata":{"execution":{"iopub.status.busy":"2022-12-07T21:12:04.222517Z","iopub.execute_input":"2022-12-07T21:12:04.223117Z","iopub.status.idle":"2022-12-07T21:30:23.204159Z","shell.execute_reply.started":"2022-12-07T21:12:04.223078Z","shell.execute_reply":"2022-12-07T21:30:23.202230Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##SVM of only Powdery Mildew\nclf = SVC(random_state=0).fit(new_Xtrain, y_train_powmildew)\n\n\nsvm_train_score=clf.score(new_Xtrain, y_train_powmildew)\nprint('Powdery Mildew Train Set Accuracy: ', svm_train_score)\n\nsvm_test_score=clf.score(new_Xtest, y_test_powmildew)\nprint('Powdery Mildew Test Set Accuracy: ', svm_test_score)\n","metadata":{"execution":{"iopub.status.busy":"2022-12-07T21:30:23.207015Z","iopub.execute_input":"2022-12-07T21:30:23.207410Z","iopub.status.idle":"2022-12-07T21:39:34.839973Z","shell.execute_reply.started":"2022-12-07T21:30:23.207371Z","shell.execute_reply":"2022-12-07T21:39:34.838758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##SVM of only rust\nclf = SVC(random_state=0).fit(new_Xtrain, y_train_rust)\n\n\nsvm_train_score=clf.score(new_Xtrain, y_train_rust)\nprint('Rust Train Set Accuracy: ', svm_train_score)\n\nsvm_test_score=clf.score(new_Xtest, y_test_rust)\nprint('Rust Test Set Accuracy: ', svm_test_score)\n","metadata":{"execution":{"iopub.status.busy":"2022-12-07T21:39:34.843291Z","iopub.execute_input":"2022-12-07T21:39:34.843634Z","iopub.status.idle":"2022-12-07T21:51:08.459035Z","shell.execute_reply.started":"2022-12-07T21:39:34.843602Z","shell.execute_reply":"2022-12-07T21:51:08.457768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##SVM of only scab\nclf = SVC(random_state=0).fit(new_Xtrain, y_train_scab)\n\n\nsvm_train_score=clf.score(new_Xtrain, y_train_scab)\nprint('Scab Train Set Accuracy: ', svm_train_score)\n\nsvm_test_score=clf.score(new_Xtest, y_test_scab)\nprint('Scab Test Set Accuracy: ', svm_test_score)\n","metadata":{"execution":{"iopub.status.busy":"2022-12-07T21:51:08.460700Z","iopub.execute_input":"2022-12-07T21:51:08.462024Z","iopub.status.idle":"2022-12-07T22:13:17.952698Z","shell.execute_reply.started":"2022-12-07T21:51:08.461980Z","shell.execute_reply":"2022-12-07T22:13:17.951486Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}