{"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":"#  The Research problem.\n- Most of deaf children born to hearing parents with no knowldge of ASL are highly at risk of language deprivation syndrome.learning ASL is time consuming and most parents work long hours and some of them do not have resources to attend classes or access learning material.To assist the language and communication abilities of deaf children and their families it is crucial to create efficient and available ASL learning resources. About 94477 vidoes were collected and the language signs was defined according to it's accurate video. This collected data will be used on development of effective and accessible ASL learning tools to support language development and communication skills for deaf children.\n\n## Understanding the problem.\n- About 94477 videos where collected and language was defined according to its video. This collected data will be used onthe development of effective and accessible ASL learning tools to support the language development and communication skills of deaf children.\n\n### The aim\n- To developa high perfoming model for PopSign game that accuratly classifies isolated ASL signs using the videos given inthe data\n\n## Hypothesis\n- LEVEL OF PROFICIENCY .Develop the level of proficiency in ASL.This will cater to learners of all levels and allow them to progress in their own pace _Socio_econimic status Currently we are not sure\n\n- Vocabulary .we need to enrich the app with more words and improve vocabulary\n\n- Graphic .improve graphic perfomance so that videoscan be clear so it will cater for also people who color_blind\n\n- Social interaction .social interaction between learners ,this can include features such as chat rooms or forums where learners can communicate with each other and practice their signing skills","metadata":{"papermill":{"duration":0.022419,"end_time":"2023-04-17T18:21:05.606205","exception":false,"start_time":"2023-04-17T18:21:05.583786","status":"completed"},"tags":[]}},{"cell_type":"markdown","source":"# Understanding the data\n- This data is related to American sign language and the specific sign video of a particular word\n\n- Path-------------------- The path to the landmark file.\n\n- Participant_id-----------A unique identifier for the data contributor.\n\n- Sequence_id -------------A unique identifier for the landmark sequence.\n\n- Sign---------------------The label for the landmark sequenc","metadata":{"papermill":{"duration":0.019513,"end_time":"2023-04-17T18:21:05.644541","exception":false,"start_time":"2023-04-17T18:21:05.625028","status":"completed"},"tags":[]}},{"cell_type":"markdown","source":"## Library we are using them.","metadata":{"papermill":{"duration":0.018428,"end_time":"2023-04-17T18:21:05.681887","exception":false,"start_time":"2023-04-17T18:21:05.663459","status":"completed"},"tags":[]}},{"cell_type":"code","source":"!pip install mediapipe --quiet","metadata":{"papermill":{"duration":12.130217,"end_time":"2023-04-17T18:21:17.831280","exception":false,"start_time":"2023-04-17T18:21:05.701063","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:18.030594Z","iopub.execute_input":"2023-04-30T21:46:18.031237Z","iopub.status.idle":"2023-04-30T21:46:31.374330Z","shell.execute_reply.started":"2023-04-30T21:46:18.031200Z","shell.execute_reply":"2023-04-30T21:46:31.372959Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# # Import the required libraries.\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\nfrom matplotlib import pyplot as plt\nimport statsmodels.graphics.gofplots as sm\nfrom sklearn.preprocessing import PowerTransformer\nplt.figure(figsize=(20, 10))\nsns.set_style('darkgrid')\n!pip install pandas_bokeh\nimport plotly.express as px\nimport pandas_bokeh\npandas_bokeh.output_notebook()\nimport pyarrow.parquet as pq\nimport cv2\nfrom path import Path\nfrom PIL import Image\nfrom fastai.vision.all import show_image\n\nfrom ipywidgets import interact, interactive, fixed, interact_manual\nimport ipywidgets as widgets\n\nimport mediapipe as mp\nfrom mediapipe.framework.formats import landmark_pb2\nmp_drawing = mp.solutions.drawing_utils\nmp_drawing_styles = mp.solutions.drawing_styles\nmp_holistic = mp.solutions.holistic\nimport keras \nfrom keras.layers import *\nfrom keras.models import *\nfrom keras import backend as K\nfrom sklearn.model_selection import train_test_split\n\n","metadata":{"papermill":{"duration":27.472563,"end_time":"2023-04-17T18:21:45.323188","exception":false,"start_time":"2023-04-17T18:21:17.850625","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:31.378013Z","iopub.execute_input":"2023-04-30T21:46:31.378435Z","iopub.status.idle":"2023-04-30T21:46:58.273994Z","shell.execute_reply.started":"2023-04-30T21:46:31.378389Z","shell.execute_reply":"2023-04-30T21:46:58.272756Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Loading the csv data.","metadata":{"papermill":{"duration":0.019264,"end_time":"2023-04-17T18:21:45.363054","exception":false,"start_time":"2023-04-17T18:21:45.343790","status":"completed"},"tags":[]}},{"cell_type":"code","source":"#  We are reading csv using library pandas the csv.\ndf = pd.read_csv('/kaggle/input/asl-signs/train.csv')\ndf","metadata":{"papermill":{"duration":0.217344,"end_time":"2023-04-17T18:21:45.599943","exception":false,"start_time":"2023-04-17T18:21:45.382599","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.275953Z","iopub.execute_input":"2023-04-30T21:46:58.277384Z","iopub.status.idle":"2023-04-30T21:46:58.517717Z","shell.execute_reply.started":"2023-04-30T21:46:58.277349Z","shell.execute_reply":"2023-04-30T21:46:58.516606Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data exploration and analysis.","metadata":{"papermill":{"duration":0.019499,"end_time":"2023-04-17T18:21:45.640103","exception":false,"start_time":"2023-04-17T18:21:45.620604","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# Checking how many columns and rows our data frame has?\ndf.shape","metadata":{"papermill":{"duration":0.030406,"end_time":"2023-04-17T18:21:45.690353","exception":false,"start_time":"2023-04-17T18:21:45.659947","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.520627Z","iopub.execute_input":"2023-04-30T21:46:58.521300Z","iopub.status.idle":"2023-04-30T21:46:58.527927Z","shell.execute_reply.started":"2023-04-30T21:46:58.521260Z","shell.execute_reply":"2023-04-30T21:46:58.526883Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Showing our data frame but first five rows.\ndf.head(5)","metadata":{"papermill":{"duration":0.033061,"end_time":"2023-04-17T18:21:45.743373","exception":false,"start_time":"2023-04-17T18:21:45.710312","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.529522Z","iopub.execute_input":"2023-04-30T21:46:58.530155Z","iopub.status.idle":"2023-04-30T21:46:58.543987Z","shell.execute_reply.started":"2023-04-30T21:46:58.530119Z","shell.execute_reply":"2023-04-30T21:46:58.542922Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking our data frame how many columns it have?\ndf.columns","metadata":{"papermill":{"duration":0.029943,"end_time":"2023-04-17T18:21:45.793779","exception":false,"start_time":"2023-04-17T18:21:45.763836","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.545592Z","iopub.execute_input":"2023-04-30T21:46:58.545992Z","iopub.status.idle":"2023-04-30T21:46:58.557904Z","shell.execute_reply.started":"2023-04-30T21:46:58.545958Z","shell.execute_reply":"2023-04-30T21:46:58.556821Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"OBSERVATION\n\n    The Dataframe can clearly show that we have 4 columns namely are path,participant_id, sequence_id and sign\n","metadata":{"papermill":{"duration":0.019801,"end_time":"2023-04-17T18:21:45.833993","exception":false,"start_time":"2023-04-17T18:21:45.814192","status":"completed"},"tags":[]}},{"cell_type":"code","source":"#checking the datatype of column\ndf.dtypes","metadata":{"papermill":{"duration":0.030206,"end_time":"2023-04-17T18:21:45.884414","exception":false,"start_time":"2023-04-17T18:21:45.854208","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.561227Z","iopub.execute_input":"2023-04-30T21:46:58.561536Z","iopub.status.idle":"2023-04-30T21:46:58.571261Z","shell.execute_reply.started":"2023-04-30T21:46:58.561509Z","shell.execute_reply":"2023-04-30T21:46:58.569725Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"\n\n**OBSERVATION**\n\n    The data show that there are two data types which are objects and integers.\n    participant_id and sequence_id they are of integer type and sign and path they are of object type\n\n","metadata":{"papermill":{"duration":0.020042,"end_time":"2023-04-17T18:21:45.924602","exception":false,"start_time":"2023-04-17T18:21:45.904560","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# Showing our data but last five rows.\ndf.tail(5)","metadata":{"papermill":{"duration":0.03419,"end_time":"2023-04-17T18:21:45.978834","exception":false,"start_time":"2023-04-17T18:21:45.944644","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.572751Z","iopub.execute_input":"2023-04-30T21:46:58.573304Z","iopub.status.idle":"2023-04-30T21:46:58.587980Z","shell.execute_reply.started":"2023-04-30T21:46:58.573263Z","shell.execute_reply":"2023-04-30T21:46:58.586846Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking for the missing vaalue in our data look through the columns.\nfor col in df.columns:\n    print(f\"Column {col} has {df[col].isna().sum()} NaN values.\")","metadata":{"papermill":{"duration":0.041492,"end_time":"2023-04-17T18:21:46.040786","exception":false,"start_time":"2023-04-17T18:21:45.999294","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.589655Z","iopub.execute_input":"2023-04-30T21:46:58.590093Z","iopub.status.idle":"2023-04-30T21:46:58.611227Z","shell.execute_reply.started":"2023-04-30T21:46:58.590059Z","shell.execute_reply":"2023-04-30T21:46:58.609766Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking the summary of our data frame.\ndf.describe()","metadata":{"papermill":{"duration":0.05103,"end_time":"2023-04-17T18:21:46.112928","exception":false,"start_time":"2023-04-17T18:21:46.061898","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.616407Z","iopub.execute_input":"2023-04-30T21:46:58.616876Z","iopub.status.idle":"2023-04-30T21:46:58.647838Z","shell.execute_reply.started":"2023-04-30T21:46:58.616847Z","shell.execute_reply":"2023-04-30T21:46:58.646758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# We are counting the total number sigh and each type of sign how many it has?\ndf['sign'].value_counts()","metadata":{"papermill":{"duration":0.035645,"end_time":"2023-04-17T18:21:46.169698","exception":false,"start_time":"2023-04-17T18:21:46.134053","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.649546Z","iopub.execute_input":"2023-04-30T21:46:58.650343Z","iopub.status.idle":"2023-04-30T21:46:58.664313Z","shell.execute_reply.started":"2023-04-30T21:46:58.650301Z","shell.execute_reply":"2023-04-30T21:46:58.663210Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Observation.**\n- The total number of sign is 250.\n- The signs are shown in descreasing order.","metadata":{"papermill":{"duration":0.020839,"end_time":"2023-04-17T18:21:46.211322","exception":false,"start_time":"2023-04-17T18:21:46.190483","status":"completed"},"tags":[]}},{"cell_type":"markdown","source":"- In the sign column the most frequent sign is the listening, follow by the look,shhh,donkey and mouse respectively\n- Whereas the least sign used is the zipper sign\n","metadata":{"papermill":{"duration":0.02106,"end_time":"2023-04-17T18:21:46.253089","exception":false,"start_time":"2023-04-17T18:21:46.232029","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# We  sorting the values under the column which is sequence id.\ndf['sequence_id'].sort_values(ascending=True).head()","metadata":{"papermill":{"duration":0.068622,"end_time":"2023-04-17T18:21:46.355969","exception":false,"start_time":"2023-04-17T18:21:46.287347","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.666148Z","iopub.execute_input":"2023-04-30T21:46:58.666522Z","iopub.status.idle":"2023-04-30T21:46:58.680147Z","shell.execute_reply.started":"2023-04-30T21:46:58.666468Z","shell.execute_reply":"2023-04-30T21:46:58.678893Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking the informationof our data frame.\ndf.info()","metadata":{"papermill":{"duration":0.071969,"end_time":"2023-04-17T18:21:46.467526","exception":false,"start_time":"2023-04-17T18:21:46.395557","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.682002Z","iopub.execute_input":"2023-04-30T21:46:58.682371Z","iopub.status.idle":"2023-04-30T21:46:58.707462Z","shell.execute_reply.started":"2023-04-30T21:46:58.682335Z","shell.execute_reply":"2023-04-30T21:46:58.706384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**OBSERVATION**\n\n   - For path,participant_id,sequence_id and sign, there are 94477 entries with no missing     values.\n   -  Total columns are 4\n   -  For Datatype we have 2 integer and 2 object data type\n","metadata":{"papermill":{"duration":0.020841,"end_time":"2023-04-17T18:21:46.509375","exception":false,"start_time":"2023-04-17T18:21:46.488534","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# Checking our data how much is the skewness? It will only calculate the skewness in the \n# numerical data.\ndf.skew()","metadata":{"papermill":{"duration":0.067666,"end_time":"2023-04-17T18:21:46.598227","exception":false,"start_time":"2023-04-17T18:21:46.530561","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.711140Z","iopub.execute_input":"2023-04-30T21:46:58.711438Z","iopub.status.idle":"2023-04-30T21:46:58.736574Z","shell.execute_reply.started":"2023-04-30T21:46:58.711410Z","shell.execute_reply":"2023-04-30T21:46:58.735390Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Observation**\n\n- The participant id and sequence id is  moderately skewed that it hat the distribution is fairly symmetrical bell curve, or normal distribution.\n","metadata":{"papermill":{"duration":0.026331,"end_time":"2023-04-17T18:21:46.691741","exception":false,"start_time":"2023-04-17T18:21:46.665410","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# Checking the name of the data frame different sign.\ndf['sign'].unique()","metadata":{"papermill":{"duration":0.041256,"end_time":"2023-04-17T18:21:46.754211","exception":false,"start_time":"2023-04-17T18:21:46.712955","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.738017Z","iopub.execute_input":"2023-04-30T21:46:58.738889Z","iopub.status.idle":"2023-04-30T21:46:58.754938Z","shell.execute_reply.started":"2023-04-30T21:46:58.738839Z","shell.execute_reply":"2023-04-30T21:46:58.753437Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**OBSERVATION**\n\n    Base onthe data there are 250 unique sign that where recorded\n","metadata":{"papermill":{"duration":0.021011,"end_time":"2023-04-17T18:21:46.796735","exception":false,"start_time":"2023-04-17T18:21:46.775724","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# Checking out how many columns and rows that sigh which is listen has?\ndf.loc[df['sign']==\"listen\"].shape","metadata":{"papermill":{"duration":0.036663,"end_time":"2023-04-17T18:21:46.854976","exception":false,"start_time":"2023-04-17T18:21:46.818313","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.757064Z","iopub.execute_input":"2023-04-30T21:46:58.757838Z","iopub.status.idle":"2023-04-30T21:46:58.771275Z","shell.execute_reply.started":"2023-04-30T21:46:58.757800Z","shell.execute_reply":"2023-04-30T21:46:58.769973Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking the sample that represent our data frame with sample size 20.\ndf.sample(20)","metadata":{"papermill":{"duration":0.039844,"end_time":"2023-04-17T18:21:46.916767","exception":false,"start_time":"2023-04-17T18:21:46.876923","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.773474Z","iopub.execute_input":"2023-04-30T21:46:58.774175Z","iopub.status.idle":"2023-04-30T21:46:58.792143Z","shell.execute_reply.started":"2023-04-30T21:46:58.774139Z","shell.execute_reply":"2023-04-30T21:46:58.790931Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n# Normal probability plot\n# Probability plot is a visual tool for determining if a variable in a dataset has an\n# approximately similar theoretical distribution, such as normal or gamma. This plot \n# generates a probability plot of sample data against the quantiles of a specified \n# theoretical distribution, in this case, a normal distribution.\nfig, ax = plt.subplots(1, 2, figsize=(12, 7))\ndf[\"sequence_id\"].hist(bins=20,ax=ax[0])\nsm.ProbPlot(df[\"sequence_id\"]).qqplot(line='s', ax=ax[1])\n","metadata":{"papermill":{"duration":1.412714,"end_time":"2023-04-17T18:21:48.351355","exception":false,"start_time":"2023-04-17T18:21:46.938641","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:46:58.794412Z","iopub.execute_input":"2023-04-30T21:46:58.794895Z","iopub.status.idle":"2023-04-30T21:47:00.218333Z","shell.execute_reply.started":"2023-04-30T21:46:58.794858Z","shell.execute_reply":"2023-04-30T21:47:00.217154Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Plotting the scatter plot to check for the relationship between thw sequence id and \n# participant id the scatter plt is one of the graph that shows the relationship.\nsns.scatterplot(x=df[\"sequence_id\"],y=df[\"participant_id\"],data=df)","metadata":{"papermill":{"duration":0.63685,"end_time":"2023-04-17T18:21:49.013969","exception":false,"start_time":"2023-04-17T18:21:48.377119","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:00.219963Z","iopub.execute_input":"2023-04-30T21:47:00.220455Z","iopub.status.idle":"2023-04-30T21:47:00.843646Z","shell.execute_reply.started":"2023-04-30T21:47:00.220419Z","shell.execute_reply":"2023-04-30T21:47:00.840928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"participants = list(df.groupby('sign').count().index)\ncounts = df.groupby('sign').count()['sequence_id'].values\n\nplt.figure(figsize=(30,10))\nplt.bar(np.arange(len(participants)), height=counts, width=1)\nplt.xticks(np.arange(len(participants)), participants, rotation=90)\nplt.xlabel('sign', fontsize=20)\nplt.ylabel('Number of sequences', fontsize=20)\nplt.show()\n","metadata":{"papermill":{"duration":6.274005,"end_time":"2023-04-17T18:21:55.312207","exception":false,"start_time":"2023-04-17T18:21:49.038202","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:00.845281Z","iopub.execute_input":"2023-04-30T21:47:00.845794Z","iopub.status.idle":"2023-04-30T21:47:06.928693Z","shell.execute_reply.started":"2023-04-30T21:47:00.845754Z","shell.execute_reply":"2023-04-30T21:47:06.927604Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**OBSERVATION**\n\n    The bar graph show that there is an unequal frequency distribution of the sign videos.\n    certain signs they are used less as compared to other onces.\n    This unequal distribution may cause the analysis of the data to be biased.\n","metadata":{"papermill":{"duration":0.025037,"end_time":"2023-04-17T18:21:55.363133","exception":false,"start_time":"2023-04-17T18:21:55.338096","status":"completed"},"tags":[]}},{"cell_type":"code","source":"df[\"participant_id\"].value_counts()","metadata":{"papermill":{"duration":0.036637,"end_time":"2023-04-17T18:21:55.424606","exception":false,"start_time":"2023-04-17T18:21:55.387969","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:06.929862Z","iopub.execute_input":"2023-04-30T21:47:06.930204Z","iopub.status.idle":"2023-04-30T21:47:06.941395Z","shell.execute_reply.started":"2023-04-30T21:47:06.930171Z","shell.execute_reply":"2023-04-30T21:47:06.940175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"participant_id\"].value_counts().plot(kind=\"bar\")","metadata":{"papermill":{"duration":0.386335,"end_time":"2023-04-17T18:21:55.835766","exception":false,"start_time":"2023-04-17T18:21:55.449431","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:06.943120Z","iopub.execute_input":"2023-04-30T21:47:06.943892Z","iopub.status.idle":"2023-04-30T21:47:07.342804Z","shell.execute_reply.started":"2023-04-30T21:47:06.943852Z","shell.execute_reply":"2023-04-30T21:47:07.341750Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**OBSERVATION**\n\n    The graph and the data above depict that there are 21 participant_id\n    The participant with the highest number of ASL signs is 49455 with sum of 4968 signs\n    The participant with the least number of ASL signs is 30680 with sum of 3338\n\n","metadata":{"papermill":{"duration":0.025388,"end_time":"2023-04-17T18:21:55.888074","exception":false,"start_time":"2023-04-17T18:21:55.862686","status":"completed"},"tags":[]}},{"cell_type":"markdown","source":"# INDIVIDUAL PARQUET.","metadata":{"papermill":{"duration":0.025344,"end_time":"2023-04-17T18:21:55.939074","exception":false,"start_time":"2023-04-17T18:21:55.913730","status":"completed"},"tags":[]}},{"cell_type":"markdown","source":"# Reading a single train landmark files.","metadata":{"papermill":{"duration":0.025343,"end_time":"2023-04-17T18:21:55.990268","exception":false,"start_time":"2023-04-17T18:21:55.964925","status":"completed"},"tags":[]}},{"cell_type":"code","source":"p1 = pd.read_parquet('/kaggle/input/asl-signs/train_landmark_files/16069/100015657.parquet')","metadata":{"papermill":{"duration":0.194973,"end_time":"2023-04-17T18:21:56.211172","exception":false,"start_time":"2023-04-17T18:21:56.016199","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.344524Z","iopub.execute_input":"2023-04-30T21:47:07.345403Z","iopub.status.idle":"2023-04-30T21:47:07.503417Z","shell.execute_reply.started":"2023-04-30T21:47:07.345362Z","shell.execute_reply":"2023-04-30T21:47:07.502231Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### EDA for parquet data.","metadata":{"papermill":{"duration":0.027762,"end_time":"2023-04-17T18:21:56.265223","exception":false,"start_time":"2023-04-17T18:21:56.237461","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# Checking how many columns and rows our data frame has?\np1.shape","metadata":{"papermill":{"duration":0.035578,"end_time":"2023-04-17T18:21:56.326267","exception":false,"start_time":"2023-04-17T18:21:56.290689","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.507772Z","iopub.execute_input":"2023-04-30T21:47:07.508117Z","iopub.status.idle":"2023-04-30T21:47:07.518009Z","shell.execute_reply.started":"2023-04-30T21:47:07.508088Z","shell.execute_reply":"2023-04-30T21:47:07.516938Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Showing the first 5 rows of the data.\np1.head()","metadata":{"papermill":{"duration":0.040974,"end_time":"2023-04-17T18:21:56.392592","exception":false,"start_time":"2023-04-17T18:21:56.351618","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.519580Z","iopub.execute_input":"2023-04-30T21:47:07.519894Z","iopub.status.idle":"2023-04-30T21:47:07.538191Z","shell.execute_reply.started":"2023-04-30T21:47:07.519866Z","shell.execute_reply":"2023-04-30T21:47:07.536506Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking the our data column how many columns?\np1.columns","metadata":{"papermill":{"duration":0.035787,"end_time":"2023-04-17T18:21:56.455127","exception":false,"start_time":"2023-04-17T18:21:56.419340","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.540019Z","iopub.execute_input":"2023-04-30T21:47:07.541135Z","iopub.status.idle":"2023-04-30T21:47:07.548689Z","shell.execute_reply.started":"2023-04-30T21:47:07.541094Z","shell.execute_reply":"2023-04-30T21:47:07.547426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"p1.value_counts()","metadata":{"papermill":{"duration":0.131926,"end_time":"2023-04-17T18:21:56.612992","exception":false,"start_time":"2023-04-17T18:21:56.481066","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.550419Z","iopub.execute_input":"2023-04-30T21:47:07.551738Z","iopub.status.idle":"2023-04-30T21:47:07.665076Z","shell.execute_reply.started":"2023-04-30T21:47:07.551675Z","shell.execute_reply":"2023-04-30T21:47:07.663860Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"p1.info()","metadata":{"papermill":{"duration":0.048509,"end_time":"2023-04-17T18:21:56.688641","exception":false,"start_time":"2023-04-17T18:21:56.640132","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.674128Z","iopub.execute_input":"2023-04-30T21:47:07.674474Z","iopub.status.idle":"2023-04-30T21:47:07.696104Z","shell.execute_reply.started":"2023-04-30T21:47:07.674444Z","shell.execute_reply":"2023-04-30T21:47:07.694784Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"p1.sample(5)","metadata":{"papermill":{"duration":0.045284,"end_time":"2023-04-17T18:21:56.762656","exception":false,"start_time":"2023-04-17T18:21:56.717372","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.697938Z","iopub.execute_input":"2023-04-30T21:47:07.698426Z","iopub.status.idle":"2023-04-30T21:47:07.717210Z","shell.execute_reply.started":"2023-04-30T21:47:07.698370Z","shell.execute_reply":"2023-04-30T21:47:07.715823Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Observation\n- The frame is number in the row video .\n- row_id -->is the unique identifier of the row .\n- type-->the type of the landmark it can be face ,pose, left_hand and right_hand.\n- lanamark_index-->hand landmark locations you can find the location of the hand using this index.\n- x,y,z--->this are normalized spatial coordinates of the landmark.when using the mormalized dataset we make our data to be more efficient and reduce the storage space and minimize the quiring of the data","metadata":{"papermill":{"duration":0.026515,"end_time":"2023-04-17T18:21:56.816447","exception":false,"start_time":"2023-04-17T18:21:56.789932","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# Checking type of data names under type column. \np1['type'].unique()","metadata":{"papermill":{"duration":0.03906,"end_time":"2023-04-17T18:21:56.881657","exception":false,"start_time":"2023-04-17T18:21:56.842597","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.719165Z","iopub.execute_input":"2023-04-30T21:47:07.719587Z","iopub.status.idle":"2023-04-30T21:47:07.731126Z","shell.execute_reply.started":"2023-04-30T21:47:07.719543Z","shell.execute_reply":"2023-04-30T21:47:07.729832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking the value counts under type column.\np1['type'].value_counts()","metadata":{"papermill":{"duration":0.039845,"end_time":"2023-04-17T18:21:56.947722","exception":false,"start_time":"2023-04-17T18:21:56.907877","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.733949Z","iopub.execute_input":"2023-04-30T21:47:07.735030Z","iopub.status.idle":"2023-04-30T21:47:07.747146Z","shell.execute_reply.started":"2023-04-30T21:47:07.734993Z","shell.execute_reply":"2023-04-30T21:47:07.745780Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking for the missing values in our data look through the columns.\nfor col in p1.columns:\n    print(f\"Column {col} has {p1[col].isna().sum()} NaN values.\")","metadata":{"papermill":{"duration":0.042268,"end_time":"2023-04-17T18:21:57.016740","exception":false,"start_time":"2023-04-17T18:21:56.974472","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.749602Z","iopub.execute_input":"2023-04-30T21:47:07.750579Z","iopub.status.idle":"2023-04-30T21:47:07.764187Z","shell.execute_reply.started":"2023-04-30T21:47:07.750542Z","shell.execute_reply":"2023-04-30T21:47:07.762746Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Observation**\n- There could be several reasons why some values are missing in the MediaPipe data for right hand, left hand, and pose. It could be due to several factors such as occlusions, low camera quality, inaccurate detection, or incorrect labeling.\n- To fix this issue during preprocessing, one possible approach is to impute the missing values. There are different techniques available for imputing missing data, such as:\n1.\tMean or median imputation: Replace the missing values with the mean or median of the available data. This is a simple technique, but it assumes that the missing values are missing at random, and it may not be appropriate for highly skewed or non-normal data.\n- The choice of imputation method depends on the characteristics of the data and the research question. It is also important to consider the potential impact of imputing missing values on the results of the analysis. Imputing missing values can introduce bias or reduce the statistical power of the analysis, so it is important to evaluate the robustness of the results to different imputation methods and assumptions.\n","metadata":{"papermill":{"duration":0.027123,"end_time":"2023-04-17T18:21:57.071409","exception":false,"start_time":"2023-04-17T18:21:57.044286","status":"completed"},"tags":[]}},{"cell_type":"code","source":"p1.isnull().sum()","metadata":{"papermill":{"duration":0.043518,"end_time":"2023-04-17T18:21:57.142151","exception":false,"start_time":"2023-04-17T18:21:57.098633","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.765630Z","iopub.execute_input":"2023-04-30T21:47:07.766567Z","iopub.status.idle":"2023-04-30T21:47:07.783307Z","shell.execute_reply.started":"2023-04-30T21:47:07.766528Z","shell.execute_reply":"2023-04-30T21:47:07.782129Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Obesrvation**\n- There are missing values on x,y and z whereas for frame,row_id and type there are no missing values","metadata":{"papermill":{"duration":0.026779,"end_time":"2023-04-17T18:21:57.196319","exception":false,"start_time":"2023-04-17T18:21:57.169540","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# Calculate the column x mean.\nx_mean=p1[\"x\"].mean()\nprint(\"The mean of column x is  \",x_mean)","metadata":{"papermill":{"duration":0.046402,"end_time":"2023-04-17T18:21:57.270285","exception":false,"start_time":"2023-04-17T18:21:57.223883","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.784830Z","iopub.execute_input":"2023-04-30T21:47:07.785952Z","iopub.status.idle":"2023-04-30T21:47:07.793214Z","shell.execute_reply.started":"2023-04-30T21:47:07.785913Z","shell.execute_reply":"2023-04-30T21:47:07.791746Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Impute the missing data in the x column with the mean x value\np1[\"x\"].fillna(x_mean,inplace=True)","metadata":{"papermill":{"duration":0.072049,"end_time":"2023-04-17T18:21:57.410689","exception":false,"start_time":"2023-04-17T18:21:57.338640","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.795133Z","iopub.execute_input":"2023-04-30T21:47:07.796327Z","iopub.status.idle":"2023-04-30T21:47:07.803659Z","shell.execute_reply.started":"2023-04-30T21:47:07.796283Z","shell.execute_reply":"2023-04-30T21:47:07.802625Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking for the missing vaalue in our data look through the columns.\nfor col in p1.columns:\n    print(f\"Column {col} has {p1[col].isna().sum()} NaN values.\")","metadata":{"papermill":{"duration":0.046245,"end_time":"2023-04-17T18:21:57.508603","exception":false,"start_time":"2023-04-17T18:21:57.462358","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.805160Z","iopub.execute_input":"2023-04-30T21:47:07.806067Z","iopub.status.idle":"2023-04-30T21:47:07.824664Z","shell.execute_reply.started":"2023-04-30T21:47:07.806028Z","shell.execute_reply":"2023-04-30T21:47:07.823374Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking all the records in the dataset for which the 'y' column is NA\np1[p1['y'].isnull()]","metadata":{"papermill":{"duration":0.047778,"end_time":"2023-04-17T18:21:57.584043","exception":false,"start_time":"2023-04-17T18:21:57.536265","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.827987Z","iopub.execute_input":"2023-04-30T21:47:07.828289Z","iopub.status.idle":"2023-04-30T21:47:07.851835Z","shell.execute_reply.started":"2023-04-30T21:47:07.828261Z","shell.execute_reply":"2023-04-30T21:47:07.850957Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\np1[\"y\"].unique","metadata":{"papermill":{"duration":0.038114,"end_time":"2023-04-17T18:21:57.649795","exception":false,"start_time":"2023-04-17T18:21:57.611681","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.853297Z","iopub.execute_input":"2023-04-30T21:47:07.854879Z","iopub.status.idle":"2023-04-30T21:47:07.863979Z","shell.execute_reply.started":"2023-04-30T21:47:07.854832Z","shell.execute_reply":"2023-04-30T21:47:07.862784Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":" # Sort the values of y in ascending order\np1['y'].sort_values(ascending=False).head()","metadata":{"papermill":{"duration":0.045183,"end_time":"2023-04-17T18:21:57.722960","exception":false,"start_time":"2023-04-17T18:21:57.677777","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.865797Z","iopub.execute_input":"2023-04-30T21:47:07.866845Z","iopub.status.idle":"2023-04-30T21:47:07.886763Z","shell.execute_reply.started":"2023-04-30T21:47:07.866800Z","shell.execute_reply":"2023-04-30T21:47:07.885757Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#  Calculating the median value of the y column\ny_median= p1[\"y\"].median()\nprint(\"The median of the y column is \",y_median)\n","metadata":{"papermill":{"duration":0.038423,"end_time":"2023-04-17T18:21:57.789353","exception":false,"start_time":"2023-04-17T18:21:57.750930","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.888384Z","iopub.execute_input":"2023-04-30T21:47:07.889189Z","iopub.status.idle":"2023-04-30T21:47:07.897135Z","shell.execute_reply.started":"2023-04-30T21:47:07.889148Z","shell.execute_reply":"2023-04-30T21:47:07.895922Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Impute the missing data in the y column with the median  y value\np1[\"y\"].fillna(y_median,inplace=True)","metadata":{"papermill":{"duration":0.036399,"end_time":"2023-04-17T18:21:57.854121","exception":false,"start_time":"2023-04-17T18:21:57.817722","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.899056Z","iopub.execute_input":"2023-04-30T21:47:07.899862Z","iopub.status.idle":"2023-04-30T21:47:07.907893Z","shell.execute_reply.started":"2023-04-30T21:47:07.899817Z","shell.execute_reply":"2023-04-30T21:47:07.906973Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking for the missing vaalue in our data look through the columns.\nfor col in p1.columns:\n    print(f\"Column {col} has {p1[col].isna().sum()} NaN values.\")","metadata":{"papermill":{"duration":0.042596,"end_time":"2023-04-17T18:21:57.924196","exception":false,"start_time":"2023-04-17T18:21:57.881600","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.909418Z","iopub.execute_input":"2023-04-30T21:47:07.910161Z","iopub.status.idle":"2023-04-30T21:47:07.928531Z","shell.execute_reply.started":"2023-04-30T21:47:07.910122Z","shell.execute_reply":"2023-04-30T21:47:07.927321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking all the records in the dataset for which the 'z' column is NA\np1[p1['z'].isnull()]","metadata":{"papermill":{"duration":0.048556,"end_time":"2023-04-17T18:21:58.000359","exception":false,"start_time":"2023-04-17T18:21:57.951803","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.930021Z","iopub.execute_input":"2023-04-30T21:47:07.930672Z","iopub.status.idle":"2023-04-30T21:47:07.951523Z","shell.execute_reply.started":"2023-04-30T21:47:07.930633Z","shell.execute_reply":"2023-04-30T21:47:07.950226Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Calculate the mean of z column.\nz_mean=p1[\"z\"].mean()\nprint(\"The mean of the z column is \",z_mean)\n","metadata":{"papermill":{"duration":0.03838,"end_time":"2023-04-17T18:21:58.067336","exception":false,"start_time":"2023-04-17T18:21:58.028956","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.953573Z","iopub.execute_input":"2023-04-30T21:47:07.954195Z","iopub.status.idle":"2023-04-30T21:47:07.960860Z","shell.execute_reply.started":"2023-04-30T21:47:07.954160Z","shell.execute_reply":"2023-04-30T21:47:07.959715Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# We  use the mean of the z values in the column to impute the missing value in the z column.\np1[\"z\"].fillna(z_mean,inplace=True)","metadata":{"papermill":{"duration":0.037057,"end_time":"2023-04-17T18:21:58.133179","exception":false,"start_time":"2023-04-17T18:21:58.096122","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.962449Z","iopub.execute_input":"2023-04-30T21:47:07.963209Z","iopub.status.idle":"2023-04-30T21:47:07.972479Z","shell.execute_reply.started":"2023-04-30T21:47:07.963170Z","shell.execute_reply":"2023-04-30T21:47:07.971213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking for the missing values in our data look through the columns.\nfor col in p1.columns:\n    print(f\"Column {col} has {p1[col].isna().sum()} NaN values.\")","metadata":{"papermill":{"duration":0.043617,"end_time":"2023-04-17T18:21:58.205304","exception":false,"start_time":"2023-04-17T18:21:58.161687","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.974391Z","iopub.execute_input":"2023-04-30T21:47:07.974939Z","iopub.status.idle":"2023-04-30T21:47:07.992749Z","shell.execute_reply.started":"2023-04-30T21:47:07.974886Z","shell.execute_reply":"2023-04-30T21:47:07.991379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Showing the summary of the data.\np1.describe()","metadata":{"papermill":{"duration":0.062787,"end_time":"2023-04-17T18:21:58.296092","exception":false,"start_time":"2023-04-17T18:21:58.233305","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:07.994659Z","iopub.execute_input":"2023-04-30T21:47:07.995960Z","iopub.status.idle":"2023-04-30T21:47:08.035663Z","shell.execute_reply.started":"2023-04-30T21:47:07.995919Z","shell.execute_reply":"2023-04-30T21:47:08.034359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data Visualization of the single parquet Data.","metadata":{"papermill":{"duration":0.028844,"end_time":"2023-04-17T18:21:58.354318","exception":false,"start_time":"2023-04-17T18:21:58.325474","status":"completed"},"tags":[]}},{"cell_type":"code","source":"fig, ax = plt.subplots(1,2, figsize=(12, 7))\np1[\"x\"].hist(bins=20,ax=ax[0])\nsm.ProbPlot(p1['x']).qqplot(line='s', ax=ax[1])\n","metadata":{"papermill":{"duration":1.195047,"end_time":"2023-04-17T18:21:59.577451","exception":false,"start_time":"2023-04-17T18:21:58.382404","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:08.037236Z","iopub.execute_input":"2023-04-30T21:47:08.038363Z","iopub.status.idle":"2023-04-30T21:47:09.356051Z","shell.execute_reply.started":"2023-04-30T21:47:08.038324Z","shell.execute_reply":"2023-04-30T21:47:09.354775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking correlation between variables in the data\ncorrelation_between_varialables = p1.corr()\nprint(correlation_between_varialables)","metadata":{"papermill":{"duration":0.048618,"end_time":"2023-04-17T18:21:59.656020","exception":false,"start_time":"2023-04-17T18:21:59.607402","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:09.357776Z","iopub.execute_input":"2023-04-30T21:47:09.358212Z","iopub.status.idle":"2023-04-30T21:47:09.376218Z","shell.execute_reply.started":"2023-04-30T21:47:09.358174Z","shell.execute_reply":"2023-04-30T21:47:09.374985Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# we visualise the  correlation between the varialables with Seaborn library\nsns.heatmap(correlation_between_varialables, annot = True, cmap= 'coolwarm')","metadata":{"papermill":{"duration":0.379579,"end_time":"2023-04-17T18:22:00.067839","exception":false,"start_time":"2023-04-17T18:21:59.688260","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:09.377965Z","iopub.execute_input":"2023-04-30T21:47:09.378351Z","iopub.status.idle":"2023-04-30T21:47:09.750527Z","shell.execute_reply.started":"2023-04-30T21:47:09.378313Z","shell.execute_reply":"2023-04-30T21:47:09.749562Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Showing the graph.\nsns.pairplot(p1[['x','y','z']])","metadata":{"papermill":{"duration":6.740619,"end_time":"2023-04-17T18:22:06.840554","exception":false,"start_time":"2023-04-17T18:22:00.099935","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:09.752130Z","iopub.execute_input":"2023-04-30T21:47:09.752891Z","iopub.status.idle":"2023-04-30T21:47:17.399748Z","shell.execute_reply.started":"2023-04-30T21:47:09.752846Z","shell.execute_reply":"2023-04-30T21:47:17.398763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Observation**\n- A pair plot is a data visualization that shows pairwise associations between various variables of a dataset in a grid so that we may more easily see how they relate to one another.\n- The diagonal of the grid can represent a histogram or KDE, as shown in the above code  which we compare the x, y, and y variable of the dataset.","metadata":{"papermill":{"duration":0.032599,"end_time":"2023-04-17T18:22:06.907198","exception":false,"start_time":"2023-04-17T18:22:06.874599","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# Checking the outlier in our data.\nsns.boxplot(p1)","metadata":{"papermill":{"duration":0.342123,"end_time":"2023-04-17T18:22:07.282452","exception":false,"start_time":"2023-04-17T18:22:06.940329","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:17.401339Z","iopub.execute_input":"2023-04-30T21:47:17.401978Z","iopub.status.idle":"2023-04-30T21:47:17.720457Z","shell.execute_reply.started":"2023-04-30T21:47:17.401929Z","shell.execute_reply":"2023-04-30T21:47:17.719366Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Observation**\n- The is no outlier in this data ","metadata":{"papermill":{"duration":0.033543,"end_time":"2023-04-17T18:22:07.350141","exception":false,"start_time":"2023-04-17T18:22:07.316598","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# checking if any data that is repeated or duplicated.\np1.duplicated()","metadata":{"papermill":{"duration":0.069755,"end_time":"2023-04-17T18:22:07.453073","exception":false,"start_time":"2023-04-17T18:22:07.383318","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:17.722174Z","iopub.execute_input":"2023-04-30T21:47:17.722561Z","iopub.status.idle":"2023-04-30T21:47:17.759959Z","shell.execute_reply.started":"2023-04-30T21:47:17.722521Z","shell.execute_reply":"2023-04-30T21:47:17.758746Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Observation**\n- The is no duplicated in my data.","metadata":{"papermill":{"duration":0.035665,"end_time":"2023-04-17T18:22:07.522080","exception":false,"start_time":"2023-04-17T18:22:07.486415","status":"completed"},"tags":[]}},{"cell_type":"code","source":"p1.groupby(['frame']).count()","metadata":{"papermill":{"duration":0.059156,"end_time":"2023-04-17T18:22:07.615341","exception":false,"start_time":"2023-04-17T18:22:07.556185","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:17.761877Z","iopub.execute_input":"2023-04-30T21:47:17.762254Z","iopub.status.idle":"2023-04-30T21:47:17.787260Z","shell.execute_reply.started":"2023-04-30T21:47:17.762218Z","shell.execute_reply":"2023-04-30T21:47:17.786041Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"p1['frame'].plot_bokeh(kind='hist')\n","metadata":{"papermill":{"duration":0.216958,"end_time":"2023-04-17T18:22:07.866307","exception":false,"start_time":"2023-04-17T18:22:07.649349","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:17.788842Z","iopub.execute_input":"2023-04-30T21:47:17.789316Z","iopub.status.idle":"2023-04-30T21:47:17.978402Z","shell.execute_reply.started":"2023-04-30T21:47:17.789276Z","shell.execute_reply":"2023-04-30T21:47:17.977269Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"p1['type'].value_counts()","metadata":{"papermill":{"duration":0.048289,"end_time":"2023-04-17T18:22:07.949277","exception":false,"start_time":"2023-04-17T18:22:07.900988","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:17.980051Z","iopub.execute_input":"2023-04-30T21:47:17.980504Z","iopub.status.idle":"2023-04-30T21:47:17.993003Z","shell.execute_reply.started":"2023-04-30T21:47:17.980465Z","shell.execute_reply":"2023-04-30T21:47:17.991849Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"type_p1=p1['type'].value_counts()\ntype_p1.plot_bokeh(kind='pie',x=type_p1.index,)","metadata":{"papermill":{"duration":0.122959,"end_time":"2023-04-17T18:22:08.106545","exception":false,"start_time":"2023-04-17T18:22:07.983586","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:17.994768Z","iopub.execute_input":"2023-04-30T21:47:17.995184Z","iopub.status.idle":"2023-04-30T21:47:18.090693Z","shell.execute_reply.started":"2023-04-30T21:47:17.995148Z","shell.execute_reply":"2023-04-30T21:47:18.089364Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Obervations**\n- most of data in column for type were labelled face follwed by pose and the left hand and righ hand are equal.","metadata":{"papermill":{"duration":0.034721,"end_time":"2023-04-17T18:22:08.176185","exception":false,"start_time":"2023-04-17T18:22:08.141464","status":"completed"},"tags":[]}},{"cell_type":"code","source":"p1.loc[p1[\"type\"]==\"face\"].plot_bokeh.scatter(\nx=\"x\",\ny=\"y\",\ncategory=\"type\")\n","metadata":{"papermill":{"duration":0.48743,"end_time":"2023-04-17T18:22:08.698257","exception":false,"start_time":"2023-04-17T18:22:08.210827","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:18.092681Z","iopub.execute_input":"2023-04-30T21:47:18.093139Z","iopub.status.idle":"2023-04-30T21:47:18.447875Z","shell.execute_reply.started":"2023-04-30T21:47:18.093095Z","shell.execute_reply":"2023-04-30T21:47:18.447041Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"p1.loc[p1[\"type\"]==\"right_hand\"].plot_bokeh.scatter(\nx=\"x\",\ny=\"y\",\ncategory=\"type\")\n","metadata":{"papermill":{"duration":0.181356,"end_time":"2023-04-17T18:22:08.945399","exception":false,"start_time":"2023-04-17T18:22:08.764043","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:18.449104Z","iopub.execute_input":"2023-04-30T21:47:18.450145Z","iopub.status.idle":"2023-04-30T21:47:18.581580Z","shell.execute_reply.started":"2023-04-30T21:47:18.450108Z","shell.execute_reply":"2023-04-30T21:47:18.580482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"p1.loc[p1[\"type\"]==\"left_hand\"].plot_bokeh.scatter(\nx=\"x\",\ny=\"y\",\ncategory=\"type\")\n","metadata":{"papermill":{"duration":0.166446,"end_time":"2023-04-17T18:22:09.171276","exception":false,"start_time":"2023-04-17T18:22:09.004830","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:18.583057Z","iopub.execute_input":"2023-04-30T21:47:18.584017Z","iopub.status.idle":"2023-04-30T21:47:18.695117Z","shell.execute_reply.started":"2023-04-30T21:47:18.583977Z","shell.execute_reply":"2023-04-30T21:47:18.694145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"p1.loc[p1[\"type\"]==\"pose\"].plot_bokeh.scatter(\nx=\"x\",\ny=\"y\",\ncategory=\"type\")\n","metadata":{"papermill":{"duration":0.179396,"end_time":"2023-04-17T18:22:09.410434","exception":false,"start_time":"2023-04-17T18:22:09.231038","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:18.696539Z","iopub.execute_input":"2023-04-30T21:47:18.697617Z","iopub.status.idle":"2023-04-30T21:47:18.823184Z","shell.execute_reply.started":"2023-04-30T21:47:18.697578Z","shell.execute_reply":"2023-04-30T21:47:18.822256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Use MediaPipe to Render Parquet Files**","metadata":{"papermill":{"duration":0.056891,"end_time":"2023-04-17T18:22:09.527455","exception":false,"start_time":"2023-04-17T18:22:09.470564","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# load up the train csv\ndf = pd.read_csv('/kaggle/input/asl-signs/train.csv')\ndf.head()","metadata":{"papermill":{"duration":0.161074,"end_time":"2023-04-17T18:22:09.745717","exception":false,"start_time":"2023-04-17T18:22:09.584643","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:18.824924Z","iopub.execute_input":"2023-04-30T21:47:18.825603Z","iopub.status.idle":"2023-04-30T21:47:18.931788Z","shell.execute_reply.started":"2023-04-30T21:47:18.825564Z","shell.execute_reply":"2023-04-30T21:47:18.930681Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\npf = pd.read_parquet('/kaggle/input/asl-signs/train_landmark_files/26734/1000035562.parquet')\npf.head()","metadata":{"papermill":{"duration":0.096534,"end_time":"2023-04-17T18:22:09.904037","exception":false,"start_time":"2023-04-17T18:22:09.807503","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:18.933207Z","iopub.execute_input":"2023-04-30T21:47:18.933913Z","iopub.status.idle":"2023-04-30T21:47:18.970264Z","shell.execute_reply.started":"2023-04-30T21:47:18.933864Z","shell.execute_reply":"2023-04-30T21:47:18.969055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('This parquet file contains the following frames:')\nprint(pf.frame.unique())","metadata":{"papermill":{"duration":0.073519,"end_time":"2023-04-17T18:22:10.035819","exception":false,"start_time":"2023-04-17T18:22:09.962300","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:18.972089Z","iopub.execute_input":"2023-04-30T21:47:18.972639Z","iopub.status.idle":"2023-04-30T21:47:18.981174Z","shell.execute_reply.started":"2023-04-30T21:47:18.972593Z","shell.execute_reply":"2023-04-30T21:47:18.979938Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Frame types: ')\nprint(pf.type.unique())","metadata":{"papermill":{"duration":0.075269,"end_time":"2023-04-17T18:22:10.169640","exception":false,"start_time":"2023-04-17T18:22:10.094371","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:18.983240Z","iopub.execute_input":"2023-04-30T21:47:18.983728Z","iopub.status.idle":"2023-04-30T21:47:18.993915Z","shell.execute_reply.started":"2023-04-30T21:47:18.983664Z","shell.execute_reply":"2023-04-30T21:47:18.992640Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Total number of features per frame: ')\npf.shape[0]/pf.frame.nunique()","metadata":{"papermill":{"duration":0.079462,"end_time":"2023-04-17T18:22:10.309867","exception":false,"start_time":"2023-04-17T18:22:10.230405","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:18.995943Z","iopub.execute_input":"2023-04-30T21:47:18.996298Z","iopub.status.idle":"2023-04-30T21:47:19.008767Z","shell.execute_reply.started":"2023-04-30T21:47:18.996263Z","shell.execute_reply":"2023-04-30T21:47:19.007585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Number of features per frame per type: ')\npf.type.value_counts()/pf.frame.nunique()","metadata":{"papermill":{"duration":0.073913,"end_time":"2023-04-17T18:22:10.442224","exception":false,"start_time":"2023-04-17T18:22:10.368311","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:19.010250Z","iopub.execute_input":"2023-04-30T21:47:19.010718Z","iopub.status.idle":"2023-04-30T21:47:19.025842Z","shell.execute_reply.started":"2023-04-30T21:47:19.010628Z","shell.execute_reply":"2023-04-30T21:47:19.023258Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def draw_landmarks(landmarks,image,show_pose=True,show_face_contour=True,show_face_tesselation=True,show_left_hand=True,show_right_hand=True):\n    annotated_image = image.copy()\n    results = landmarks\n    if show_face_tesselation:\n        mp_drawing.draw_landmarks(\n            annotated_image,\n            results.face_landmarks,\n            mp_holistic.FACEMESH_TESSELATION,\n            landmark_drawing_spec=None,\n            connection_drawing_spec=mp_drawing_styles\n            .get_default_face_mesh_tesselation_style())\n    if show_face_contour:\n        mp_drawing.draw_landmarks(\n            annotated_image,\n            results.face_landmarks,\n            mp_holistic.FACEMESH_CONTOURS,\n            landmark_drawing_spec=None,\n            connection_drawing_spec=mp_drawing_styles\n            .get_default_face_mesh_contours_style())\n    if show_pose:\n        mp_drawing.draw_landmarks(\n            annotated_image,\n            results.pose_landmarks,\n            mp_holistic.POSE_CONNECTIONS,\n            landmark_drawing_spec=mp_drawing_styles.\n            get_default_pose_landmarks_style())\n    if show_left_hand:\n        mp_drawing.draw_landmarks(\n            annotated_image,\n            results.left_hand_landmarks,\n            mp_holistic.HAND_CONNECTIONS,\n            landmark_drawing_spec=mp_drawing_styles\n            .get_default_hand_landmarks_style())\n    if show_right_hand:\n        mp_drawing.draw_landmarks(\n            annotated_image,\n            results.right_hand_landmarks,\n            mp_holistic.HAND_CONNECTIONS,\n            landmark_drawing_spec=mp_drawing_styles\n            .get_default_hand_landmarks_style())\n    return annotated_image","metadata":{"papermill":{"duration":0.072107,"end_time":"2023-04-17T18:22:10.572261","exception":false,"start_time":"2023-04-17T18:22:10.500154","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:19.027385Z","iopub.execute_input":"2023-04-30T21:47:19.027661Z","iopub.status.idle":"2023-04-30T21:47:19.037997Z","shell.execute_reply.started":"2023-04-30T21:47:19.027636Z","shell.execute_reply":"2023-04-30T21:47:19.036773Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# the size is arbitrary the landmark locations will be rendered relative to the dimensions of the background image provided\nannotated_image = np.zeros((1024,1024,3),dtype=np.uint8)\nshow_image(annotated_image)  # show empty blackground image for reference","metadata":{"papermill":{"duration":0.422041,"end_time":"2023-04-17T18:22:11.051950","exception":false,"start_time":"2023-04-17T18:22:10.629909","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:19.039519Z","iopub.execute_input":"2023-04-30T21:47:19.040305Z","iopub.status.idle":"2023-04-30T21:47:19.431511Z","shell.execute_reply.started":"2023-04-30T21:47:19.040269Z","shell.execute_reply":"2023-04-30T21:47:19.430543Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# simple holder for our landmarks that will mimic the results that we get back from mediapipe but using our data\nclass Landmarks(object):\n    pass\n\ndef get_landmarks_from_parquet(pf,frame):\n    f = pf[pf.frame == frame]\n    face = landmark_pb2.NormalizedLandmarkList()\n    for t in f[f.type=='face'][['x','y','z']].itertuples(index=False):\n        face.landmark.add(x=t.x,y=t.y,z=t.z)\n    pose = landmark_pb2.NormalizedLandmarkList()\n    for t in f[f.type=='pose'][['x','y','z']].itertuples(index=False):\n        pose.landmark.add(x=t.x,y=t.y,z=t.z)\n    left_hand = landmark_pb2.NormalizedLandmarkList()\n    for t in f[f.type=='left_hand'][['x','y','z']].itertuples(index=False):\n        left_hand.landmark.add(x=t.x,y=t.y,z=t.z)\n    right_hand = landmark_pb2.NormalizedLandmarkList()\n    for t in f[f.type=='right_hand'][['x','y','z']].itertuples(index=False):\n        right_hand.landmark.add(x=t.x,y=t.y,z=t.z)    \n    result = Landmarks()\n    result.face_landmarks = face\n    result.pose_landmarks = pose\n    result.left_hand_landmarks = left_hand\n    result.right_hand_landmarks = right_hand\n    return result","metadata":{"papermill":{"duration":0.073939,"end_time":"2023-04-17T18:22:11.184975","exception":false,"start_time":"2023-04-17T18:22:11.111036","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:19.433056Z","iopub.execute_input":"2023-04-30T21:47:19.433548Z","iopub.status.idle":"2023-04-30T21:47:19.445221Z","shell.execute_reply.started":"2023-04-30T21:47:19.433506Z","shell.execute_reply":"2023-04-30T21:47:19.444064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"landmarks = get_landmarks_from_parquet(pf,20)\nshow_image(draw_landmarks(landmarks,annotated_image))","metadata":{"papermill":{"duration":0.460657,"end_time":"2023-04-17T18:22:11.703311","exception":false,"start_time":"2023-04-17T18:22:11.242654","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:19.446950Z","iopub.execute_input":"2023-04-30T21:47:19.447302Z","iopub.status.idle":"2023-04-30T21:47:19.962461Z","shell.execute_reply.started":"2023-04-30T21:47:19.447268Z","shell.execute_reply":"2023-04-30T21:47:19.961440Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"frames = pf.frame.unique()  # get the frames from the parquet file\n\ndef show_frame(frame):\n    landmarks = get_landmarks_from_parquet(pf,frames[frame])\n    show_image(draw_landmarks(landmarks,annotated_image),figsize=(9,9),title=f'frame: {frames[frame]} [{frame+1} of {len(frames)}]')\n    print(f'showing frame: {frames[frame]}')\n    \ni = interact(show_frame,frame=widgets.IntSlider(min=0, max=len(frames)-1, step=1, value=0))","metadata":{"papermill":{"duration":0.469744,"end_time":"2023-04-17T18:22:12.237815","exception":false,"start_time":"2023-04-17T18:22:11.768071","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:19.963877Z","iopub.execute_input":"2023-04-30T21:47:19.965006Z","iopub.status.idle":"2023-04-30T21:47:20.393796Z","shell.execute_reply.started":"2023-04-30T21:47:19.964962Z","shell.execute_reply":"2023-04-30T21:47:20.392613Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **CNN**","metadata":{"papermill":{"duration":0.064799,"end_time":"2023-04-17T18:22:12.375062","exception":false,"start_time":"2023-04-17T18:22:12.310263","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# Filtering  the data for the body part of interest which in case we used face\ndf1 = p1[p1['type'].str.contains('face')]\ndf1.head()","metadata":{"papermill":{"duration":0.074166,"end_time":"2023-04-17T18:22:12.656471","exception":false,"start_time":"2023-04-17T18:22:12.582305","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:20.395598Z","iopub.execute_input":"2023-04-30T21:47:20.396378Z","iopub.status.idle":"2023-04-30T21:47:20.439695Z","shell.execute_reply.started":"2023-04-30T21:47:20.396336Z","shell.execute_reply":"2023-04-30T21:47:20.438458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# the line of code randomly shuffles the rows of the DataFrame df1 and returns the shuffled DataFrame.\ndf1 = df1.sample(frac=1, random_state=42)","metadata":{"papermill":{"duration":0.085959,"end_time":"2023-04-17T18:22:12.521649","exception":false,"start_time":"2023-04-17T18:22:12.435690","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:20.441655Z","iopub.execute_input":"2023-04-30T21:47:20.442823Z","iopub.status.idle":"2023-04-30T21:47:20.454967Z","shell.execute_reply.started":"2023-04-30T21:47:20.442778Z","shell.execute_reply":"2023-04-30T21:47:20.453722Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Reshape the data into a 2D array for each frame\nframes = df1['frame'].unique()\ndf2 =[]\nfor frame in frames:\n    s=df1[df1['frame']==frame]\n    landmarks=s[['x','y','z']].values\n    img = np.zeros((256,256))\nfor i,landmark in enumerate(landmarks):\n    x,y,z = landmark\n    x = int(x*img.shape[1])\n    y = int(y*img.shape[0])\n    # Set the pixel value at the landmark position to 1\n    img[y,x]=1\n    df2.append(img)","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:47:20.457567Z","iopub.execute_input":"2023-04-30T21:47:20.458721Z","iopub.status.idle":"2023-04-30T21:47:20.581166Z","shell.execute_reply.started":"2023-04-30T21:47:20.458657Z","shell.execute_reply":"2023-04-30T21:47:20.580021Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Normalize the data\ndf2 = np.array(df2)\nmean = np.mean(df2)\nstd = np.std(df2)\ndf2_norm = (df2 - mean) / std","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:47:20.582676Z","iopub.execute_input":"2023-04-30T21:47:20.583127Z","iopub.status.idle":"2023-04-30T21:47:20.903439Z","shell.execute_reply.started":"2023-04-30T21:47:20.583083Z","shell.execute_reply":"2023-04-30T21:47:20.902150Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(df2_norm[0], cmap='gray'),landmark[0]","metadata":{"papermill":{"duration":0.347134,"end_time":"2023-04-17T18:22:13.789439","exception":false,"start_time":"2023-04-17T18:22:13.442305","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-30T21:47:20.905181Z","iopub.execute_input":"2023-04-30T21:47:20.906429Z","iopub.status.idle":"2023-04-30T21:47:21.218889Z","shell.execute_reply.started":"2023-04-30T21:47:20.906372Z","shell.execute_reply":"2023-04-30T21:47:21.217797Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df2_norm.shape)\nprint(df2.shape)\n\nif df2_norm.shape[0] != df2.shape[0]:\n  print(\"df2 and df2_norm rows are mismatched, check dataset again\")","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:47:21.220668Z","iopub.execute_input":"2023-04-30T21:47:21.221046Z","iopub.status.idle":"2023-04-30T21:47:21.228037Z","shell.execute_reply.started":"2023-04-30T21:47:21.221008Z","shell.execute_reply":"2023-04-30T21:47:21.226780Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train, x_test, y_train, y_test = train_test_split(df2_norm,df2, test_size=400,random_state=888888,shuffle  = True)\n\nprint(\"Samples in Training:\",x_train.shape[0])\nprint(\"Samples in Testing:\",x_test.shape[0])","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:47:21.229315Z","iopub.execute_input":"2023-04-30T21:47:21.230470Z","iopub.status.idle":"2023-04-30T21:47:21.383213Z","shell.execute_reply.started":"2023-04-30T21:47:21.230431Z","shell.execute_reply":"2023-04-30T21:47:21.381920Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"inputs = Input(shape=(256,256,1))\nconv1 = Conv2D(32, kernel_size=(3, 3),activation='relu')(inputs)\nconv2 = Conv2D(64, kernel_size=(3, 3),activation='relu')(conv1)\npool1 = MaxPooling2D(pool_size=(2, 2))(conv2)\nconv3 = Conv2D(128, kernel_size=(3, 3),activation='relu')(pool1)\npool2 = MaxPooling2D(pool_size=(2, 2))(conv3)\nm = Dropout(0.25)(pool2)\nflat = Flatten()(m)\n\ndropout = Dropout(0.5)\nx_model = Dense(256, activation='relu')(flat)\nx_model = dropout(x_model)\nx_model = Dense(128, activation='relu')(x_model)\nx_model = dropout(x_model)\nx_model = Dense(64, activation='relu')(x_model)\nx_model = dropout(x_model)\nx_model = Dense(32, activation='relu')(x_model)\nx_model = dropout(x_model)\nx_model = Dense(16, activation='relu')(x_model)\nx_model = dropout(x_model)\nx_model = Dense(1, activation='relu')(x_model)\n\ndropout = Dropout(0.5)\ny_model = Dense(256, activation='relu')(flat)\ny_model= dropout(y_model)\ny_model = Dense(128, activation='relu')(y_model)\ny_model = dropout(y_model)\ny_model = Dense(64, activation='relu')(y_model)\ny_model= dropout(y_model)\ny_model = Dense(32, activation='relu')(y_model)\ny_model = dropout(y_model)\ny_model = Dense(16, activation='relu')(y_model)\ny_model = dropout(y_model)\ny_model = Dense(8, activation='sigmoid')(y_model)\ny_model = dropout(y_model)\ny_model = Dense(4, activation='relu')(y_model)\ny_model = dropout(y_model)\ny_model = Dense(1, activation='relu')(y_model)","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:47:21.384848Z","iopub.execute_input":"2023-04-30T21:47:21.385322Z","iopub.status.idle":"2023-04-30T21:47:29.410711Z","shell.execute_reply.started":"2023-04-30T21:47:21.385281Z","shell.execute_reply":"2023-04-30T21:47:29.409684Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = Model(inputs=inputs, outputs=[x_model,y_model])\nmodel.compile(optimizer = 'adam', loss =['mse','binary_crossentropy'],metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:47:29.412293Z","iopub.execute_input":"2023-04-30T21:47:29.412669Z","iopub.status.idle":"2023-04-30T21:47:29.438972Z","shell.execute_reply.started":"2023-04-30T21:47:29.412631Z","shell.execute_reply":"2023-04-30T21:47:29.438055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.summary()","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:47:29.450461Z","iopub.execute_input":"2023-04-30T21:47:29.450809Z","iopub.status.idle":"2023-04-30T21:47:29.510079Z","shell.execute_reply.started":"2023-04-30T21:47:29.450780Z","shell.execute_reply":"2023-04-30T21:47:29.509224Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tf.keras.utils.plot_model(model, 'model.png',show_shapes=True) ","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:47:29.511176Z","iopub.execute_input":"2023-04-30T21:47:29.511643Z","iopub.status.idle":"2023-04-30T21:47:30.476476Z","shell.execute_reply.started":"2023-04-30T21:47:29.511600Z","shell.execute_reply":"2023-04-30T21:47:30.475200Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h = model.fit(x_train,[y_train[:,0],y_train[:,1]],validation_data=(x_test,[y_test[:,0],y_test[:,1]]),epochs = 90, batch_size=28,shuffle = True)","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:47:30.478772Z","iopub.execute_input":"2023-04-30T21:47:30.479484Z","iopub.status.idle":"2023-04-30T21:50:55.728818Z","shell.execute_reply.started":"2023-04-30T21:47:30.479440Z","shell.execute_reply":"2023-04-30T21:50:55.727665Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#saving the model\nmodel.save('submission.zip')","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:50:55.730869Z","iopub.execute_input":"2023-04-30T21:50:55.731284Z","iopub.status.idle":"2023-04-30T21:51:14.326646Z","shell.execute_reply.started":"2023-04-30T21:50:55.731243Z","shell.execute_reply":"2023-04-30T21:51:14.325381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = h\nplt.plot(history.history['loss'])\nplt.plot(history.history['val_loss'])\nplt.title('model loss')\nplt.ylabel('loss')\nplt.xlabel('epoch')\nplt.legend(['train', 'val'], loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:51:14.329032Z","iopub.execute_input":"2023-04-30T21:51:14.329634Z","iopub.status.idle":"2023-04-30T21:51:14.593762Z","shell.execute_reply.started":"2023-04-30T21:51:14.329592Z","shell.execute_reply":"2023-04-30T21:51:14.592737Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(history.history['dense_5_loss'])\nplt.plot(history.history['val_dense_5_loss'])\nplt.title('dense_5_model loss')\nplt.ylabel('accuracy')\nplt.xlabel('epoch')\nplt.legend(['train', 'val'], loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:51:14.595435Z","iopub.execute_input":"2023-04-30T21:51:14.596138Z","iopub.status.idle":"2023-04-30T21:51:16.087723Z","shell.execute_reply.started":"2023-04-30T21:51:14.596099Z","shell.execute_reply":"2023-04-30T21:51:16.086745Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(history.history['dense_13_loss'])\nplt.plot(history.history['val_dense_13_loss'])\nplt.title('dense_13_model loss')\nplt.ylabel('accuracy')\nplt.xlabel('epoch')\nplt.legend(['train', 'val'], loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:51:16.089058Z","iopub.execute_input":"2023-04-30T21:51:16.089415Z","iopub.status.idle":"2023-04-30T21:51:16.962796Z","shell.execute_reply.started":"2023-04-30T21:51:16.089378Z","shell.execute_reply":"2023-04-30T21:51:16.961669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport tensorflow as tf\nimport zipfile","metadata":{"execution":{"iopub.status.busy":"2023-04-30T21:51:16.964376Z","iopub.execute_input":"2023-04-30T21:51:16.964752Z","iopub.status.idle":"2023-04-30T21:51:16.969928Z","shell.execute_reply.started":"2023-04-30T21:51:16.964713Z","shell.execute_reply":"2023-04-30T21:51:16.968595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_file_path = '/kaggle/input/submission/saved_model.pb'","metadata":{"execution":{"iopub.status.busy":"2023-04-30T22:04:36.729055Z","iopub.execute_input":"2023-04-30T22:04:36.729464Z","iopub.status.idle":"2023-04-30T22:04:36.734776Z","shell.execute_reply.started":"2023-04-30T22:04:36.729429Z","shell.execute_reply":"2023-04-30T22:04:36.733431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"zip_file_path = '/kaggle/working/submission.zip/saved_model.pb'","metadata":{"execution":{"iopub.status.busy":"2023-04-30T22:07:06.207134Z","iopub.execute_input":"2023-04-30T22:07:06.207540Z","iopub.status.idle":"2023-04-30T22:07:06.212519Z","shell.execute_reply.started":"2023-04-30T22:07:06.207504Z","shell.execute_reply":"2023-04-30T22:07:06.211253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with open(model_file_path, 'rb') as f:\n    tflite_model = f.read()","metadata":{"execution":{"iopub.status.busy":"2023-04-30T22:07:44.608419Z","iopub.execute_input":"2023-04-30T22:07:44.608810Z","iopub.status.idle":"2023-04-30T22:07:44.614651Z","shell.execute_reply.started":"2023-04-30T22:07:44.608775Z","shell.execute_reply":"2023-04-30T22:07:44.613566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with zipfile.ZipFile(zip_file_path, 'w', zipfile.ZIP_DEFLATED) as zip_file:\n    zip_file.writestr(\"model.tflite\", tflite_model)","metadata":{"execution":{"iopub.status.busy":"2023-04-30T22:07:47.174352Z","iopub.execute_input":"2023-04-30T22:07:47.174773Z","iopub.status.idle":"2023-04-30T22:07:47.191351Z","shell.execute_reply.started":"2023-04-30T22:07:47.174731Z","shell.execute_reply":"2023-04-30T22:07:47.190415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **REFERENCES**\n\n* This notebook uses code from the following Kaggle notebook: \n[Use MediaPipe to Render Parquet Files](https://www.kaggle.com/code/johnrobinsn/use-mediapipe-to-render-parquet-files)","metadata":{"papermill":{"duration":0.110768,"end_time":"2023-04-17T18:22:24.656827","exception":false,"start_time":"2023-04-17T18:22:24.546059","status":"completed"},"tags":[]}},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.110186,"end_time":"2023-04-17T18:22:24.876032","exception":false,"start_time":"2023-04-17T18:22:24.765846","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]}]}