# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/Samrath49/AI-with-Tensorflow/blob/master/Data%20Preprocessing.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + id="1z36E54-aDRT" colab_type="code" colab={}
import pandas as pd #used to convert unstructured data into tabuler form structured data
import numpy as np # it means numbers in python for numbers
import seaborn as sns # seaboen includes extra graphical functions that r not there in matplot lib
import matplotlib.pyplot as mp # mathematical ploting using graphs ets

# + id="bW0fUheeohIM" colab_type="code" colab={}
data = {'Sno': [1,2,3,4,5,6,7,8,9,10],
        'Horse_Id': ['H01','H02','H03','H04','H05','H06','H07','H08','H09','H10'],
        'Horse_Gender': ['M','F','F','F','M','M','F','F','M','F'],
        'Horse_Height(cm)':[188,190,178,150,np.NaN,198,200,179,np.NaN,180],
        'Horse_Weight(kg)':[410,550,600,710,590,630,np.NaN,740,650,720],
        'Racer_Horse':['yes','no','yes','no','yes','no','yes','no','yes','no']}

# + id="q0W2qp5DpkAW" colab_type="code" colab={}
df = pd.DataFrame(data,columns=['Sno','Horse_Id', 'Horse_Gender', 'Horse_Height(cm)','Horse_Weight(kg)','Racer_Horse'])

# + id="NcNJymrmqBzh" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 359} outputId="541ef44d-3daf-423c-987e-1d7ff8304aee"
df # data in tabular form as sorted data is called dataframe


# + id="88Cs_ogSO7WX" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 266} outputId="d1a9abce-31c2-446e-d6e8-21e664f0eca9"
info = df.dropna()
info

# + id="5Ddzzd8FqLmv" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 111} outputId="d37557ba-84a0-4514-fccb-1860d3c05ce6"
df.head(2)

# + id="LQVu95L2qddE" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 111} outputId="b6433384-2469-4d62-9e4b-26a4aa94372f"
df.tail(2)

# + id="5gpG4xr5qfjS" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 238} outputId="db1a5072-69bb-4125-e1b9-415d9604c9e8"
df.info()

# + id="g4bMqkQuqk8B" colab_type="code" colab={}
df.loc[(df['Horse_Height(cm)'].isnull()),'Horse_Height(cm)'] = df['Horse_Height(cm)'].mean()

# + id="cnYst780Mz_B" colab_type="code" colab={}
df.loc[(df['Horse_Gender']=='F')&(df['Horse_Weight(kg)'].isnull()),'Horse_Weight(kg)'] = 550

# + id="FsG4vvR3NJVq" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 359} outputId="fd1eb58b-f424-48c6-f332-a0285c68aeb8"
df

# + id="Em9uSPh7vR7P" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 204} outputId="24cee2a9-b700-45fd-87cd-280883415049"
target = df['Racer_Horse']
target

# + id="N4F95puPQbOe" colab_type="code" colab={}
df=df.drop(['Horse_Id'],axis=1)

# + id="pZzsf6dxRyG_" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 359} outputId="3b9e251a-19b6-4294-8c4d-6261d8ef1c3f"
df

# + id="tDSnYWRpxXqI" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 366} outputId="16207384-9041-4e3d-c5cd-7a64bcf596d1"
df.hist()

# + id="AqmK4FHGxgdL" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 584} outputId="43e95505-3be6-42e9-e77a-38de38a81d4c"
sns.pairplot(df)

# + id="2vAGqxPOxsVP" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 584} outputId="49b0cc5f-3d7e-4d12-f063-bd9ae25fc901"
sns.pairplot(df,hue="Racer_Horse")

# + id="Mb7RVzZXyVQ9" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 297} outputId="22d53e58-1977-4e28-e2d6-1af9d5fc7d5e"
sns.boxplot(x="Horse_Height(cm)", y="Racer_Horse",data=df)

# + id="7K-didssTDOf" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 297} outputId="31b2d2ad-f223-423b-d523-3f5d1b1961bb"
sns.boxplot(x="Horse_Height(cm)", y="Horse_Gender",data=df)

# + id="tZaDqfp9z_Ta" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 297} outputId="f645b4a8-6473-4a92-eac1-616d17e41f88"
sns.violinplot(x="Horse_Height(cm)",y="Racer_Horse",data=df)

# + id="vv0h_3bN8qpl" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 297} outputId="75613f5e-b341-4f76-fb70-b857e40dfadc"
sns.violinplot(x="Horse_Height(cm)",y="Racer_Horse",data=df, inner="quartile")

StarcoderdataJupyterScriptsDedupFiltered