<jupyter_start><jupyter_text>Predictions using Titanic Dataset<jupyter_code>import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score

df = pd.read_csv('titanic_2.csv')
df['male'] = df['Sex'] == 'male'<jupyter_output><empty_output><jupyter_text>Confusion Matrix<jupyter_code>from sklearn.metrics import confusion_matrix
print(confusion_matrix(y,y_pred))<jupyter_output>[[480  65]
 [109 233]]<jupyter_text>Training and Testing in Sklearn<jupyter_code>from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X,y)
print('whole dataset shape: ',X.shape, y.shape)
print('training set shape: ',X_train.shape,y_train.shape)
print('test set shape: ',X_test.shape,y_test.shape)<jupyter_output>whole dataset shape:  (887, 6) (887,)
training set shape:  (665, 6) (665,)
test set shape:  (222, 6) (222,)<jupyter_text>Logistic Regresssion Model<jupyter_code>model = LogisticRegression(solver='liblinear')
model.fit(X_train,y_train)
print(model.score(X_test,y_test))<jupyter_output>0.8018018018018018<jupyter_text>Predictions<jupyter_code>y_pred = model.predict(X_test)

print('accuracy = ',accuracy_score(y_test,y_pred))
print('precision = ',precision_score(y_test,y_pred))
print('recall = ',recall_score(y_test,y_pred))
print('f1 score = ',f1_score(y_test,y_pred))<jupyter_output>accuracy =  0.8018018018018018
precision =  0.75
recall =  0.7142857142857143
f1 score =  0.7317073170731706
{'fraction_non_alphanumeric': 0.12606697307944845, 'fraction_numerical': 0.07091267235718976, 'mean_word_length': 9.808510638297872, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '173738', 'license': 'Apache-2.0', 'n_tokens_mistral': 664, 'n_tokens_neox': 585, 'n_words': 96, 'path': 'Model_evaluation.ipynb', 'repo_name': 'ransherraj/Predictions-using-Titanic-Dataset-', 'size': '1523'}