0% found this document useful (0 votes)
61 views1 page

SVM (Using Python)

This document loads and prepares the Titanic dataset for machine learning modeling. It splits the data into training and test sets, fits a support vector machine (SVM) model to predict survival using the training set, makes predictions on the test set, and evaluates the model's performance by printing the confusion matrix and accuracy score.

Uploaded by

ochin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views1 page

SVM (Using Python)

This document loads and prepares the Titanic dataset for machine learning modeling. It splits the data into training and test sets, fits a support vector machine (SVM) model to predict survival using the training set, makes predictions on the test set, and evaluates the model's performance by printing the confusion matrix and accuracy score.

Uploaded by

ochin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

import pandas as pd

import matplotlib.pyplot as plt


import sklearn
from sklearn.linear_model import LogisticRegression
import numpy as np
import seaborn as sns
#% matplotlib inline
import math
titanic_data = pd.read_csv("C:\\Users\\OCHIN\\Desktop\\Titanic.csv")
print(titanic_data.keys())
y=titanic_data["survived"]
X=titanic_data.drop("survived",axis=1)
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.3, random_state=42)
# type: (object, object, object, object)
from sklearn.svm import SVC
model=SVC()
model.fit(X_train,y_train)
predictions=model.predict (X_test)
from sklearn.metrics import confusion_matrix
print(confusion_matrix(y_test,predictions))
from sklearn.metrics import accuracy_score
print(accuracy_score(y_test,predictions))

#print(titanic_data['DESCR'])

You might also like