<jupyter_start><jupyter_text>Data Preprocessing Zone<jupyter_code>df_t.drop(['Loan_ID'],inplace=True,axis=1)
# Checking number of the columns
len((df_t))
# Shape of the dataset
df_t.shape
# Checking the name of the columns
df_t.columns
# checking the null values
df_t.isnull()
# Checking the sum of the null vlaues
df_t.isnull().sum()
# Visualize the null values using heatmap
sns.heatmap(df_t.isnull(),yticklabels=False,cbar=False)
# Data Observation
df_t.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 367 entries, 0 to 366
Data columns (total 11 columns):
Gender               356 non-null object
Married              367 non-null object
Dependents           357 non-null object
Education            367 non-null object
Self_Employed        344 non-null object
ApplicantIncome      367 non-null int64
CoapplicantIncome    367 non-null int64
LoanAmount           362 non-null float64
Loan_Amount_Term     361 non-null float64
Credit_History       338 non-null float64
Property_Area        367 non-null object
dtypes: float64(3), int64(2), object(6)
memory usage: 31.6+ KB<jupyter_text>Handling the Null / Missing Values in Numerical Values<jupyter_code># Using fillna methods to fillup the maean of the features
df_t['LoanAmount'] = df_t['LoanAmount'].fillna(df_t['LoanAmount'].mean())
df_t['Loan_Amount_Term'] = df_t['Loan_Amount_Term'].fillna(df_t['Loan_Amount_Term'].mean())
df_t['Credit_History'] = df_t['Credit_History'].fillna(df_t['Credit_History'].mean())
df_t.isnull().sum()
# After handling the Numerical missing valeu
sns.heatmap(df_t.isnull())<jupyter_output><empty_output><jupyter_text>Handling the Null / Missing Values in Gategorical Values<jupyter_code># Knowing the value counts
df_t['Gender'].value_counts()
df_t['Dependents'].value_counts()
df_t['Self_Employed'].value_counts()
# Converting the numerical values using get_dummies
Gender = pd.get_dummies(df_t['Gender'],drop_first=True)
Dependents = pd.get_dummies(df_t['Dependents'],drop_first=True)
Self_Employed = pd.get_dummies(df_t['Self_Employed'],drop_first=True)
# Displays the Converted features
Gender.head()
Dependents.head()
Self_Employed.head()
df_t.drop(['Gender','Dependents','Self_Employed'],axis=1,inplace=True)
df_t.head()
# Concating the existing Features with new one
df_t = pd.concat([df_t,Gender,Dependents,Self_Employed],axis=1)
df_t.head()
# Converting Other Gategorical Features
# Counts values
df_t['Married'].value_counts().head()
df_t['Education'].value_counts().head()
df_t['Property_Area'].value_counts().head()
Married = pd.get_dummies(df_t['Married'],drop_first=True)
Education = pd.get_dummies(df_t['Education'],drop_first=True)
Property_Area = pd.get_dummies(df_t['Property_Area'],drop_first=True)
df_t.drop(['Married','Education','Property_Area'],axis=1,inplace=True)
# Concating the existing Features with new one
df_t = pd.concat([df_t,Married,Education,Property_Area],axis=1)
df_t.head()
df_t.to_csv('formulatedtest.csv',index=False)
sns.countplot(y = 'Male',hue='y',data=df_t)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup