Sure! Here is an example of SVM (Support Vector Machine) code implemented in Python using the scikit-learn library:
python
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn import svm
# Load the Iris dataset
iris = datasets.load_iris()
X = iris.data
y = iris.target
# Split the dataset into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
# Create an SVM classifier
clf = svm.SVC(kernel='linear')
# Train the classifier on the training data
clf.fit(X_train, y_train)
# Predict the classes of test samples
y_pred = clf.predict(X_test)
# Evaluate the model's accuracy
accuracy = clf.score(X_test, y_test)
print("Accuracy:", accuracy)
In this example, we use the famous Iris dataset from the datasets module. We split the dataset into training and test sets using the train_test_split function. Then, we create an SVM classifier using the linear kernel. The classifier is trained on the training data using the fit method. Finally, we predict the classes of test samples using the predict method and calculate the accuracy of the model using the score method.