how to create dataset for classification and pattern recognition (neural network)

5 views (last 30 days)
Dear all I have a table of extracted features from the image. I need to create a dataset to use it in classification and pattern recognition. I have many images and i will group them according to disease stage to 4 or 5 groups or classes. could you help me how to create the dataset (inputs and targets) and if there some advice to create a good classifier and have a good results. thank you

Answers (1)

Aditya
Aditya on 8 Feb 2025
Hi Hanem,
Creating a dataset for classification and pattern recognition involves several key steps.
  1. Organize your data
  2. Prepare the dataset
  3. Split the dataset
  4. Choose and Trainb a classifier
Following is the example code for the same:
% Assuming 'featuresTable' is your table with extracted features
% and 'diseaseStage' is a vector with labels for each image
% Convert the features table to a matrix
X = table2array(featuresTable);
% Ensure 'diseaseStage' is a column vector
Y = diseaseStage(:);
% Check dimensions
assert(size(X, 1) == length(Y), 'Number of samples in X and Y must match');
% Set a random seed for reproducibility
rng(0);
% Split data into training (80%) and testing (20%)
cv = cvpartition(Y, 'HoldOut', 0.2);
XTrain = X(training(cv), :);
YTrain = Y(training(cv), :);
XTest = X(test(cv), :);
YTest = Y(test(cv), :);
% Train an SVM classifier
SVMModel = fitcsvm(XTrain, YTrain, 'KernelFunction', 'linear', 'Standardize', true);
% Predict on the test set
YPred = predict(SVMModel, XTest);
% Evaluate the classifier
accuracy = sum(YPred == YTest) / length(YTest);
fprintf('Test Accuracy: %.2f%%\n', accuracy * 100);

Community Treasure Hunt

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

Start Hunting!