Why does the error at the bottom show up even though the correct dataset seems to be selected?
조회 수: 2 (최근 30일)
이전 댓글 표시
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;
댓글 수: 0
답변 (1개)
Walter Roberson
2024년 7월 12일
Your values in the table are scalars. You cannot create response variables from scalars.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Feature Detection and Extraction에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!