<jupyter_start><jupyter_text>first we find the null values in given data set<jupyter_code>train.isnull().head()<jupyter_output><empty_output><jupyter_text>now it become difficult to trace null values because there can be millions of data so we use seaborn library to plot a heatmap<jupyter_code>sn.heatmap(train.isnull(),    xticklabels=True,cbar=False,cmap='gist_earth')<jupyter_output><empty_output><jupyter_text>now we need to know how may peope survived or how many not....!! using again seaborn library<jupyter_code>sn.set_style('whitegrid')
sn.countplot(x='Survived',data=train)<jupyter_output><empty_output><jupyter_text>now we distiguise on the basis of sex e.i; how many male and female survived<jupyter_code>sn.set_style('whitegrid')
sn.countplot(x='Survived',hue='Sex',data=train,palette='RdBu_r')
sn.set_style('whitegrid')
sn.countplot(x='Survived',hue='Pclass',data=train,palette='RdBu_r')<jupyter_output><empty_output><jupyter_text>now we extract information about the age of people with no. of people with same ages<jupyter_code>sn.distplot(train['Age'].dropna(),kde=False,color='black',bins=40)<jupyter_output><empty_output><jupyter_text>now we have to find people having no of spouse or siblings<jupyter_code>sn.countplot(x='SibSp',data=train)
sn.distplot(train['Fare'],kde=False)<jupyter_output><empty_output><jupyter_text>or<jupyter_code>train['Fare'].hist(color='green',bins=40,figsize=(8,4))<jupyter_output><empty_output><jupyter_text>now we have to remove nan values ,here we find relation between passenger class and their age for that relation we use boxplot<jupyter_code>mt.Figure(figsize=(12,7))
sn.boxplot(x='Pclass',y='Age',data=train)<jupyter_output><empty_output><jupyter_text>now here we find that the average age of 1 class=38(approx),2 class=28(approx),3 class=25(approx) so we define a function to remove nan values<jupyter_code>def impute_age(cols):
    Age=cols[0]
    Pclass=cols[1]
     
    if pd.isnull(Age):
        if Pclass==1:
            return 38
        elif Pclass==2:
            return 28
        else:
            return 25
    else:
        return Age<jupyter_output><empty_output><jupyter_text>now apply that function<jupyter_code>train['Age']=train[['Age','Pclass']].apply(impute_age,axis=1)
(pd.isnull(train['Age']))
sn.heatmap(train.isnull())
train.drop('Cabin',axis=1,inplace=True)
train
pd.isnull(train)<jupyter_output><empty_output><jupyter_text>ufffff<jupyter_code>train.info()
embark=pd.get_dummies(train['Embarked'],drop_first=True)
sex=pd.get_dummies(train['Sex'],drop_first=True)
train.drop(['Name','Sex','Embarked','Ticket'],axis=1,inplace=True)
train.head()
train=pd.concat([train,sex,embark],axis=1)
train.head()<jupyter_output><empty_output><jupyter_text>Great! now  our data is ready for our model  BUILDING A logistic regression model<jupyter_code>from sklearn.model_selection import train_test_split
x_train,x_test,y_train,y_test=train_test_split(train.drop(['Survived'],axis=1),train['Survived'],test_size=0.30,random_state=101)
from sklearn.linear_model import LogisticRegression
logmodel=LogisticRegression()
logmodel.fit(x_train,y_train)
prediction=logmodel.predict(x_test)
from sklearn.metrics import confusion_matrix
accuracy=confusion_matrix(y_test,prediction)
accuracy
from sklearn.metrics import accuracy_score
accuracy=accuracy_score(y_test,prediction)
accuracy
prediction<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1300620750812888, 'fraction_numerical': 0.011528229382205143, 'mean_word_length': 8.696275071633238, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '492621', 'license': 'MIT', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1205, 'n_words': 209, 'path': 'exploratory data analysis.ipynb', 'repo_name': 'mohnish-38/My_Scripts', 'size': '3383'}