フィルターのクリア

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

9 ビュー (過去 30 日間)
Asuka
Asuka 2024 年 7 月 12 日 19:01
回答済み: Walter Roberson 2024 年 7 月 12 日 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;

回答 (1 件)

Walter Roberson
Walter Roberson 2024 年 7 月 12 日 20:06
Your values in the table are scalars. You cannot create response variables from scalars.

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by