Lab Week 7
Lab Week 7
Lab Week 7
Random Data
Step 6: Import Sklearn and split the testing data randomly using only 20% of the data
from sklearn.model_selection import train_test_split_data
input_train, input_test, target_train, target_test = train_test_split(input_data, target_data,
nnnnnn test_size = 0.2)
Step 7: After split the data user must import SVM and SVC model, also choose 4 different kernels
sklearn.svm import SVC
svcModel = SVC (kernel = 'linear'), or sigmoid, or rbf, or poly
svcModel.fit(input_train, target_train)
Step 10: Compare the accuracy of each kernel and choose the highest accuracy
Step 11: In this practice the best kernel is poly as it get 100% accuracy
Fixed Data
Step 2: Separate the data testing by 30 data and data training by 120 data in new microsoft excel
ssss file using random generator
Step 6: import SVM and SVC model, also choose 4 different kernels
sklearn.svm import SVC
svcModel = SVC (kernel = 'linear'), or sigmoid, or rbf, or poly
svcModel.fit(input_data_train, target_data_train)
Step 8: Drop the last column and number column for testing data
input_data_test = data_test.drop(columns = ['No', 'species'])
input_data_test
Step 13: In this practice the best kernel is Linear as it get 96.7 accuracy
The difference result accuracy is based on different kernel that has been used to find the most
optimized and efficient kernel technique
Advantage of SVM
• SVM works relatively well when there is a clear margin of separation between classes.
• SVM is more effective in high dimensional spaces.
• SVM is effective in cases where the number of dimensions is greater than the number of
samples.
• SVM is relatively memory efficient
Disadvantage of SVM