SVM Algorithm for Python Code
For every Machine Learning Algorithm following are the major steps to build the Model: 1. Collection of data 2. Divide data into training and testing 3. Build the Network 5. Performance Analysis and Accuracy calculations Step1 : Load dataset #Import scikit-learn dataset library from sklearn import datasets Ex. cancer = datasets.load_breast_cancer() Step 2:Split dataset into a training set and test set Import train_test_split function from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(cancer.data, cancer.target, test_size=0.3,random_state=109) # 70% training and 30% test Step3:Create a svm Classifier Import svm model from sklearn import svm clf = svm.SVC(kernel='linear') # Linear Kernel clf = svm.SVC(kernel='linear') # Linear Kernel Step4:Train the model using the training sets clf.fit(X_train, y_train) ...
Comments
Post a Comment