{"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":"markdown","source":"# Galaxy Zoo\n\nUnderstanding how and why we are here is one of the fundamental questions for the human race. Part of the answer to this question lies in the origins of galaxies, such as our own Milky Way. Yet questions remain about how the Milky Way (or any of the other ~100 billion galaxies in our Universe) was formed and has evolved. Galaxies come in all shapes, sizes and colors: from beautiful spirals to huge ellipticals. Understanding the distribution, location and types of galaxies as a function of shape, size, and color are critical pieces for solving this puzzle.\n\n![Image Credit: ESA/Hubble & NASA](https://storage.googleapis.com/kaggle-competitions/kaggle/3175/media/mainimage.jpg)\n\nWith each passing day telescopes around and above the Earth capture more and more images of distant galaxies. As better and bigger telescopes continue to collect these images, the datasets begin to explode in size. In order to better understand how the different shapes (or morphologies) of galaxies relate to the physics that create them, such images need to be sorted and classified. \n\nHence the Galaxy Zoo Challenge!","metadata":{"id":"0w86YsWnWGmr"}},{"cell_type":"markdown","source":"### Happy EDA! Feel free to fork this notebook and add your own inputs and experiment! Do drop any questions or tips for improvements in the comments, and dont forget to Upvote! For more such projects and ML in general, visit my [Github/shibinjudahpaul](https://github.com/shibinjudahpaul)","metadata":{}},{"cell_type":"markdown","source":"## Goal\nThe aim is to analyze the JPG images of galaxies to find automated metrics that reproduce the probability distributions derived from human classifications. For each galaxy, determine the probability that it belongs in a particular class. ","metadata":{"id":"QOH1u7WMWGwS"}},{"cell_type":"markdown","source":"## Import libraries","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nfrom sklearn.model_selection import train_test_split\nimport tensorflow as tf\nimport os\nimport random\nimport matplotlib.pyplot as plt","metadata":{"id":"b_odvKR6wsPl","execution":{"iopub.status.busy":"2023-03-11T09:11:21.816642Z","iopub.execute_input":"2023-03-11T09:11:21.817605Z","iopub.status.idle":"2023-03-11T09:11:30.217683Z","shell.execute_reply.started":"2023-03-11T09:11:21.817540Z","shell.execute_reply":"2023-03-11T09:11:30.216507Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Unzip the training data  ","metadata":{"id":"0GEoi1DAcA4Y"}},{"cell_type":"code","source":"!unzip -q /kaggle/input/galaxy-zoo-the-galaxy-challenge/training_solutions_rev1.zip","metadata":{"id":"SZBQGuHBwsX6","outputId":"a21f0c50-8550-44df-bf1d-c6b4bd2aabe7","execution":{"iopub.status.busy":"2023-03-11T09:11:47.632017Z","iopub.execute_input":"2023-03-11T09:11:47.632666Z","iopub.status.idle":"2023-03-11T09:11:48.812945Z","shell.execute_reply.started":"2023-03-11T09:11:47.632625Z","shell.execute_reply":"2023-03-11T09:11:48.811425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Read and split the data and divide it in training and testing data","metadata":{"id":"MF53EgetcHeo"}},{"cell_type":"code","source":"df = pd.read_csv('/kaggle/working/training_solutions_rev1.csv')\n\ndf_train, df_test = train_test_split(df[:30000], test_size=.2)\ndf_train.shape, df_test.shape","metadata":{"id":"igdqj9HHwoJx","outputId":"5ac3f9f5-0d30-41a3-e25c-db19fa37d91c","execution":{"iopub.status.busy":"2023-03-11T09:11:53.320913Z","iopub.execute_input":"2023-03-11T09:11:53.321966Z","iopub.status.idle":"2023-03-11T09:11:53.570143Z","shell.execute_reply.started":"2023-03-11T09:11:53.321922Z","shell.execute_reply":"2023-03-11T09:11:53.568992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Basic EDA","metadata":{"id":"eeP-k0s0cPRn"}},{"cell_type":"code","source":"df_train.describe()","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:53:35.703911Z","iopub.execute_input":"2023-03-11T09:53:35.704632Z","iopub.status.idle":"2023-03-11T09:53:35.837015Z","shell.execute_reply.started":"2023-03-11T09:53:35.704593Z","shell.execute_reply":"2023-03-11T09:53:35.835851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Shape of the train set: \",df_train.shape)\n\nprint(\"Shape of the test set: \",df_test.shape)","metadata":{"id":"872exVWsVk26","outputId":"87180457-d332-4262-ead0-dfa7cca5ec48","execution":{"iopub.status.busy":"2023-03-11T09:52:36.677346Z","iopub.execute_input":"2023-03-11T09:52:36.677953Z","iopub.status.idle":"2023-03-11T09:52:36.683990Z","shell.execute_reply.started":"2023-03-11T09:52:36.677913Z","shell.execute_reply":"2023-03-11T09:52:36.682926Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Unzipping train and test images","metadata":{"id":"SOdMWmjHf5Kp"}},{"cell_type":"code","source":"!unzip -q /kaggle/input/galaxy-zoo-the-galaxy-challenge/images_training_rev1.zip\n!unzip -q /kaggle/input/galaxy-zoo-the-galaxy-challenge/images_test_rev1.zip","metadata":{"id":"DDKQh8FE1LaI","outputId":"8adc14a2-0cba-4ff7-8445-7455de6a6623","execution":{"iopub.status.busy":"2023-03-11T09:12:58.320391Z","iopub.execute_input":"2023-03-11T09:12:58.321311Z","iopub.status.idle":"2023-03-11T09:13:38.488106Z","shell.execute_reply.started":"2023-03-11T09:12:58.321256Z","shell.execute_reply":"2023-03-11T09:13:38.486590Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### EDA Images","metadata":{"id":"npC8SgWbeyMU"}},{"cell_type":"code","source":"trainPath = '/kaggle/working/images_training_rev1'\ntestPath = '/kaggle/working/images_test_rev1'","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:13:38.490846Z","iopub.execute_input":"2023-03-11T09:13:38.491233Z","iopub.status.idle":"2023-03-11T09:13:38.499091Z","shell.execute_reply.started":"2023-03-11T09:13:38.491198Z","shell.execute_reply":"2023-03-11T09:13:38.497882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def plot_random_galaxy(path, sample = 5):\n    random_image=random.sample(os.listdir(path),sample)\n \n    plt.figure(figsize=(16,5))\n    for i in range(sample):\n        \n        plt.subplot(1,sample,i+1)\n        img=tf.io.read_file(os.path.join(path,random_image[i]))\n        img=tf.io.decode_image(img)\n        plt.imshow(img)\n        plt.title(f'Class: {random_image[i]}\\nShape: {img.shape}')\n        plt.axis(False) ","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:13:38.500869Z","iopub.execute_input":"2023-03-11T09:13:38.501673Z","iopub.status.idle":"2023-03-11T09:13:38.510128Z","shell.execute_reply.started":"2023-03-11T09:13:38.501632Z","shell.execute_reply":"2023-03-11T09:13:38.508815Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_random_galaxy(trainPath)","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:13:38.513779Z","iopub.execute_input":"2023-03-11T09:13:38.514655Z","iopub.status.idle":"2023-03-11T09:13:43.070904Z","shell.execute_reply.started":"2023-03-11T09:13:38.514552Z","shell.execute_reply":"2023-03-11T09:13:43.070020Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_random_galaxy(testPath)","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:56:09.792347Z","iopub.execute_input":"2023-03-11T09:56:09.793344Z","iopub.status.idle":"2023-03-11T09:56:10.414521Z","shell.execute_reply.started":"2023-03-11T09:56:09.793289Z","shell.execute_reply":"2023-03-11T09:56:10.413657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**We can see a mix of elliptical and spiral galaxies in both train and test datasets.**","metadata":{}},{"cell_type":"markdown","source":"#### Read images in reference to the csv file, Resize and split them into train and test data(X,y) ","metadata":{}},{"cell_type":"code","source":"\nfrom skimage.transform import resize\nfrom tqdm import tqdm # progress which the model\nimport matplotlib.pyplot as plt\n%matplotlib inline\n          \n\nORIG_SHAPE = (424,424)\nCROP_SIZE = (256,256)\nIMG_SHAPE = (64,64)\n\ndef get_image(path, x1,y1, shape, crop_size):\n    x = plt.imread(path)\n    x = x[x1:x1+crop_size[0], y1:y1+crop_size[1]]\n    x = resize(x, shape)\n    x = x/255.\n    return x\n    \ndef get_all_images(dataframe, shape=IMG_SHAPE, crop_size=CROP_SIZE):\n    x1 = (ORIG_SHAPE[0]-CROP_SIZE[0])//2\n    y1 = (ORIG_SHAPE[1]-CROP_SIZE[1])//2\n   \n    sel = dataframe.values\n    ids = sel[:,0].astype(int).astype(str)\n    y_batch = sel[:,1:]\n    x_batch = []\n    for i in tqdm(ids):\n        x = get_image('/kaggle/working/images_training_rev1/'+i+'.jpg', x1,y1, shape=shape, crop_size=crop_size)\n        x_batch.append(x)\n    x_batch = np.array(x_batch)\n    return x_batch, y_batch\n        \nX_train, y_train = get_all_images(df_train)\nX_test, y_test = get_all_images(df_test)","metadata":{"id":"hkV56aCJyWos","outputId":"503eb8be-5154-4317-b674-ff8023d7537a","execution":{"iopub.status.busy":"2023-03-11T09:13:43.071846Z","iopub.execute_input":"2023-03-11T09:13:43.072174Z","iopub.status.idle":"2023-03-11T09:17:59.522833Z","shell.execute_reply.started":"2023-03-11T09:13:43.072138Z","shell.execute_reply":"2023-03-11T09:17:59.521769Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train.shape","metadata":{"id":"RkIJtf4jpczY","execution":{"iopub.status.busy":"2023-03-11T09:17:59.524405Z","iopub.execute_input":"2023-03-11T09:17:59.527081Z","iopub.status.idle":"2023-03-11T09:17:59.534097Z","shell.execute_reply.started":"2023-03-11T09:17:59.527038Z","shell.execute_reply":"2023-03-11T09:17:59.532825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.values[0].shape","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:17:59.535793Z","iopub.execute_input":"2023-03-11T09:17:59.536208Z","iopub.status.idle":"2023-03-11T09:17:59.550011Z","shell.execute_reply.started":"2023-03-11T09:17:59.536172Z","shell.execute_reply":"2023-03-11T09:17:59.548866Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Build a Deep learning Model using Mirrored Strategy ","metadata":{"id":"Abg_RI6zphbu"}},{"cell_type":"code","source":"from keras.models import Sequential\nfrom keras.layers import Conv2D, MaxPooling2D\nfrom keras.layers import Activation, Dropout, Flatten, Dense, BatchNormalization, GlobalMaxPooling2D\nfrom keras import backend as K\n\ndef root_mean_squared_error(y_true, y_pred):\n        return K.sqrt(K.mean(K.square(y_pred - y_true))) \n\n#to use two GPUs in parallel\nstrategy = tf.distribute.MirroredStrategy()\n\nwith strategy.scope():\n    model = Sequential()\n    model.add(Conv2D(512, (3, 3), input_shape=(IMG_SHAPE[0], IMG_SHAPE[1], 3)))\n    model.add(Conv2D(256, (3, 3)))\n    #model.add(BatchNormalization())\n    model.add(Activation('relu'))\n    model.add(MaxPooling2D(pool_size=(2, 2)))\n\n    model.add(Conv2D(256, (3, 3)))\n    model.add(Conv2D(128, (3, 3)))\n    #model.add(BatchNormalization())\n    model.add(Activation('relu'))\n    model.add(MaxPooling2D(pool_size=(2, 2)))\n\n    model.add(Conv2D(128, (3, 3)))\n    model.add(Conv2D(128, (3, 3)))\n    #model.add(BatchNormalization())\n    model.add(Activation('relu'))\n    model.add(GlobalMaxPooling2D())\n\n\n    model.add(Dropout(0.25))\n    model.add(Dense(128))\n    model.add(Activation('relu'))\n    model.add(Dropout(0.25))\n    model.add(Dense(128))\n    model.add(Activation('relu'))\n    model.add(Dropout(0.25))\n    model.add(Dense(128))\n    model.add(Activation('relu'))\n    model.add(Dropout(0.25))\n    model.add(Dense(37))\n    model.add(Activation('sigmoid'))\n\n    model.compile(loss='binary_crossentropy', optimizer='adamax', metrics=['accuracy',root_mean_squared_error])\n\nmodel.summary()","metadata":{"id":"c15JIGEYzGBK","execution":{"iopub.status.busy":"2023-03-11T09:17:59.551931Z","iopub.execute_input":"2023-03-11T09:17:59.552313Z","iopub.status.idle":"2023-03-11T09:18:00.526210Z","shell.execute_reply.started":"2023-03-11T09:17:59.552258Z","shell.execute_reply":"2023-03-11T09:18:00.525534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### begin training","metadata":{"id":"p8KXkyY-pnqC"}},{"cell_type":"code","source":"batch_size = 128\nwith strategy.scope():\n    model.fit(X_train, y_train, epochs=20, validation_data=(X_test, y_test),use_multiprocessing=True)","metadata":{"id":"VEMOW_aazHL4","execution":{"iopub.status.busy":"2023-03-11T09:18:00.527182Z","iopub.execute_input":"2023-03-11T09:18:00.527484Z","iopub.status.idle":"2023-03-11T09:35:56.997672Z","shell.execute_reply.started":"2023-03-11T09:18:00.527452Z","shell.execute_reply":"2023-03-11T09:35:56.996317Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### After 20 epochs,\n\n* **Loss:** 0.2476\n* **Accuracy:** 0.7494\n* **Root Mean Squared Error:** 0.1066\n* **Validation loss:** 0.2443\n* **Validation Accuracy:** 0.7567\n* **Validation Root Mean Squared Error:** 0.1035","metadata":{}},{"cell_type":"markdown","source":"#### Generate predictions on test data\n\nChoosing only 1000 images, as more will crash kaggle due to memory limits","metadata":{"id":"vyXcpnM5ynue"}},{"cell_type":"code","source":"import os\nfrom tqdm import tqdm\nbatch_size = 1\ndef test_image_generator(ids, shape=IMG_SHAPE):\n    x1 = (ORIG_SHAPE[0]-CROP_SIZE[0])//2\n    y1 = (ORIG_SHAPE[1]-CROP_SIZE[1])//2\n    x_batch = []\n    for i in ids:\n        x = get_image('/kaggle/working/images_test_rev1/'+i, x1, y1, shape=IMG_SHAPE, crop_size=CROP_SIZE)\n        x_batch.append(x)\n    x_batch = np.array(x_batch)\n    return x_batch\n\nval_files = os.listdir('/kaggle/working/images_test_rev1/')\nval_files = val_files[:1000]\nval_predictions = []\nN_val = len(val_files)\nfor i in tqdm(np.arange(0, N_val, batch_size)):\n    if i+batch_size > N_val:\n        upper = N_val\n    else:\n        upper = i+batch_size\n    X = test_image_generator(val_files[i:upper])\n    y_pred = model.predict(X, verbose=0)\n    val_predictions.append(y_pred)\nval_predictions = np.array(val_predictions)\nY_pred = np.vstack(val_predictions)\nids = np.array([v.split('.')[0] for v in val_files]).reshape(len(val_files),1)\nsubmission_df = pd.DataFrame(np.hstack((ids, Y_pred)), columns=df.columns)\nsubmission_df = submission_df.sort_values(by=['GalaxyID'])\nsubmission_df.to_csv('sample_submission.csv', index=False)","metadata":{"id":"myRvt_rdzKh0","execution":{"iopub.status.busy":"2023-03-11T09:37:41.858737Z","iopub.execute_input":"2023-03-11T09:37:41.859459Z","iopub.status.idle":"2023-03-11T09:41:12.584438Z","shell.execute_reply.started":"2023-03-11T09:37:41.859421Z","shell.execute_reply":"2023-03-11T09:41:12.582643Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Check the predictions","metadata":{}},{"cell_type":"code","source":"submission_df[:10]","metadata":{"id":"3asN-3hJyWwg","execution":{"iopub.status.busy":"2023-03-11T09:41:52.565532Z","iopub.execute_input":"2023-03-11T09:41:52.566503Z","iopub.status.idle":"2023-03-11T09:41:52.596082Z","shell.execute_reply.started":"2023-03-11T09:41:52.566464Z","shell.execute_reply":"2023-03-11T09:41:52.594989Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\"\"\"val_files = os.listdir('/kaggle/working/images_test_rev1/')\n\nlen(val_files)\n\nsub_ten = submission_df[:10]\n\nlabels = sub_ten.columns\n\nlabels\n\nlen(labels[1:])\n\nsub_ten['GalaxyID'] = sub_ten['GalaxyID'].astype('int')\n\nsub_ten.loc[:, sub_ten.columns != 'GalaxyID']=sub_ten.loc[:, sub_ten.columns != 'GalaxyID'].astype('float')\n\nsubs = sub_ten.copy()\n\nsub_labels = subs.loc[:, sub_ten.columns != 'GalaxyID'].idxmax(axis=1)\"\"\"","metadata":{"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Make a dataframe with only GalaxyID and Predicted class","metadata":{}},{"cell_type":"code","source":"labels = submission_df.columns","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:44:55.941451Z","iopub.execute_input":"2023-03-11T09:44:55.941873Z","iopub.status.idle":"2023-03-11T09:44:55.947499Z","shell.execute_reply.started":"2023-03-11T09:44:55.941828Z","shell.execute_reply":"2023-03-11T09:44:55.946333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels[1:]","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:45:16.517407Z","iopub.execute_input":"2023-03-11T09:45:16.517797Z","iopub.status.idle":"2023-03-11T09:45:16.525352Z","shell.execute_reply.started":"2023-03-11T09:45:16.517763Z","shell.execute_reply":"2023-03-11T09:45:16.524212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n\npairs = list(zip(labels[1:], range(len(labels[1:]))))\n\nlabels_dict = dict(pairs)","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:45:22.028821Z","iopub.execute_input":"2023-03-11T09:45:22.030025Z","iopub.status.idle":"2023-03-11T09:45:22.035379Z","shell.execute_reply.started":"2023-03-11T09:45:22.029960Z","shell.execute_reply":"2023-03-11T09:45:22.034306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_dict","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:45:28.596458Z","iopub.execute_input":"2023-03-11T09:45:28.596873Z","iopub.status.idle":"2023-03-11T09:45:28.605066Z","shell.execute_reply.started":"2023-03-11T09:45:28.596832Z","shell.execute_reply":"2023-03-11T09:45:28.603751Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df = submission_df.copy()\n\nsub_df['GalaxyID'] = sub_df['GalaxyID'].astype('int')\nsub_df.loc[:, sub_df.columns != 'GalaxyID']=sub_df.loc[:, sub_df.columns != 'GalaxyID'].astype('float')\nsub_labels = sub_df.loc[:, sub_df.columns != 'GalaxyID'].idxmax(axis=1)","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:46:03.093520Z","iopub.execute_input":"2023-03-11T09:46:03.093919Z","iopub.status.idle":"2023-03-11T09:46:03.166310Z","shell.execute_reply.started":"2023-03-11T09:46:03.093879Z","shell.execute_reply":"2023-03-11T09:46:03.165231Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_labels.describe()","metadata":{"execution":{"iopub.status.busy":"2023-03-11T10:05:42.106068Z","iopub.execute_input":"2023-03-11T10:05:42.107037Z","iopub.status.idle":"2023-03-11T10:05:42.118927Z","shell.execute_reply.started":"2023-03-11T10:05:42.106972Z","shell.execute_reply":"2023-03-11T10:05:42.117864Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_dict","metadata":{"execution":{"iopub.status.busy":"2023-03-11T10:05:52.282701Z","iopub.execute_input":"2023-03-11T10:05:52.283106Z","iopub.status.idle":"2023-03-11T10:05:52.297413Z","shell.execute_reply.started":"2023-03-11T10:05:52.283053Z","shell.execute_reply":"2023-03-11T10:05:52.294271Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred_class = [labels_dict[label] for label in sub_labels]","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:46:30.636983Z","iopub.execute_input":"2023-03-11T09:46:30.637687Z","iopub.status.idle":"2023-03-11T09:46:30.643222Z","shell.execute_reply.started":"2023-03-11T09:46:30.637648Z","shell.execute_reply":"2023-03-11T09:46:30.641929Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df['Pred_class'] = pred_class","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:46:39.032365Z","iopub.execute_input":"2023-03-11T09:46:39.033380Z","iopub.status.idle":"2023-03-11T09:46:39.041618Z","shell.execute_reply.started":"2023-03-11T09:46:39.033320Z","shell.execute_reply":"2023-03-11T09:46:39.040496Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:46:41.129890Z","iopub.execute_input":"2023-03-11T09:46:41.130948Z","iopub.status.idle":"2023-03-11T09:46:41.162740Z","shell.execute_reply.started":"2023-03-11T09:46:41.130884Z","shell.execute_reply":"2023-03-11T09:46:41.161357Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = sub_df.copy()","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:46:50.108981Z","iopub.execute_input":"2023-03-11T09:46:50.109388Z","iopub.status.idle":"2023-03-11T09:46:50.116649Z","shell.execute_reply.started":"2023-03-11T09:46:50.109351Z","shell.execute_reply":"2023-03-11T09:46:50.115555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = predictions.loc[:,['GalaxyID', 'Pred_class']]","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:46:52.805141Z","iopub.execute_input":"2023-03-11T09:46:52.805528Z","iopub.status.idle":"2023-03-11T09:46:52.813604Z","shell.execute_reply.started":"2023-03-11T09:46:52.805487Z","shell.execute_reply":"2023-03-11T09:46:52.812027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions","metadata":{"execution":{"iopub.status.busy":"2023-03-11T09:46:55.323244Z","iopub.execute_input":"2023-03-11T09:46:55.323976Z","iopub.status.idle":"2023-03-11T09:46:55.334907Z","shell.execute_reply.started":"2023-03-11T09:46:55.323933Z","shell.execute_reply":"2023-03-11T09:46:55.333690Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Thanks for reading so far! Feel free to fork this notebook and add your own inputs and experiment! Happy EDA! Do drop any questions or tips for improvements in the comments, and dont forget to Upvote! For more such projects and ML in general, like computer vision, NLP and deep learning , visit my [Github/shibinjudahpaul](https://github.com/shibinjudahpaul)","metadata":{}}]}