<jupyter_start><jupyter_text>Exploratory Data Analysis: We want to show the power of visualizations<jupyter_code>sns.countplot(y='Gender', hue='Loan_Status', data=df_train)
sns.countplot(y='Married',hue='Loan_Status',data=df_train)
sns.countplot(y='Credit_History',hue='Loan_Status',data=df_train)
sns.countplot(y='Property_Area',hue='Loan_Status',data=df_train)
sns.countplot(y='Loan_Amount_Term',hue='Loan_Status',data=df_train)
grid= sns.FacetGrid(df_train,row='Gender',col='Married', size=2.2, aspect=1.6)
grid.map(plt.hist, 'ApplicantIncome', alpha=0.5, bins=10)
grid.add_legend()
grid=sns.FacetGrid(df_train,row='Gender',col='Education',size=2.2, aspect=1.6)
grid.map(plt.hist,'ApplicantIncome',alpha=0.5,bins=10)
grid.add_legend()
grid = sns.FacetGrid(df_train,row='Self_Employed',col='Education',size=2.2, aspect=1.6)
grid.map(plt.hist, 'ApplicantIncome', alpha=0.5,bins=10)
grid.add_legend()
grid = sns.FacetGrid(df_train, row='Married', col='Dependents', size=3.2, aspect=1.6)
grid.map(plt.hist,'ApplicantIncome',alpha=0.5, bins=10)
grid.add_legend()<jupyter_output>C:\Users\visha\Anaconda3\lib\site-packages\seaborn\axisgrid.py:230: UserWarning: The `size` paramter has been renamed to `height`; please update your code.
  warnings.warn(msg, UserWarning)<jupyter_text>Encoding Numeric data, getting ready for Training<jupyter_code>code = {'Male':1,'Female':2,
       'Yes':1,'No':2,
       'Graduate':1,'Not Graduate':2,
       'Urban':3,'Semiurban':2,'Rural':1,
       'Y':1,'N':0,
       '3+':3}

df_train = df_train.applymap(lambda s: code.get(s) if s in code else s)
df_test = df_test.applymap(lambda s: code.get(s) if s in code else s)

#drop the uniqes loan id
df_train.drop('Loan_ID',axis=1,inplace=True)
df_train.head()
df_train['Dependents'].value_counts()
df_train.apply(empty,axis=0)<jupyter_output><empty_output><jupyter_text>We have to cpnvert the Dependents feature to Numeric<jupyter_code>Dependents1 = pd.to_numeric(df_train.Dependents)
Dependents2 = pd.to_numeric(df_test.Dependents)
df_train.drop(['Dependents'],axis=1, inplace=True)
df_test.drop(['Dependents'],axis=1, inplace=True)
df_train =  pd.concat([df_train,Dependents1],axis=1)
df_test =  pd.concat([df_test,Dependents2],axis=1)
sns.heatmap(df_train.corr())
y=df_train['Loan_Status']
X=df_train.drop(['Loan_Status'],axis=1)
from sklearn.model_selection import train_test_split
from sklearn.metrics import f1_score
from sklearn.model_selection import GridSearchCV
from sklearn.tree import DecisionTreeClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.20,random_state=0)<jupyter_output><empty_output><jupyter_text>using Logistic Regression<jupyter_code>model = LogisticRegression()
model.fit(X_train,y_train)
ypred=model.predict(X_test)
print(ypred)
evaluation = f1_score(y_test,ypred)
evaluation<jupyter_output><empty_output><jupyter_text>Using Decision tree<jupyter_code>tree = DecisionTreeClassifier()
tree.fit(X_train,y_train)
ypred_tree = tree.predict(X_test)
accuracy = f1_score(y_test,ypred_tree)
print(accuracy)<jupyter_output>0.8023255813953488<jupyter_text>Using Random Forest Classfier<jupyter_code>forest = RandomForestClassifier()
forest.fit(X_train,y_train)
ypred_forest = forest.predict(X_test)
accuracy = f1_score(ypred_forest,ypred)
print(accuracy)<jupyter_output>0.8181818181818182
{'fraction_non_alphanumeric': 0.14494875549048317, 'fraction_numerical': 0.02986822840409956, 'mean_word_length': 9.810126582278482, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '413000', 'license': 'MIT', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1336, 'n_words': 179, 'path': 'Loan Prediction.ipynb', 'repo_name': 'vishalstark/Loan-Prediction-Algorithm', 'size': '3415'}