{"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)\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\n'''\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":"2023-03-29T06:31:10.980056Z","iopub.execute_input":"2023-03-29T06:31:10.981066Z","iopub.status.idle":"2023-03-29T06:31:10.990454Z","shell.execute_reply.started":"2023-03-29T06:31:10.981026Z","shell.execute_reply":"2023-03-29T06:31:10.989418Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install torch torchvision","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:10.992411Z","iopub.execute_input":"2023-03-29T06:31:10.993597Z","iopub.status.idle":"2023-03-29T06:31:21.058300Z","shell.execute_reply.started":"2023-03-29T06:31:10.993559Z","shell.execute_reply":"2023-03-29T06:31:21.056996Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"! pip install torchxrayvision","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:21.061175Z","iopub.execute_input":"2023-03-29T06:31:21.061578Z","iopub.status.idle":"2023-03-29T06:31:30.723751Z","shell.execute_reply.started":"2023-03-29T06:31:21.061533Z","shell.execute_reply":"2023-03-29T06:31:30.722522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import torch\nfrom torch.utils.data import Dataset, DataLoader\nfrom torchvision import transforms\nimport skimage\ndevice = torch.device(\"cuda\")\n\nclass MyDataset(Dataset):\n    def __init__(self, image_ids, image_paths, transform=None):\n        self.image_ids = image_ids\n        self.image_paths = image_paths\n        self.transform = transform\n\n    def __len__(self):\n        return len(self.image_ids)\n\n    def __getitem__(self, idx):\n        img = skimage.io.imread(self.image_paths[idx])\n        img = xrv.datasets.normalize(img, 255) # convert 8-bit image to [-1024, 1024] range\n        img = img.mean(2)[None, ...] # Make single color channel\n        if self.transform:\n            img = self.transform(img)\n            img = torch.from_numpy(img)\n        \n        img = img.to(device)  # move the image tensor to the GPU\n        return self.image_ids[idx], img\n\n# Example usage\nbatch_size = 128","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:30.725687Z","iopub.execute_input":"2023-03-29T06:31:30.726679Z","iopub.status.idle":"2023-03-29T06:31:30.737853Z","shell.execute_reply.started":"2023-03-29T06:31:30.726641Z","shell.execute_reply":"2023-03-29T06:31:30.736580Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import torchxrayvision as xrv\nimport  torch, torchvision\nimport gc\n\n# Prepare the image:\n\n#model = xrv.models.DenseNet(weights=\"densenet121-res224-all\")\n#model = xrv.models.DenseNet(weights=\"densenet121-res224-chex\")\nmodel = xrv.models.ResNet(weights=\"resnet50-res512-all\")\nmodel.to(device)\n    \ntransform = torchvision.transforms.Compose([xrv.datasets.XRayCenterCrop(),xrv.datasets.XRayResizer(512)])\n\n\n\ndef extract_image_features(image_ids, image_paths):\n    dataset = MyDataset(image_ids, image_paths, transform=transform)\n    dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=False)\n    \n    feature_list=[]\n    id_list=[]\n    for batch_idx, (ids, images) in enumerate(dataloader):\n        \n        #print(f'Batch {batch_idx}: IDs = {ids}, Images = {images.shape}')\n        with torch.no_grad():\n            batch_features = model.features(images)\n        feature_list.extend(batch_features.cpu().squeeze().numpy().tolist())\n        id_list.extend( ids.cpu().numpy().tolist())\n    \n    features_df = pd.DataFrame({'imageId': id_list, 'features': feature_list})\n    return features_df","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:30.741335Z","iopub.execute_input":"2023-03-29T06:31:30.741708Z","iopub.status.idle":"2023-03-29T06:31:31.501959Z","shell.execute_reply.started":"2023-03-29T06:31:30.741669Z","shell.execute_reply":"2023-03-29T06:31:31.500769Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def number_to_filename(number):\n    filename = f\"{number:06d}.png\"\n    path = '/kaggle/input/spr-x-ray-age/kaggle/kaggle/train/'\n    filename = path+filename\n    return filename\n","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:31.503372Z","iopub.execute_input":"2023-03-29T06:31:31.504020Z","iopub.status.idle":"2023-03-29T06:31:31.509468Z","shell.execute_reply.started":"2023-03-29T06:31:31.503978Z","shell.execute_reply":"2023-03-29T06:31:31.508376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_age_df=pd.read_csv('/kaggle/input/spr-x-ray-age/train_age.csv')","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:31.510968Z","iopub.execute_input":"2023-03-29T06:31:31.511611Z","iopub.status.idle":"2023-03-29T06:31:31.528681Z","shell.execute_reply.started":"2023-03-29T06:31:31.511569Z","shell.execute_reply":"2023-03-29T06:31:31.527781Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_age_df['filepath'] = train_age_df['imageId'].apply(number_to_filename)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:31.531613Z","iopub.execute_input":"2023-03-29T06:31:31.531879Z","iopub.status.idle":"2023-03-29T06:31:31.544032Z","shell.execute_reply.started":"2023-03-29T06:31:31.531853Z","shell.execute_reply":"2023-03-29T06:31:31.542842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_age_df.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:31.545359Z","iopub.execute_input":"2023-03-29T06:31:31.546211Z","iopub.status.idle":"2023-03-29T06:31:31.561514Z","shell.execute_reply.started":"2023-03-29T06:31:31.546174Z","shell.execute_reply":"2023-03-29T06:31:31.559961Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_age_df['age'].hist()","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:31.563012Z","iopub.execute_input":"2023-03-29T06:31:31.563534Z","iopub.status.idle":"2023-03-29T06:31:31.807103Z","shell.execute_reply.started":"2023-03-29T06:31:31.563497Z","shell.execute_reply":"2023-03-29T06:31:31.805870Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from matplotlib import pyplot as plt\nimport cv2\n\nimg = cv2.imread(train_age_df['filepath'][0],0)\nplt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))\nplt.title(str(train_age_df['age'][0]))","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:31.811394Z","iopub.execute_input":"2023-03-29T06:31:31.811694Z","iopub.status.idle":"2023-03-29T06:31:32.250839Z","shell.execute_reply.started":"2023-03-29T06:31:31.811666Z","shell.execute_reply":"2023-03-29T06:31:32.249822Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img = cv2.imread(train_age_df['filepath'][0],0)\nplt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))\nplt.title(str(train_age_df['age'][100]))","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:32.252409Z","iopub.execute_input":"2023-03-29T06:31:32.253077Z","iopub.status.idle":"2023-03-29T06:31:32.683463Z","shell.execute_reply.started":"2023-03-29T06:31:32.253040Z","shell.execute_reply":"2023-03-29T06:31:32.682411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img = cv2.imread(train_age_df['filepath'][0],0)\nplt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))\nplt.title(str(train_age_df['age'][500]))","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:32.684817Z","iopub.execute_input":"2023-03-29T06:31:32.685809Z","iopub.status.idle":"2023-03-29T06:31:33.119035Z","shell.execute_reply.started":"2023-03-29T06:31:32.685770Z","shell.execute_reply":"2023-03-29T06:31:33.117939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampled_df = train_age_df.groupby('age').apply(lambda x: x.sample(frac=0.95, replace=False)).reset_index(drop=True)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:33.120483Z","iopub.execute_input":"2023-03-29T06:31:33.121496Z","iopub.status.idle":"2023-03-29T06:31:33.166196Z","shell.execute_reply.started":"2023-03-29T06:31:33.121454Z","shell.execute_reply":"2023-03-29T06:31:33.165030Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"features_df = extract_image_features(sampled_df['imageId'].tolist(), sampled_df['filepath'].tolist())","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:31:33.167526Z","iopub.execute_input":"2023-03-29T06:31:33.168200Z","iopub.status.idle":"2023-03-29T06:41:57.017598Z","shell.execute_reply.started":"2023-03-29T06:31:33.168159Z","shell.execute_reply":"2023-03-29T06:41:57.016501Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"features_df.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:41:57.019272Z","iopub.execute_input":"2023-03-29T06:41:57.019672Z","iopub.status.idle":"2023-03-29T06:41:57.040408Z","shell.execute_reply.started":"2023-03-29T06:41:57.019631Z","shell.execute_reply":"2023-03-29T06:41:57.039336Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_df = pd.merge(sampled_df, features_df, on='imageId')","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:41:57.042106Z","iopub.execute_input":"2023-03-29T06:41:57.042466Z","iopub.status.idle":"2023-03-29T06:41:57.064666Z","shell.execute_reply.started":"2023-03-29T06:41:57.042431Z","shell.execute_reply":"2023-03-29T06:41:57.063767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_df.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:41:57.065891Z","iopub.execute_input":"2023-03-29T06:41:57.066267Z","iopub.status.idle":"2023-03-29T06:41:57.089170Z","shell.execute_reply.started":"2023-03-29T06:41:57.066229Z","shell.execute_reply":"2023-03-29T06:41:57.087978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"split_columns = training_df['features'].apply(pd.Series)\n","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:41:57.090569Z","iopub.execute_input":"2023-03-29T06:41:57.091219Z","iopub.status.idle":"2023-03-29T06:41:59.930250Z","shell.execute_reply.started":"2023-03-29T06:41:57.091179Z","shell.execute_reply":"2023-03-29T06:41:59.929136Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_df = pd.concat([training_df.drop('features', axis=1), split_columns], axis=1)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:41:59.931967Z","iopub.execute_input":"2023-03-29T06:41:59.932767Z","iopub.status.idle":"2023-03-29T06:41:59.974819Z","shell.execute_reply.started":"2023-03-29T06:41:59.932727Z","shell.execute_reply":"2023-03-29T06:41:59.973632Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mod_training_df = training_df.drop(columns=['filepath','imageId'])","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:41:59.976517Z","iopub.execute_input":"2023-03-29T06:41:59.976951Z","iopub.status.idle":"2023-03-29T06:42:00.067760Z","shell.execute_reply.started":"2023-03-29T06:41:59.976893Z","shell.execute_reply":"2023-03-29T06:42:00.066725Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mod_training_df.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:00.069458Z","iopub.execute_input":"2023-03-29T06:42:00.069847Z","iopub.status.idle":"2023-03-29T06:42:00.104876Z","shell.execute_reply.started":"2023-03-29T06:42:00.069808Z","shell.execute_reply":"2023-03-29T06:42:00.103707Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#from sklearn.linear_model import ElasticNet\nfrom sklearn.ensemble import GradientBoostingRegressor\n#from sklearn.ensemble import RandomForestRegressor\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import mean_squared_error, r2_score\nfrom sklearn.pipeline import Pipeline\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn import decomposition","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:00.106325Z","iopub.execute_input":"2023-03-29T06:42:00.107332Z","iopub.status.idle":"2023-03-29T06:42:00.437036Z","shell.execute_reply.started":"2023-03-29T06:42:00.107295Z","shell.execute_reply":"2023-03-29T06:42:00.436034Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pipeline = Pipeline([\n    \n    ('standard_scaler', StandardScaler()),\n    ('gradient_regression', GradientBoostingRegressor())\n])","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:00.438392Z","iopub.execute_input":"2023-03-29T06:42:00.439501Z","iopub.status.idle":"2023-03-29T06:42:00.445373Z","shell.execute_reply.started":"2023-03-29T06:42:00.439461Z","shell.execute_reply":"2023-03-29T06:42:00.443797Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"features = mod_training_df.drop('age',axis=1)\ntarget = mod_training_df['age']\nX_train, X_test, y_train, y_test = train_test_split(features, target,stratify=target, test_size=0.2, random_state=0)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:00.446761Z","iopub.execute_input":"2023-03-29T06:42:00.447215Z","iopub.status.idle":"2023-03-29T06:42:00.532611Z","shell.execute_reply.started":"2023-03-29T06:42:00.447177Z","shell.execute_reply":"2023-03-29T06:42:00.531309Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:00.534093Z","iopub.execute_input":"2023-03-29T06:42:00.534575Z","iopub.status.idle":"2023-03-29T06:42:00.571844Z","shell.execute_reply.started":"2023-03-29T06:42:00.534537Z","shell.execute_reply":"2023-03-29T06:42:00.570944Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_test","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:00.573325Z","iopub.execute_input":"2023-03-29T06:42:00.573768Z","iopub.status.idle":"2023-03-29T06:42:00.609834Z","shell.execute_reply.started":"2023-03-29T06:42:00.573727Z","shell.execute_reply":"2023-03-29T06:42:00.608698Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pipeline.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:00.611210Z","iopub.execute_input":"2023-03-29T06:42:00.611630Z","iopub.status.idle":"2023-03-29T06:42:26.472084Z","shell.execute_reply.started":"2023-03-29T06:42:00.611586Z","shell.execute_reply":"2023-03-29T06:42:26.471105Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = pipeline.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:26.477722Z","iopub.execute_input":"2023-03-29T06:42:26.478032Z","iopub.status.idle":"2023-03-29T06:42:26.521983Z","shell.execute_reply.started":"2023-03-29T06:42:26.478004Z","shell.execute_reply":"2023-03-29T06:42:26.520968Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import mean_absolute_error\nmae = mean_absolute_error(y_test, y_pred)\nr2 = r2_score(y_test, y_pred)\n\nprint(f\"Mean Squared Error: {mae:.2f}\")\nprint(f\"R-squared: {r2:.2f}\")","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:26.523422Z","iopub.execute_input":"2023-03-29T06:42:26.524015Z","iopub.status.idle":"2023-03-29T06:42:26.533513Z","shell.execute_reply.started":"2023-03-29T06:42:26.523976Z","shell.execute_reply":"2023-03-29T06:42:26.532325Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = pd.read_csv('/kaggle/input/spr-x-ray-age/sample_submission_age.csv')\n","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:26.535206Z","iopub.execute_input":"2023-03-29T06:42:26.535986Z","iopub.status.idle":"2023-03-29T06:42:26.549476Z","shell.execute_reply.started":"2023-03-29T06:42:26.535946Z","shell.execute_reply":"2023-03-29T06:42:26.548540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def testnumber_to_filename(number):\n    filename = f\"{number:06d}.png\"\n    path = '/kaggle/input/spr-x-ray-age/kaggle/kaggle/test/'\n    filename = path+filename\n    return filename","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:26.550982Z","iopub.execute_input":"2023-03-29T06:42:26.551344Z","iopub.status.idle":"2023-03-29T06:42:26.556579Z","shell.execute_reply.started":"2023-03-29T06:42:26.551308Z","shell.execute_reply":"2023-03-29T06:42:26.555395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['filepath'] = test_df['imageId'].apply(testnumber_to_filename)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:26.558255Z","iopub.execute_input":"2023-03-29T06:42:26.559001Z","iopub.status.idle":"2023-03-29T06:42:26.574060Z","shell.execute_reply.started":"2023-03-29T06:42:26.558963Z","shell.execute_reply":"2023-03-29T06:42:26.573135Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:26.575372Z","iopub.execute_input":"2023-03-29T06:42:26.575892Z","iopub.status.idle":"2023-03-29T06:42:26.586450Z","shell.execute_reply.started":"2023-03-29T06:42:26.575855Z","shell.execute_reply":"2023-03-29T06:42:26.584981Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_features_df = extract_image_features(test_df['imageId'].tolist(), test_df['filepath'].tolist())","metadata":{"execution":{"iopub.status.busy":"2023-03-29T06:42:26.588185Z","iopub.execute_input":"2023-03-29T06:42:26.588587Z","iopub.status.idle":"2023-03-29T07:05:29.387811Z","shell.execute_reply.started":"2023-03-29T06:42:26.588552Z","shell.execute_reply":"2023-03-29T07:05:29.386753Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_features_df.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:20:05.182533Z","iopub.execute_input":"2023-03-29T07:20:05.183065Z","iopub.status.idle":"2023-03-29T07:20:05.217317Z","shell.execute_reply.started":"2023-03-29T07:20:05.183018Z","shell.execute_reply":"2023-03-29T07:20:05.216267Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df_final = pd.merge(test_features_df, test_df, on='imageId')","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:05:29.389239Z","iopub.execute_input":"2023-03-29T07:05:29.389701Z","iopub.status.idle":"2023-03-29T07:05:29.401979Z","shell.execute_reply.started":"2023-03-29T07:05:29.389662Z","shell.execute_reply":"2023-03-29T07:05:29.400929Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"split_columns = test_df_final['features'].apply(pd.Series)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:05:29.403637Z","iopub.execute_input":"2023-03-29T07:05:29.404035Z","iopub.status.idle":"2023-03-29T07:05:35.642694Z","shell.execute_reply.started":"2023-03-29T07:05:29.403998Z","shell.execute_reply":"2023-03-29T07:05:35.641636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df_final = pd.concat([test_df_final.drop('features', axis=1), split_columns], axis=1)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:05:35.644316Z","iopub.execute_input":"2023-03-29T07:05:35.644712Z","iopub.status.idle":"2023-03-29T07:05:35.696650Z","shell.execute_reply.started":"2023-03-29T07:05:35.644671Z","shell.execute_reply":"2023-03-29T07:05:35.694821Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mod_test_df = test_df_final.drop(columns=['filepath','imageId'])","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:05:35.703517Z","iopub.execute_input":"2023-03-29T07:05:35.706189Z","iopub.status.idle":"2023-03-29T07:05:35.768431Z","shell.execute_reply.started":"2023-03-29T07:05:35.706150Z","shell.execute_reply":"2023-03-29T07:05:35.767390Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"features = mod_test_df.drop('age',axis=1)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:05:35.770081Z","iopub.execute_input":"2023-03-29T07:05:35.770476Z","iopub.status.idle":"2023-03-29T07:05:35.939389Z","shell.execute_reply.started":"2023-03-29T07:05:35.770437Z","shell.execute_reply":"2023-03-29T07:05:35.938317Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"features","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:20:21.131685Z","iopub.execute_input":"2023-03-29T07:20:21.132088Z","iopub.status.idle":"2023-03-29T07:20:21.170555Z","shell.execute_reply.started":"2023-03-29T07:20:21.132052Z","shell.execute_reply":"2023-03-29T07:20:21.169407Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = pipeline.predict(features)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:05:35.940845Z","iopub.execute_input":"2023-03-29T07:05:35.941252Z","iopub.status.idle":"2023-03-29T07:05:36.397674Z","shell.execute_reply.started":"2023-03-29T07:05:35.941214Z","shell.execute_reply":"2023-03-29T07:05:36.396546Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:19:47.056511Z","iopub.execute_input":"2023-03-29T07:19:47.057299Z","iopub.status.idle":"2023-03-29T07:19:47.067184Z","shell.execute_reply.started":"2023-03-29T07:19:47.057255Z","shell.execute_reply":"2023-03-29T07:19:47.065658Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['age']=y_pred","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:05:36.399134Z","iopub.execute_input":"2023-03-29T07:05:36.399481Z","iopub.status.idle":"2023-03-29T07:05:36.405098Z","shell.execute_reply.started":"2023-03-29T07:05:36.399442Z","shell.execute_reply":"2023-03-29T07:05:36.403987Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df[['imageId', 'age']].to_csv(\"submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:05:36.406772Z","iopub.execute_input":"2023-03-29T07:05:36.407580Z","iopub.status.idle":"2023-03-29T07:05:36.438951Z","shell.execute_reply.started":"2023-03-29T07:05:36.407540Z","shell.execute_reply":"2023-03-29T07:05:36.438040Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}