Animal detection and classification using svm

8 views (last 30 days)
Tejomayi Raju
Tejomayi Raju on 18 Feb 2021
Answered: Gautam on 2 Jan 2025
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

Answers (1)

Gautam
Gautam on 2 Jan 2025
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

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!