𝐒𝐕𝐌 is a supervised machine learning algorithm which has been used for a classification task in this example. 𝗦𝘂𝗽𝗽𝗼𝗿𝘁 𝗩𝗲𝗰𝘁𝗼𝗿 𝗠𝗮𝗰𝗵𝗶𝗻𝗲 can perform both linear and non-linear classification using the 𝘬𝘦𝘳𝘯𝘦𝘭 𝘵𝘳𝘪𝘤𝘬. The main objective of 𝐒𝐕𝐌 is to find the optimal hyperplane in an N-dimensional space that can separate the data points in different classes in the feature space.
I used 𝐦𝐮𝐬𝐡𝐫𝐨𝐨𝐦𝐬.𝐜𝐬𝐯 dataset for this example. The dataset is available in the repository. This dataset contains two types of mushrooms: 𝐞𝐝𝐢𝐛𝐥𝐞 & 𝐩𝐨𝐢𝐬𝐨𝐧𝐨𝐮𝐬. It has 22 features. I used a 𝐩𝐨𝐥𝐲𝐧𝐨𝐦𝐢𝐚𝐥 kernel with 𝐝𝐞𝐠𝐫𝐞𝐞 2 to train the 𝐒𝐕𝐌 model and got 𝟵𝟵.𝟳𝟭% accuracy on the test set. The 𝐠𝐚𝐦𝐦𝐚 and 𝐫𝐞𝐠𝐮𝐥𝐚𝐫𝐢𝐳𝐚𝐭𝐢𝐨𝐧 (𝐂) parameters were set to 𝗮𝘂𝘁𝗼 and 0.2, respectively.
𝙄𝙢𝙥𝙤𝙧𝙩𝙖𝙣𝙩 𝙩𝙞𝙢𝙚𝙨𝙩𝙖𝙢𝙥𝙨:
00:39 - Import required libraries
02:21 - Load 𝗺𝘂𝘀𝗵𝗿𝗼𝗼𝗺𝘀 dataset
06:38 - Perform preprocessing
08:15 - Separate features and labels
09:51 - Split the dataset
11:35 - Apply 𝗦𝗩𝗠
14:23 - Plot 𝗰𝗼𝗻𝗳𝘂𝘀𝗶𝗼𝗻_𝗺𝗮𝘁𝗿𝗶𝘅
20:55 - Print 𝗰𝗹𝗮𝘀𝘀𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻_𝗿𝗲𝗽𝗼𝗿𝘁
21:30 - Random prediction
𝑮𝒊𝒕𝑯𝒖𝒃 𝒂𝒅𝒅𝒓𝒆𝒔𝒔: https://github.com/randomaccess2023/M...
#datascience #machinelearning #scikitlearn #sklearn #supportvectormachine #svm #jupyternotebook #pythonprogramming #python #mushroomsdataset #confusionmatrix