Clear Filters
Clear Filters

Classification for seperate training and testing dataset

4 views (last 30 days)
Hello gyus,
I extract 20 features for 8 images(which are 8 diseases) and then I made a .csv file of these features.I have also an another .csv file
with these features from a dataset of 3000 images. So I have the trining and the testing dataset. I want to classificate the 3000 images
with the 8 diseases from the the first .csv file. Can i use the tool of classification learner or only writing code?
Thanks in advance!

Answers (1)

Nihal
Nihal on 26 Jul 2024 at 11:50
Yes, you can certainly use the Classification Learner app in MATLAB to classify your dataset of 3000 images into the 8 disease categories based on the features extracted from your images. The Classification Learner app provides a user-friendly interface for training, validating, and comparing different classification models without the need to write extensive code.Steps to Use Classification Learner App
Load Your Data:
  • Ensure your training and testing datasets are in .csv files.
  • Read these files into MATLAB using the readtable function.
trainingData = readtable('training_data.csv');
testingData = readtable('testing_data.csv');
  1. Open Classification Learner App:
  • Open the app by typing classificationLearner in the MATLAB command window or by navigating to the Apps tab and selecting Classification Learner.
classificationLearner
Import Data:
  • In the Classification Learner app, click on New Session and then From Workspace.
  • Select your training data table (trainingData).
Select Features and Response:
  • Choose the features (predictors) and the response (target variable) for classification.
  • Ensure that the response variable is correctly labeled in your training dataset.
Train Models:
  • Choose different classifiers to train your model (e.g., Decision Trees, SVM, k-NN, etc.).
  • Click on Train to start the training process.
Evaluate Models:
  • Use the app to compare the performance of different models using metrics like accuracy, confusion matrix, ROC curves, etc.
  • Select the best-performing model based on your evaluation.
Export the Model:
  • Once you have identified the best model, you can export it to the workspace for further use.
  • Click on Export Model and then Export Compact Model.
Classify New Data:
  • Use the exported model to classify the testing dataset.
% Assuming your model is exported as 'trainedModel'
predictions = trainedModel.predictFcn(testingData);
Example Code to Read Data and Use Exported Model
% Read training and testing data
trainingData = readtable('training_data.csv');
testingData = readtable('testing_data.csv');
% Assuming 'trainedModel' is the exported model from Classification Learner
% Predict on new data
predictions = trainedModel.predictFcn(testingData);
% Display predictions
disp(predictions);
Summary
  • Classification Learner App: A powerful tool for training and evaluating classification models without writing extensive code.
  • Data Import: Load your .csv files into MATLAB and import them into the Classification Learner app.
  • Model Training and Evaluation: Train multiple models, evaluate their performance, and select the best one.
  • Export and Predict: Export the best model and use it to classify new data.
Using the Classification Learner app simplifies the process of model training and evaluation, making it accessible even if you prefer not to write code. However, if you need more customization or automation, you can always write your own MATLAB code for classification.

Community Treasure Hunt

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

Start Hunting!