<jupyter_start><jupyter_text>Data Analysis: Viewing the data in different formats and learnign relations<jupyter_code># survivors
sns.countplot(x="Survived",data=dataset)
# survived - male and female 
sns.countplot(x='Survived',hue='Sex',data=dataset)
# survived - passenger class
sns.countplot(x='Survived',hue='Pclass',data=dataset)
# age distribution
dataset["Age"].plot.hist()
# fare distribution
dataset["Fare"].plot.hist(bins=10,figsize=(10,5))
dataset.info()
# survived - siblings and spouses
sns.countplot(x='SibSp',data=dataset)
# return null values
dataset.isnull()
dataset.isnull().sum()
# heatmap
sns.heatmap(dataset.isnull(),yticklabels=False,cmap="Accent")
sns.boxplot(x="Pclass",y="Age",data=dataset)<jupyter_output><empty_output><jupyter_text>Data Wrangling: cleaning null values and unnecessary data from the dataset<jupyter_code>dataset.head(10)
# remove cabin column
dataset.drop("Cabin",axis=1,inplace=True)
dataset.head(5)
# drop rows with null values
dataset.dropna(inplace=True)
dataset.head(10)
sns.heatmap(dataset.isnull(),yticklabels=False,cbar=False)
dataset.isnull().sum()
dataset.head(10)<jupyter_output><empty_output><jupyter_text>create new datasets with descrete values from a cloumn<jupyter_code># passenger class
# drop first column
passengerClass=pd.get_dummies(dataset['Pclass'],drop_first=True)
passengerClass.head(5)
# sex
passengerSex=pd.get_dummies(dataset['Sex'],drop_first=True)
passengerSex.head(5)
# embarked
passengerEmbarked=pd.get_dummies(dataset['Embarked'],drop_first=True)
passengerEmbarked.head(5)
# add new descrete data column in main table
dataset=pd.concat([dataset,passengerClass,passengerSex,passengerEmbarked],axis=1)
dataset.head(5)
dataset.info()
# drop columns converted into descrete columns
dataset.drop(['PassengerId','Pclass','Name','Sex','Ticket','Embarked'],axis=1,inplace=True)
dataset.head(5)<jupyter_output><empty_output><jupyter_text>Train Data<jupyter_code>X=dataset.drop("Survived",axis=1)
y=dataset["Survived"]
# split data into training and testing phase
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=1)
from sklearn.linear_model import LogisticRegression
logmodel=LogisticRegression()
logmodel.fit(X_train,y_train)
predictions=logmodel.predict(X_test)
from sklearn.metrics import classification_report
classification_report(y_test,predictions)
from sklearn.metrics import confusion_matrix
confusion_matrix(y_test,predictions)
from sklearn.metrics import accuracy_score
accuracy_score(y_test,predictions)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12677679600461006, 'fraction_numerical': 0.009604302727621975, 'mean_word_length': 10.944954128440367, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '649033', 'license': 'MIT', 'n_tokens_mistral': 911, 'n_tokens_neox': 883, 'n_words': 150, 'path': 'Course/edureka/3. Projects/titanic/titanic.ipynb', 'repo_name': 'sajalT05/Machine-Learning', 'size': '2603'}