in Machine Learning by
Q:

What is SVM (Support Vector Machines)?

1 Answer

0 votes
by
SVM is a Machine Learning algorithm that is majorly used for classification. It is used on top of the high dimensionality of the characteristic vector.

Below is the code for the SVM classifier:

# Introducing required libraries

from sklearn import datasets

from sklearn.metrics import confusion_matrix

from sklearn.model_selection import train_test_split

# Stacking the Iris dataset

iris = datasets.load_iris()

# A -> features and B -> label

A = iris.data

B = iris.target

# Breaking A and B into train and test data

A_train, A_test, B_train, B_test = train_test_split(A, B, random_state = 0)

# Training a linear SVM classifier

from sklearn.svm import SVC

svm_model_linear = SVC(kernel = 'linear', C = 1).fit(A_train, B_train)

svm_predictions = svm_model_linear.predict(A_test)

# Model accuracy for A_test

accuracy = svm_model_linear.score(A_test, B_test)

# Creating a confusion matrix

cm = confusion_matrix(B_test, svm_predictions)
Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

0 votes
asked Dec 27, 2019 in Data Science by sharadyadav1986
0 votes
asked Feb 17, 2020 in Azure by rahuljain1
+2 votes
asked Jul 24, 2019 in Azure by Robindeniel
0 votes
asked Aug 1, 2020 in Matlab by Robindeniel
+1 vote
asked Jan 28, 2020 in Data Handling by rahuljain1
...