Titanic

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

2) Create a sns.barplot using x = "Pclass" and Y="Survived" and data=train in a tuple

sns.barplot(x="Pclass", y="Survived", data=train)

1) Import seaborn as sns 2) Create a sns.barplot using x = "Sex" and Y="Survived" and data=train_data in a tuple

sns.barplot(x="Sex", y="Survived", data=train_data)

Create a sns.barplot using x = "Sibsp" and Y="Survived" and data=train in a tuple

sns.barplot(x="SibSp", y="Survived", data=train)

# KNN or k-Nearest Neighbors from sklearn.neighbors import KNeighborsClassifier knn = KNeighborsClassifier() knn.fit(x_train, y_train) y_pred = knn.predict(x_val) acc_knn = round(accuracy_score(y_pred, y_val) * 100, 2) print(acc_knn)

77.66

# Gaussian Naive Bayes from sklearn.naive_bayes import GaussianNB from sklearn.metrics import accuracy_score gaussian = GaussianNB() gaussian.fit(x_train, y_train) y_pred = gaussian.predict(x_val) acc_gaussian = round(accuracy_score(y_pred, y_val) * 100, 2) print(acc_gaussian)

78.68

# Linear SVC from sklearn.svm import LinearSVC linear_svc = LinearSVC() linear_svc.fit(x_train, y_train) y_pred = linear_svc.predict(x_val) acc_linear_svc = round(accuracy_score(y_pred, y_val) * 100, 2) print(acc_linear_svc)

78.68

# Logistic Regression from sklearn.linear_model import LogisticRegression logreg = LogisticRegression() logreg.fit(x_train, y_train) y_pred = logreg.predict(x_val) acc_logreg = round(accuracy_score(y_pred, y_val) * 100, 2) print(acc_logreg)

79.19

# Perceptron from sklearn.linear_model import Perceptron perceptron = Perceptron() perceptron.fit(x_train, y_train) y_pred = perceptron.predict(x_val) acc_perceptron = round(accuracy_score(y_pred, y_val) * 100, 2) print(acc_perceptron)

79.19

# Stochastic Gradient Descent from sklearn.linear_model import SGDClassifier sgd = SGDClassifier() sgd.fit(x_train, y_train) y_pred = sgd.predict(x_val) acc_sgd = round(accuracy_score(y_pred, y_val) * 100, 2) print(acc_sgd)

80.2

#Decision Tree from sklearn.tree import DecisionTreeClassifier decisiontree = DecisionTreeClassifier() decisiontree.fit(x_train, y_train) y_pred = decisiontree.predict(x_val) acc_decisiontree = round(accuracy_score(y_pred, y_val) * 100, 2) print(acc_decisiontree)

80.71

# Random Forest from sklearn.ensemble import RandomForestClassifier randomforest = RandomForestClassifier() randomforest.fit(x_train, y_train) y_pred = randomforest.predict(x_val) acc_randomforest = round(accuracy_score(y_pred, y_val) * 100, 2) print(acc_randomforest)

81.22

# Support Vector Machines from sklearn.svm import SVC svc = SVC() svc.fit(x_train, y_train) y_pred = svc.predict(x_val) acc_svc = round(accuracy_score(y_pred, y_val) * 100, 2) print(acc_svc)

82.74

# Gradient Boosting Classifier from sklearn.ensemble import GradientBoostingClassifier gbk = GradientBoostingClassifier() gbk.fit(x_train, y_train) y_pred = gbk.predict(x_val) acc_gbk = round(accuracy_score(y_pred, y_val) * 100, 2) print(acc_gbk)

84.77


Set pelajaran terkait

Vision Terms & Visual Perception

View Set

NUR 3420 Pharmacology PrepU Chapter 9

View Set

PEDS: Chapter 6 Growth and Development of the School-age Child

View Set

Chapter 29 - Endocrine System Tumors

View Set

Cardiac Arrest and Shock Assessment

View Set