Effacer les filtres
Effacer les filtres

Why does the error at the bottom show up even though the correct dataset seems to be selected?

9 vues (au cours des 30 derniers jours)
Asuka
Asuka le 12 Juil 2024 à 19:01
Réponse apportée : Walter Roberson le 12 Juil 2024 à 20:06
It says "Unable to find suitable response variable ~"
Here is the code:
img = imread("C:\Users\xxoox\OneDrive\デスクトップ\MATLAB works\Data\MathWorks Images\ocean.jpg"); % Load the unlabeled image
load ("C:\Users\xxoox\OneDrive\デスクトップ\MATLAB works\Computer Vision for Engineering and Science\C2-MachineLearningForComputerVision\Module 2\gcClassifierSaturation.mat","gcClassifierSaturation") % Load the model trained using hand-selected features
load ("C:\Users\xxoox\OneDrive\デスクトップ\MATLAB works\Computer Vision for Engineering and Science\C2-MachineLearningForComputerVision\Module 2\gcClassifierBag.mat","gcClassifierBag") % Load the model trained using automatically generated features
load ("C:\Users\xxoox\OneDrive\デスクトップ\MATLAB works\Computer Vision for Engineering and Science\C2-MachineLearningForComputerVision\Module 2\bag.mat","bag") % Load bag of visual words object created by bagOfFeatures
% Step 1: Create a table of saturation-based predictor features
% Convert the image to HSV color space
hsvImg = rgb2hsv(img);
% Extract the saturation channel
saturation = hsvImg(:,:,2);
% Calculate the mean and standard deviation of the saturation
avgSat = mean(saturation(:));
stdSat = std(saturation(:));
% Create a table of saturation-based predictor features
gcTableSaturation = table(avgSat, stdSat);
% Step 2: Use gcClassifierSaturation.predictFcn to classify the unlabeled image
% Use the classifier to predict the label
prediction = gcClassifierSaturation.predictFcn(gcTableSaturation);
% Attach the prediction to the table
gcTableSaturation.prediction = prediction;
% Step 3: Create a table of bagOfFeatures-based predictor features
% Encode the image using the bag of features
featureVector = encode(bag, img);
% Create a table of predictor features for the unlabeled image
gcTableBag = array2table(featureVector);
gcTableBag.Properties.VariableNames = arrayfun(@(x) ['f' num2str(x)], 1:500, 'UniformOutput', false);
% Step 4: Use gcClassifierBag.predictFcn to classify the unlabeled image
% Use the classifier to predict the label
predictionBag = gcClassifierBag.predictFcn(gcTableBag);
% Attach the prediction to the table
gcTableBag.prediction = predictionBag;

Réponses (1)

Walter Roberson
Walter Roberson le 12 Juil 2024 à 20:06
Your values in the table are scalars. You cannot create response variables from scalars.

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by