{"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":"# Libraries that we will use\n\nimport numpy as np\nimport pandas as pd\nimport os\nfrom tqdm import tqdm\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom wordcloud import WordCloud, STOPWORDS\nfrom datetime import datetime\nfrom PIL import Image\nfrom sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:34:38.902087Z","iopub.execute_input":"2023-04-28T12:34:38.902509Z","iopub.status.idle":"2023-04-28T12:34:40.321524Z","shell.execute_reply.started":"2023-04-28T12:34:38.902467Z","shell.execute_reply":"2023-04-28T12:34:40.320124Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.listdir(\"/kaggle/input\")","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:34:47.227241Z","iopub.execute_input":"2023-04-28T12:34:47.227692Z","iopub.status.idle":"2023-04-28T12:34:47.237477Z","shell.execute_reply.started":"2023-04-28T12:34:47.227634Z","shell.execute_reply":"2023-04-28T12:34:47.236411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"files and folders: {os.listdir('/kaggle/input/asl-signs')}\")\nprint(\"Subfolders in images folder: \", len(list(os.listdir(\"/kaggle/input/asl-signs\"))))","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:34:51.243854Z","iopub.execute_input":"2023-04-28T12:34:51.244264Z","iopub.status.idle":"2023-04-28T12:34:51.251838Z","shell.execute_reply.started":"2023-04-28T12:34:51.244228Z","shell.execute_reply":"2023-04-28T12:34:51.250341Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#LOADING THE DATA\ntrain = pd.read_csv('/kaggle/input/asl-signs/train.csv')","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:34:55.240282Z","iopub.execute_input":"2023-04-28T12:34:55.240986Z","iopub.status.idle":"2023-04-28T12:34:55.489099Z","shell.execute_reply.started":"2023-04-28T12:34:55.240920Z","shell.execute_reply":"2023-04-28T12:34:55.487793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#CHECK THE FIRST 5 OBSERVATIONS\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:34:59.244557Z","iopub.execute_input":"2023-04-28T12:34:59.245870Z","iopub.status.idle":"2023-04-28T12:34:59.276268Z","shell.execute_reply.started":"2023-04-28T12:34:59.245818Z","shell.execute_reply":"2023-04-28T12:34:59.274954Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#CHECK THE LAST 5 OBSERVATIONS\ntrain.tail()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:35:03.667017Z","iopub.execute_input":"2023-04-28T12:35:03.667452Z","iopub.status.idle":"2023-04-28T12:35:03.679241Z","shell.execute_reply.started":"2023-04-28T12:35:03.667411Z","shell.execute_reply":"2023-04-28T12:35:03.678021Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.shape","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:35:07.276574Z","iopub.execute_input":"2023-04-28T12:35:07.277014Z","iopub.status.idle":"2023-04-28T12:35:07.284290Z","shell.execute_reply.started":"2023-04-28T12:35:07.276976Z","shell.execute_reply":"2023-04-28T12:35:07.283012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:35:10.977858Z","iopub.execute_input":"2023-04-28T12:35:10.978287Z","iopub.status.idle":"2023-04-28T12:35:11.019318Z","shell.execute_reply.started":"2023-04-28T12:35:10.978246Z","shell.execute_reply":"2023-04-28T12:35:11.018099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:35:18.952325Z","iopub.execute_input":"2023-04-28T12:35:18.952791Z","iopub.status.idle":"2023-04-28T12:35:18.981736Z","shell.execute_reply.started":"2023-04-28T12:35:18.952746Z","shell.execute_reply":"2023-04-28T12:35:18.980602Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train['sign'].unique() #250 data types","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:35:25.390670Z","iopub.execute_input":"2023-04-28T12:35:25.391098Z","iopub.status.idle":"2023-04-28T12:35:25.406817Z","shell.execute_reply.started":"2023-04-28T12:35:25.391049Z","shell.execute_reply":"2023-04-28T12:35:25.405153Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def unique_col_values(df):\n    for column in df:\n        print(\"{} | {} | {}\".format(df[column].name, len(df[column].unique()),\n                                   df[column].dtype))\n        \nunique_col_values(train)","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:35:33.158868Z","iopub.execute_input":"2023-04-28T12:35:33.159311Z","iopub.status.idle":"2023-04-28T12:35:33.206708Z","shell.execute_reply.started":"2023-04-28T12:35:33.159272Z","shell.execute_reply":"2023-04-28T12:35:33.205213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:35:37.698328Z","iopub.execute_input":"2023-04-28T12:35:37.698760Z","iopub.status.idle":"2023-04-28T12:35:37.718925Z","shell.execute_reply.started":"2023-04-28T12:35:37.698719Z","shell.execute_reply":"2023-04-28T12:35:37.717610Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.duplicated().sum()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:35:42.150071Z","iopub.execute_input":"2023-04-28T12:35:42.151369Z","iopub.status.idle":"2023-04-28T12:35:42.205795Z","shell.execute_reply.started":"2023-04-28T12:35:42.151318Z","shell.execute_reply":"2023-04-28T12:35:42.204722Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.participant_id.value_counts().plot(kind=\"bar\")","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:35:46.685569Z","iopub.execute_input":"2023-04-28T12:35:46.686673Z","iopub.status.idle":"2023-04-28T12:35:47.054499Z","shell.execute_reply.started":"2023-04-28T12:35:46.686611Z","shell.execute_reply":"2023-04-28T12:35:47.053356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"CLASSES_STR= \"\"\nfor sign in train[\"sign\"]:\n    CLASSES_STR+= sign+\" \"\n\nwordcloud = WordCloud(width = 800, height = 800,\n                background_color ='white',\n                min_font_size = 10).generate(CLASSES_STR)\n\n# plot the WordCloud image                      \nplt.figure(figsize = (8, 8), facecolor = None)\nplt.imshow(wordcloud)\nplt.axis(\"off\")\nplt.tight_layout(pad = 0)\n \nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:35:53.695948Z","iopub.execute_input":"2023-04-28T12:35:53.696792Z","iopub.status.idle":"2023-04-28T12:35:55.849806Z","shell.execute_reply.started":"2023-04-28T12:35:53.696742Z","shell.execute_reply":"2023-04-28T12:35:55.848584Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.boxplot(x='participant_id', data=train)","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:36:41.249821Z","iopub.execute_input":"2023-04-28T12:36:41.250251Z","iopub.status.idle":"2023-04-28T12:36:41.431279Z","shell.execute_reply.started":"2023-04-28T12:36:41.250204Z","shell.execute_reply":"2023-04-28T12:36:41.429939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(x='participant_id', data=train, )\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:36:09.548699Z","iopub.execute_input":"2023-04-28T12:36:09.549197Z","iopub.status.idle":"2023-04-28T12:36:09.892743Z","shell.execute_reply.started":"2023-04-28T12:36:09.549145Z","shell.execute_reply":"2023-04-28T12:36:09.891522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**21 MARCH 2023**","metadata":{}},{"cell_type":"code","source":"temp = train.groupby([\"sign\"])[\"participant_id\"].count()\ndf = pd.DataFrame({'Sign': temp.index,\n                   'Number of Attempts': temp.values\n                  })\ndf = df.sort_values(['Sign'], ascending=False)[0:20]\nplt.figure(figsize = (16,6))\nplt.title(f'Number of Participants per Sign')\nsns.set_color_codes(\"pastel\")\ns = sns.barplot(x = 'Sign', y=\"Number of Attempts\", data=df)\ns.set_xticklabels(s.get_xticklabels(),rotation=90)\nlocs, labels = plt.xticks()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:36:46.320403Z","iopub.execute_input":"2023-04-28T12:36:46.320957Z","iopub.status.idle":"2023-04-28T12:36:46.740766Z","shell.execute_reply.started":"2023-04-28T12:36:46.320904Z","shell.execute_reply":"2023-04-28T12:36:46.739814Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(15,6))\nsns.lineplot(x = train['sign'].head(250), y = train ['participant_id'].head(50), data = train,\n            palette = 'hls')\nplt.xticks(rotation = 90)\nplt.show\n","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:36:54.613402Z","iopub.execute_input":"2023-04-28T12:36:54.613963Z","iopub.status.idle":"2023-04-28T12:36:55.514913Z","shell.execute_reply.started":"2023-04-28T12:36:54.613909Z","shell.execute_reply":"2023-04-28T12:36:55.513720Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(15,6))\nsns.scatterplot(x = train['sign'].head(250), y = train ['participant_id'].head(50), data = train,\n            palette = 'hls')\nplt.xticks(rotation = 90)\nplt.show\n","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:37:01.127438Z","iopub.execute_input":"2023-04-28T12:37:01.128796Z","iopub.status.idle":"2023-04-28T12:37:01.990502Z","shell.execute_reply.started":"2023-04-28T12:37:01.128750Z","shell.execute_reply":"2023-04-28T12:37:01.989502Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Visualizations of building a machine learning Model (still in progress)","metadata":{"execution":{"iopub.status.busy":"2023-04-24T11:56:09.123126Z","iopub.execute_input":"2023-04-24T11:56:09.123868Z","iopub.status.idle":"2023-04-24T11:56:09.129413Z","shell.execute_reply.started":"2023-04-24T11:56:09.123821Z","shell.execute_reply":"2023-04-24T11:56:09.127855Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nplt.figure(figsize=(12,6))\n  \nsns.heatmap(train.corr(),\n            cmap='BrBG',\n            fmt='.2f',\n            linewidths=2,\n            annot=True)","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:37:14.031918Z","iopub.execute_input":"2023-04-28T12:37:14.032323Z","iopub.status.idle":"2023-04-28T12:37:14.311723Z","shell.execute_reply.started":"2023-04-28T12:37:14.032288Z","shell.execute_reply":"2023-04-28T12:37:14.310752Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lis2 = ['sign', 'participant_id']\nplt.subplots(figsize=(10, 5))\nindex = 1\n  \nfor col in lis2:\n\n    y = train[col].value_counts()\n    plt.subplot(1, 2, index)\n    plt.xticks(rotation=90) \n    sns.barplot(x=list(y.index), y=y)\n  ","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:37:22.035109Z","iopub.execute_input":"2023-04-28T12:37:22.035548Z","iopub.status.idle":"2023-04-28T12:37:23.832903Z","shell.execute_reply.started":"2023-04-28T12:37:22.035510Z","shell.execute_reply":"2023-04-28T12:37:23.831690Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"\nsince we have 21 unique participants with diffrent ID's the output seems to be counting the number of signs generated/made by each ID","metadata":{}},{"cell_type":"code","source":"import pandas as pd \nimport numpy as np                    \nimport seaborn as sns \n","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:37:28.699052Z","iopub.execute_input":"2023-04-28T12:37:28.699454Z","iopub.status.idle":"2023-04-28T12:37:28.705425Z","shell.execute_reply.started":"2023-04-28T12:37:28.699418Z","shell.execute_reply":"2023-04-28T12:37:28.703959Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"parquet_file = '/kaggle/input/asl-signs/train_landmark_files/16069/100015657.parquet'\nnew_parquet_df = pd.read_parquet(parquet_file)","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:37:35.019699Z","iopub.execute_input":"2023-04-28T12:37:35.020142Z","iopub.status.idle":"2023-04-28T12:37:35.224153Z","shell.execute_reply.started":"2023-04-28T12:37:35.020106Z","shell.execute_reply":"2023-04-28T12:37:35.222903Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sign_to_prediction_index_map = {\n                                  \"TV\": 0,\n                                  \"after\": 1,\n                                  \"airplane\": 2,\n                                  \"all\": 3,\n                                  \"alligator\": 4,\n                                  \"animal\": 5,\n                                  \"another\": 6,\n                                  \"any\": 7,\n                                  \"apple\": 8,\n                                  \"arm\": 9,\n                                  \"aunt\": 10,\n                                  \"awake\": 11,\n                                  \"backyard\": 12,\n                                  \"bad\": 13,\n                                  \"balloon\": 14,\n                                  \"bath\": 15,\n                                  \"because\": 16,\n                                  \"bed\": 17,\n                                  \"bedroom\": 18,\n                                  \"bee\": 19,\n                                  \"before\": 20,\n                                  \"beside\": 21,\n                                  \"better\": 22,\n                                  \"bird\": 23,\n                                  \"black\": 24,\n                                  \"blow\": 25,\n                                  \"blue\": 26,\n                                  \"boat\": 27,\n                                  \"book\": 28,\n                                  \"boy\": 29,\n                                  \"brother\": 30,\n                                  \"brown\": 31,\n                                  \"bug\": 32,\n                                  \"bye\": 33,\n                                  \"callonphone\": 34,\n                                  \"can\": 35,\n                                  \"car\": 36,\n                                  \"carrot\": 37,\n                                  \"cat\": 38,\n                                  \"cereal\": 39,\n                                  \"chair\": 40,\n                                  \"cheek\": 41,\n                                  \"child\": 42,\n                                  \"chin\": 43,\n                                  \"chocolate\": 44,\n                                  \"clean\": 45,\n                                  \"close\": 46,\n                                  \"closet\": 47,\n                                  \"cloud\": 48,\n                                  \"clown\": 49,\n                                  \"cow\": 50,\n                                  \"cowboy\": 51,\n                                  \"cry\": 52,\n                                  \"cut\": 53,\n                                  \"cute\": 54,\n                                  \"dad\": 55,\n                                  \"dance\": 56,\n                                  \"dirty\": 57,\n                                  \"dog\": 58,\n                                  \"doll\": 59,\n                                  \"donkey\": 60,\n                                  \"down\": 61,\n                                  \"drawer\": 62,\n                                  \"drink\": 63,\n                                  \"drop\": 64,\n                                  \"dry\": 65,\n                                  \"dryer\": 66,\n                                  \"duck\": 67,\n                                  \"ear\": 68,\n                                  \"elephant\": 69,\n                                  \"empty\": 70,\n                                  \"every\": 71,\n                                  \"eye\": 72,\n                                  \"face\": 73,\n                                  \"fall\": 74,\n                                  \"farm\": 75,\n                                  \"fast\": 76,\n                                  \"feet\": 77,\n                                  \"find\": 78,\n                                  \"fine\": 79,\n                                  \"finger\": 80,\n                                  \"finish\": 81,\n                                  \"fireman\": 82,\n                                  \"first\": 83,\n                                  \"fish\": 84,\n                                  \"flag\": 85,\n                                  \"flower\": 86,\n                                  \"food\": 87,\n                                  \"for\": 88,\n                                  \"frenchfries\": 89,\n                                  \"frog\": 90,\n                                  \"garbage\": 91,\n                                  \"gift\": 92,\n                                  \"giraffe\": 93,\n                                  \"girl\": 94,\n                                  \"give\": 95,\n                                  \"glasswindow\": 96,\n                                  \"go\": 97,\n                                  \"goose\": 98,\n                                  \"grandma\": 99,\n                                  \"grandpa\": 100,\n                                  \"grass\": 101,\n                                  \"green\": 102,\n                                  \"gum\": 103,\n                                  \"hair\": 104,\n                                  \"happy\": 105,\n                                  \"hat\": 106,\n                                  \"hate\": 107,\n                                  \"have\": 108,\n                                  \"haveto\": 109,\n                                  \"head\": 110,\n                                  \"hear\": 111,\n                                  \"helicopter\": 112,\n                                  \"hello\": 113,\n                                  \"hen\": 114,\n                                  \"hesheit\": 115,\n                                  \"hide\": 116,\n                                  \"high\": 117,\n                                  \"home\": 118,\n                                  \"horse\": 119,\n                                  \"hot\": 120,\n                                  \"hungry\": 121,\n                                  \"icecream\": 122,\n                                  \"if\": 123,\n                                  \"into\": 124,\n                                  \"jacket\": 125,\n                                  \"jeans\": 126,\n                                  \"jump\": 127,\n                                  \"kiss\": 128,\n                                  \"kitty\": 129,\n                                  \"lamp\": 130,\n                                  \"later\": 131,\n                                  \"like\": 132,\n                                  \"lion\": 133,\n                                  \"lips\": 134,\n                                  \"listen\": 135,\n                                  \"look\": 136,\n                                  \"loud\": 137,\n                                  \"mad\": 138,\n                                  \"make\": 139,\n                                  \"man\": 140,\n                                  \"many\": 141,\n                                  \"milk\": 142,\n                                  \"minemy\": 143,\n                                  \"mitten\": 144,\n                                  \"mom\": 145,\n                                  \"moon\": 146,\n                                  \"morning\": 147,\n                                  \"mouse\": 148,\n                                  \"mouth\": 149,\n                                  \"nap\": 150,\n                                  \"napkin\": 151,\n                                  \"night\": 152,\n                                  \"no\": 153,\n                                  \"noisy\": 154,\n                                  \"nose\": 155,\n                                  \"not\": 156,\n                                  \"now\": 157,\n                                  \"nuts\": 158,\n                                  \"old\": 159,\n                                  \"on\": 160,\n                                  \"open\": 161,\n                                  \"orange\": 162,\n                                  \"outside\": 163,\n                                  \"owie\": 164,\n                                  \"owl\": 165,\n                                  \"pajamas\": 166,\n                                  \"pen\": 167,\n                                  \"pencil\": 168,\n                                  \"penny\": 169,\n                                  \"person\": 170,\n                                  \"pig\": 171,\n                                  \"pizza\": 172,\n                                  \"please\": 173,\n                                  \"police\": 174,\n                                  \"pool\": 175,\n                                  \"potty\": 176,\n                                  \"pretend\": 177,\n                                  \"pretty\": 178,\n                                  \"puppy\": 179,\n                                  \"puzzle\": 180,\n                                  \"quiet\": 181,\n                                  \"radio\": 182,\n                                  \"rain\": 183,\n                                  \"read\": 184,\n                                  \"red\": 185,\n                                  \"refrigerator\": 186,\n                                  \"ride\": 187,\n                                  \"room\": 188,\n                                  \"sad\": 189,\n                                  \"same\": 190,\n                                  \"say\": 191,\n                                  \"scissors\": 192,\n                                  \"see\": 193,\n                                  \"shhh\": 194,\n                                  \"shirt\": 195,\n                                  \"shoe\": 196,\n                                  \"shower\": 197,\n                                  \"sick\": 198,\n                                  \"sleep\": 199,\n                                  \"sleepy\": 200,\n                                  \"smile\": 201,\n                                  \"snack\": 202,\n                                  \"snow\": 203,\n                                  \"stairs\": 204,\n                                  \"stay\": 205,\n                                  \"sticky\": 206,\n                                  \"store\": 207,\n                                  \"story\": 208,\n                                  \"stuck\": 209,\n                                  \"sun\": 210,\n                                  \"table\": 211,\n                                  \"talk\": 212,\n                                  \"taste\": 213,\n                                  \"thankyou\": 214,\n                                  \"that\": 215,\n                                  \"there\": 216,\n                                  \"think\": 217,\n                                  \"thirsty\": 218,\n                                  \"tiger\": 219,\n                                  \"time\": 220,\n                                  \"tomorrow\": 221,\n                                  \"tongue\": 222,\n                                  \"tooth\": 223,\n                                  \"toothbrush\": 224,\n                                  \"touch\": 225,\n                                  \"toy\": 226,\n                                  \"tree\": 227,\n                                  \"uncle\": 228,\n                                  \"underwear\": 229,\n                                  \"up\": 230,\n                                  \"vacuum\": 231,\n                                  \"wait\": 232,\n                                  \"wake\": 233,\n                                  \"water\": 234,\n                                  \"wet\": 235,\n                                  \"weus\": 236,\n                                  \"where\": 237,\n                                  \"white\": 238,\n                                  \"who\": 239,\n                                  \"why\": 240,\n                                  \"will\": 241,\n                                  \"wolf\": 242,\n                                  \"yellow\": 243,\n                                  \"yes\": 244,\n                                  \"yesterday\": 245,\n                                  \"yourself\": 246,\n                                  \"yucky\": 247,\n                                  \"zebra\": 248,\n                                  \"zipper\": 249\n}","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:37:41.351725Z","iopub.execute_input":"2023-04-28T12:37:41.352150Z","iopub.status.idle":"2023-04-28T12:37:41.384604Z","shell.execute_reply.started":"2023-04-28T12:37:41.352114Z","shell.execute_reply":"2023-04-28T12:37:41.383208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_parquet_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:37:50.418280Z","iopub.execute_input":"2023-04-28T12:37:50.418744Z","iopub.status.idle":"2023-04-28T12:37:50.434479Z","shell.execute_reply.started":"2023-04-28T12:37:50.418700Z","shell.execute_reply":"2023-04-28T12:37:50.433210Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_parquet_df.tail()\n#x,y,z values have missing values\n#NB check how many rows have x,y and z have NaN\n","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:37:56.129789Z","iopub.execute_input":"2023-04-28T12:37:56.130536Z","iopub.status.idle":"2023-04-28T12:37:56.144310Z","shell.execute_reply.started":"2023-04-28T12:37:56.130489Z","shell.execute_reply":"2023-04-28T12:37:56.143351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_parquet_df.shape","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:37:59.189788Z","iopub.execute_input":"2023-04-28T12:37:59.190906Z","iopub.status.idle":"2023-04-28T12:37:59.197761Z","shell.execute_reply.started":"2023-04-28T12:37:59.190863Z","shell.execute_reply":"2023-04-28T12:37:59.196708Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"the landmark file has 57015 observations and 7 columns","metadata":{}},{"cell_type":"code","source":"new_parquet_df.keys()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:38:02.489258Z","iopub.execute_input":"2023-04-28T12:38:02.489718Z","iopub.status.idle":"2023-04-28T12:38:02.498123Z","shell.execute_reply.started":"2023-04-28T12:38:02.489677Z","shell.execute_reply":"2023-04-28T12:38:02.496733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"we have six colums namely frame, row_id, type, landmark_index, 'x', 'y', 'z","metadata":{}},{"cell_type":"code","source":"new_parquet_df.dtypes","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:38:07.793948Z","iopub.execute_input":"2023-04-28T12:38:07.794360Z","iopub.status.idle":"2023-04-28T12:38:07.804438Z","shell.execute_reply.started":"2023-04-28T12:38:07.794322Z","shell.execute_reply":"2023-04-28T12:38:07.802603Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(new_parquet_df['frame'].unique())","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:38:11.140022Z","iopub.execute_input":"2023-04-28T12:38:11.140447Z","iopub.status.idle":"2023-04-28T12:38:11.147808Z","shell.execute_reply.started":"2023-04-28T12:38:11.140410Z","shell.execute_reply":"2023-04-28T12:38:11.146695Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"there are 105 diffrent frames\n","metadata":{}},{"cell_type":"code","source":"#frame list \nnew_parquet_df['frame'].unique()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:38:14.178884Z","iopub.execute_input":"2023-04-28T12:38:14.179314Z","iopub.status.idle":"2023-04-28T12:38:14.188093Z","shell.execute_reply.started":"2023-04-28T12:38:14.179274Z","shell.execute_reply":"2023-04-28T12:38:14.186820Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_parquet_df['type'].unique()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:38:17.497504Z","iopub.execute_input":"2023-04-28T12:38:17.497967Z","iopub.status.idle":"2023-04-28T12:38:17.509666Z","shell.execute_reply.started":"2023-04-28T12:38:17.497924Z","shell.execute_reply":"2023-04-28T12:38:17.508608Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The videos in the dataframes have this features face,left_hand,pose andright_hand","metadata":{}},{"cell_type":"code","source":"import tensorflow as tf\n\n# Load the trained TensorFlow model\nmodel = tf.keras.models.load_model('new_parquet_df')\n\n# Convert the model to TensorFlow Lite format\nconverter = tf.lite.TFLiteConverter.from_keras_model(model)\ntflite_model = converter.convert()\n\n# Save the converted model\nwith open('my_sign_language_model.tflite', 'wb') as f:\n    f.write(tflite_model)","metadata":{"execution":{"iopub.status.busy":"2023-04-28T13:06:23.501386Z","iopub.execute_input":"2023-04-28T13:06:23.501872Z","iopub.status.idle":"2023-04-28T13:06:23.532503Z","shell.execute_reply.started":"2023-04-28T13:06:23.501830Z","shell.execute_reply":"2023-04-28T13:06:23.530978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense, Conv2D, MaxPooling2D, Dropout, Flatten\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\n\n# Data Preparation\ntrain_datagen = ImageDataGenerator(rescale=1./255)\ntest_datagen = ImageDataGenerator(rescale=1./255)\n\ntraining_set = train_datagen.flow_from_directory(\n        'train',\n        target_size=(64, 64),\n        batch_size=32,\n        class_mode='categorical'\n\nnew_parquet_df = test_datagen.flow_from_directory(\n        'new_parquet_df',\n        target_size=(64, 64),\n        batch_size=32,\n        class_mode='categorical'\n\n# Building the Model\nmodel = Sequential()\n\nmodel.add(Conv2D(32, (3, 3), activation='relu', input_shape=(64, 64, 3)))\nmodel.add(MaxPooling2D((2, 2)))\nmodel.add(Conv2D(64, (3, 3), activation='relu'))\nmodel.add(MaxPooling2D((2, 2)))\nmodel.add(Conv2D(128, (3, 3), activation='relu'))\nmodel.add(MaxPooling2D((2, 2)))\nmodel.add(Flatten())\nmodel.add(Dense(256, activation='relu'))\nmodel.add(Dropout(0.5))\nmodel.add(Dense(6, activation='softmax'))\n\nmodel.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])\n\nmodel.fit(\n        training_set,\n        epochs=25,\n        validation_data=test_set)\n\n# Evaluating the Model\ntest_loss, test_acc = model.evaluate(test_set)\n\nprint('Test accuracy:', test_acc)\n","metadata":{"execution":{"iopub.status.busy":"2023-04-28T13:03:21.350974Z","iopub.execute_input":"2023-04-28T13:03:21.351418Z","iopub.status.idle":"2023-04-28T13:03:21.365616Z","shell.execute_reply.started":"2023-04-28T13:03:21.351376Z","shell.execute_reply":"2023-04-28T13:03:21.363993Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"frames = new_parquet_df['frame']\nrowID = new_parquet_df['row_id']\ntypes = new_parquet_df['type']\nlandmark_index = new_parquet_df['landmark_index']\nX = new_parquet_df['x']\nY = new_parquet_df['y']\nZ =  new_parquet_df['z']\n\n\nprint(len(frames))\nprint(len(rowID))\nprint(len(types))\nprint(len(landmark_index))\nprint(len(X))\nprint(len(Y))\nprint(len(Z))","metadata":{"execution":{"iopub.status.busy":"2023-04-28T12:38:23.575966Z","iopub.execute_input":"2023-04-28T12:38:23.576698Z","iopub.status.idle":"2023-04-28T12:38:23.584432Z","shell.execute_reply.started":"2023-04-28T12:38:23.576654Z","shell.execute_reply":"2023-04-28T12:38:23.583125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip show tensorflow","metadata":{"execution":{"iopub.status.busy":"2023-04-28T13:09:53.581938Z","iopub.execute_input":"2023-04-28T13:09:53.583039Z","iopub.status.idle":"2023-04-28T13:10:04.684278Z","shell.execute_reply.started":"2023-04-28T13:09:53.582989Z","shell.execute_reply":"2023-04-28T13:10:04.682815Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install tslearn plotly","metadata":{"execution":{"iopub.status.busy":"2023-04-28T13:10:22.860758Z","iopub.execute_input":"2023-04-28T13:10:22.862303Z","iopub.status.idle":"2023-04-28T13:10:35.424371Z","shell.execute_reply.started":"2023-04-28T13:10:22.862234Z","shell.execute_reply":"2023-04-28T13:10:35.422858Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# mode = \"debugging\"\nmode = \"training\"\n# mode = \"submission\"","metadata":{"execution":{"iopub.status.busy":"2023-04-28T13:11:04.768151Z","iopub.execute_input":"2023-04-28T13:11:04.768651Z","iopub.status.idle":"2023-04-28T13:11:04.774409Z","shell.execute_reply.started":"2023-04-28T13:11:04.768586Z","shell.execute_reply":"2023-04-28T13:11:04.773062Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.read_csv(\"/kaggle/input/asl-signs/train.csv\")\nprint(df_train.shape)\ndf_train.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-04-28T13:11:27.047756Z","iopub.execute_input":"2023-04-28T13:11:27.048204Z","iopub.status.idle":"2023-04-28T13:11:27.192148Z","shell.execute_reply.started":"2023-04-28T13:11:27.048162Z","shell.execute_reply":"2023-04-28T13:11:27.191091Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport json","metadata":{"execution":{"iopub.status.busy":"2023-04-28T14:42:20.860376Z","iopub.execute_input":"2023-04-28T14:42:20.860866Z","iopub.status.idle":"2023-04-28T14:42:20.867134Z","shell.execute_reply.started":"2023-04-28T14:42:20.860826Z","shell.execute_reply":"2023-04-28T14:42:20.865763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"json_file_path = \"/kaggle/input/asl-signs/sign_to_prediction_index_map.json\"\nwith open(json_file_path, 'r') as j:\n     sign_dict = json.loads(j.read())\n        \nordered_signs = list(sign_dict.keys())\nprint(ordered_signs)","metadata":{"execution":{"iopub.status.busy":"2023-04-28T14:53:30.221553Z","iopub.execute_input":"2023-04-28T14:53:30.222641Z","iopub.status.idle":"2023-04-28T14:53:30.232191Z","shell.execute_reply.started":"2023-04-28T14:53:30.222583Z","shell.execute_reply":"2023-04-28T14:53:30.230826Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.read_csv(\"/kaggle/input/asl-signs/train.csv\")\nprint(df_train.shape)\ndf_train.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-04-28T14:54:04.774303Z","iopub.execute_input":"2023-04-28T14:54:04.774735Z","iopub.status.idle":"2023-04-28T14:54:04.941933Z","shell.execute_reply.started":"2023-04-28T14:54:04.774698Z","shell.execute_reply":"2023-04-28T14:54:04.940639Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ROWS_PER_FRAME = 543  # number of landmarks per frame\n\ndef load_relevant_data_subset(pq_path):\n    data_columns = ['x', 'y', 'z']\n    data = pd.read_parquet(pq_path, columns=data_columns).fillna(0)\n    n_frames = int(len(data) / ROWS_PER_FRAME)\n    data = data.values.reshape(n_frames, ROWS_PER_FRAME, len(data_columns))\n    return data.astype(np.float32)\n\ndef load_relevant_data(pq_path):\n    data = pd.read_parquet(pq_path).fillna(0)\n    return data","metadata":{"execution":{"iopub.status.busy":"2023-04-28T14:55:56.153622Z","iopub.execute_input":"2023-04-28T14:55:56.154158Z","iopub.status.idle":"2023-04-28T14:55:56.161555Z","shell.execute_reply.started":"2023-04-28T14:55:56.154093Z","shell.execute_reply":"2023-04-28T14:55:56.160319Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"idx_plot = 3\npath_show = \"/kaggle/input/asl-signs/\"+ df_train['path'].values[idx_plot]\nsign_plot = df_train['sign'].values[idx_plot]\npath_example = path_show.replace(\"_\", \"_\")\n\ndf = load_relevant_data(path_show)\ndf_train.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-04-28T14:55:58.784763Z","iopub.execute_input":"2023-04-28T14:55:58.786127Z","iopub.status.idle":"2023-04-28T14:55:58.875929Z","shell.execute_reply.started":"2023-04-28T14:55:58.786058Z","shell.execute_reply":"2023-04-28T14:55:58.875068Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path_show = \"/kaggle/input/asl-signs/\"+df_train['path'].values[1]\nsign_show = df_train['sign'].values[1]\n\ndf_example = load_relevant_data_subset(path_show)\n\nframes = df_example.shape[0]\nkeypoints = df_example.shape[1]\nposition = df_example.shape[2]\n\nprint(\"\\nNumber of frames:\", frames)\nprint(\"Keypoints:\", keypoints)\nprint(\"X, Y Z postions:\", position)\nprint(\"Total number of datapoints in this sequence:\", np.prod(df_example.shape))\n\n\npose_landmarks = 33\nface_landmarks = 468\nright_hand_landmarks = 21\nstart_left_hand = face_landmarks\nleft_hand_landmarks = 21\nstart_right_hand = face_landmarks + left_hand_landmarks + pose_landmarks\ntotal_landmarks = pose_landmarks + face_landmarks + right_hand_landmarks + left_hand_landmarks\n\n\nprint(\"\\nPose landmarks:\", pose_landmarks)\nprint(\"Face landmarks:\", face_landmarks)\nprint(\"Right hand landmarks:\", right_hand_landmarks)\nprint(\"Left hand landmarks:\", left_hand_landmarks)\nprint(\"Total landmarks/keypoints: \", total_landmarks)","metadata":{"execution":{"iopub.status.busy":"2023-04-28T14:56:44.201807Z","iopub.execute_input":"2023-04-28T14:56:44.202499Z","iopub.status.idle":"2023-04-28T14:56:44.222160Z","shell.execute_reply.started":"2023-04-28T14:56:44.202433Z","shell.execute_reply":"2023-04-28T14:56:44.220519Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tqdm import tqdm\n\nmax_sequence_length = 32\nlip_marks = [61, 185, 40, 39, 37, 0, 267, 269, 270, 409, 291, 78, 191, 80, 81, 82, 13, 312, 311, 310, 415, 308, 95, 88, 178, 87, 14, 317, 402, 318, 324, 146, 91, 181, 84, 17, 314, 405, 321, 375]  \n\nlips = lip_marks\nleft_hand = [*range(start_left_hand, start_left_hand+left_hand_landmarks, 1)]\nright_hand = [*range(start_right_hand, start_right_hand+right_hand_landmarks, 1)]\nmeaningful_keypoints = lips + left_hand + right_hand\ninput_length = len(meaningful_keypoints)*3\n\ndef get_data(file_paths, y_sign):\n    \n    X = np.empty((file_paths.shape[0], max_sequence_length, len(meaningful_keypoints)*3), dtype=float)\n\n    for i in tqdm(range(file_paths.shape[0])):\n        file_name = \"/kaggle/input/asl-signs/\"+file_paths[i]\n        data = load_relevant_data_subset(file_name)\n        \n        data = data[:, meaningful_keypoints]\n        \n        if data.shape[0] < max_sequence_length:\n            rows = max_sequence_length - data.shape[0]\n            data = np.append(np.zeros((rows, len(meaningful_keypoints), 3)), data, axis=0)\n        elif data.shape[0] > max_sequence_length:\n            data = data[-(max_sequence_length):]\n\n        X[i] = data.reshape(max_sequence_length, len(meaningful_keypoints)*3, order='F')\n        \n        del data\n        \n    X = np.asarray(X).astype(np.float32)\n        \n    y = []\n    for sign in y_sign:\n        y.append(sign_dict[sign])\n\n    y = np.array(y, dtype=int)\n\n    return X, y","metadata":{"execution":{"iopub.status.busy":"2023-04-28T14:57:07.577000Z","iopub.execute_input":"2023-04-28T14:57:07.577458Z","iopub.status.idle":"2023-04-28T14:57:07.591644Z","shell.execute_reply.started":"2023-04-28T14:57:07.577417Z","shell.execute_reply":"2023-04-28T14:57:07.590323Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow.keras import datasets, layers, models, Input, optimizers\nimport matplotlib.pyplot as plt\nfrom sklearn.model_selection import train_test_split\nfrom tensorflow.keras.utils import pad_sequences","metadata":{"execution":{"iopub.status.busy":"2023-04-28T14:57:24.086880Z","iopub.execute_input":"2023-04-28T14:57:24.087384Z","iopub.status.idle":"2023-04-28T14:57:24.478324Z","shell.execute_reply.started":"2023-04-28T14:57:24.087344Z","shell.execute_reply":"2023-04-28T14:57:24.476900Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def scaled_dot_product(q,k,v, softmax):\n    #calculates Q . K(transpose)\n    qkt = tf.matmul(q,k,transpose_b=True)\n    #caculates scaling factor\n    dk = tf.math.sqrt(tf.cast(q.shape[-1],dtype=tf.float32))\n    scaled_qkt = qkt/dk\n    softmax = softmax(scaled_qkt)\n    \n    z = tf.matmul(softmax,v)\n    #shape: (m,Tx,depth), same shape as q,k,v\n    return z\n\nclass MultiHeadAttention(tf.keras.layers.Layer):\n    def __init__(self,d_model,num_of_heads):\n        super(MultiHeadAttention,self).__init__()\n        self.d_model = d_model\n        self.num_of_heads = num_of_heads\n        self.depth = d_model//num_of_heads\n        self.wq = [tf.keras.layers.Dense(self.depth) for i in range(num_of_heads)]\n        self.wk = [tf.keras.layers.Dense(self.depth) for i in range(num_of_heads)]\n        self.wv = [tf.keras.layers.Dense(self.depth) for i in range(num_of_heads)]\n        self.wo = tf.keras.layers.Dense(d_model)\n        self.softmax = tf.keras.layers.Softmax()\n        \n    def call(self,x):\n        \n        multi_attn = []\n        for i in range(self.num_of_heads):\n            Q = self.wq[i](x)\n            K = self.wk[i](x)\n            V = self.wv[i](x)\n            multi_attn.append(scaled_dot_product(Q,K,V, self.softmax))\n            \n        multi_head = tf.concat(multi_attn,axis=-1)\n        multi_head_attention = self.wo(multi_head)\n        return multi_head_attention","metadata":{"execution":{"iopub.status.busy":"2023-04-28T14:57:42.912912Z","iopub.execute_input":"2023-04-28T14:57:42.913580Z","iopub.status.idle":"2023-04-28T14:57:42.934054Z","shell.execute_reply.started":"2023-04-28T14:57:42.913523Z","shell.execute_reply":"2023-04-28T14:57:42.932332Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# a single dense block followed by a normalization block and relu activation\ndef dense_block(units):\n    fc = layers.Dense(units)\n    norm = layers.LayerNormalization()\n    act = layers.Activation(\"relu\")\n    drop = layers.Dropout(0.05)\n    return lambda x: drop(act(norm(fc(x))))\n\n# transformer blocks\ndef transformer_block(key_dim, x):\n    mha = MultiHeadAttention(key_dim, 8)(x)\n    add1 = layers.add([mha, x])\n    norm1 = layers.LayerNormalization()(add1)\n\n    fc = layers.Dense(key_dim, activation=\"relu\")(norm1)\n    add2 = tf.math.add(fc, norm1)\n    norm2 = layers.LayerNormalization()(add2)\n\n    return norm2\n\n# the final dense block for the classification\ndef classifier_lstm(units):\n    lstm = layers.LSTM(units)\n    out = layers.Dense(250, activation=\"softmax\", name=\"outputs\")\n    return lambda x: out(lstm(x))\n    \ndef classifier_transformer():\n    dense = layers.Dense(256, activation=\"relu\")\n    drop = layers.Dropout(0.1)\n    \n    out = layers.Dense(250, activation=\"softmax\", name=\"outputs\")\n    return lambda x: out(drop(dense(x)))\n\ninputs = tf.keras.Input(shape=(None, input_length), ragged=True)\n# choose the number of nodes per layer\nembedding_units = [256, 128, 256] # tune this\ntransformer_units = []#, 512, 512]\n\n# # dense encoder model\nx = inputs\nfor n in embedding_units:\n    x = dense_block(n)(x)\n    \nfor t in transformer_units:\n    x = transformer_block(t, x)\n\n# classifier layer\nif len(transformer_units) > 0:\n    # Pooling\n    x = tf.math.reduce_sum(x, axis=1)\n    out = classifier_transformer()(x)\nelse:\n    out = classifier_lstm(embedding_units[-1])(x)\n\n\nmodel = tf.keras.Model(inputs=inputs, outputs=out)\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2023-04-28T14:58:06.351420Z","iopub.execute_input":"2023-04-28T14:58:06.351879Z","iopub.status.idle":"2023-04-28T14:58:07.360125Z","shell.execute_reply.started":"2023-04-28T14:58:06.351842Z","shell.execute_reply":"2023-04-28T14:58:07.358556Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# add a decreasing learning rate scheduler to help convergence\nbatch_size = 256\nvalidation_percentage = 0.05\nsteps_per_epoch = int(94477*(1-validation_percentage)) // batch_size\nboundaries = [steps_per_epoch * n for n in [23, 35, 45, 53, 60]]\nprint(boundaries)\nvalues = [1e-3,1e-4,1e-5,1e-6,1e-7,1e-8]\nlr_sched = optimizers.schedules.PiecewiseConstantDecay(boundaries, values)\n\noptimizer = optimizers.Adam(lr_sched)\n# optimizer = optimizers.Adam()\n\nmodel.compile(optimizer=optimizer,\n              loss=tf.keras.losses.SparseCategoricalCrossentropy(name=\"loss\"),\n              metrics=[\"accuracy\",\"sparse_top_k_categorical_accuracy\"])","metadata":{"execution":{"iopub.status.busy":"2023-04-28T14:58:31.114297Z","iopub.execute_input":"2023-04-28T14:58:31.114767Z","iopub.status.idle":"2023-04-28T14:58:31.180914Z","shell.execute_reply.started":"2023-04-28T14:58:31.114725Z","shell.execute_reply":"2023-04-28T14:58:31.179528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_callbacks():\n    return [\n        tf.keras.callbacks.EarlyStopping(\n            monitor=\"val_accuracy\",\n            patience = 10,\n            restore_best_weights=True\n        ),\n        tf.keras.callbacks.ReduceLROnPlateau(\n            monitor = \"val_accuracy\",\n            factor = 0.2,\n            patience = 5\n        ),\n    ]","metadata":{"execution":{"iopub.status.busy":"2023-04-28T15:11:14.445413Z","iopub.execute_input":"2023-04-28T15:11:14.446885Z","iopub.status.idle":"2023-04-28T15:11:14.454056Z","shell.execute_reply.started":"2023-04-28T15:11:14.446821Z","shell.execute_reply":"2023-04-28T15:11:14.452595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"no missing values","metadata":{}}]}