Animal detection and classification using svm
10 次查看(过去 30 天)
显示 更早的评论
We are working on animal detection and classification (wild animal). We thought of using SVM classification algorithm. We are not getting the code. Our dataset /database is cheetah, elephant, fox, pig, tiger and wolf. We have chosen the image with nature background
0 个评论
回答(1 个)
Gautam
2025-1-2
Hello Tejomayi,
You can use the “fitcsvm” function to perform classification of animals using the SVM algorithm. Assuming you have the features data, below is a workflow that you can refer to
% Assume we have 3 features per animal.
features = [
70, 60, 110;
3000, 3, 25;
8, 8, 60;
90, 40, 11;
220, 80, 65;
40, 30, 55
];
% Corresponding labels for each animal
labels = {'Cheetah', 'Elephant', 'Fox', 'Pig', 'Tiger', 'Wolf'}';
% Convert string labels to categorical
categoricalLabels = categorical(labels);
% Train the SVM classifier
SVMModel = fitcsvm(features, categoricalLabels, 'KernelFunction', 'linear', 'Standardize', true);
% Display the trained SVM model
disp(SVMModel);
% Example of classifying a new animal based on its features
newAnimalFeatures = [100, 50, 50]; % Example features for a new animal
predictedLabel = predict(SVMModel, newAnimalFeatures);
% Display the predicted label
fprintf('The predicted animal is: %s\n', string(predictedLabel));
Please refer to the following documentation for more information on the “fitcsvm” function
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!