- Verify compute_mapping Implementation: Ensure that the compute_mapping function is correctly implemented to handle PCA. It should call the pca function with the correct number of arguments. Here's a simplified example of how compute_mapping might handle PCA:
I'm getting an error when I was using compute_mapping function for pca, please give me any suggestions how can I solve it?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Error using internal.stats.parseArgs (line 42)
Wrong number of arguments.
Error in pca (line 174)
= internal.stats.parseArgs(paramNames, defaults, varargin{:});
Error in compute_mapping (line 309)
if isempty(varargin), [mappedA, mapping] = pca(A, no_dims);
Error in run_feature (line 34)
[P_A_feature, mapping1] = compute_mapping(P_A_feature, 'PCA', 28); //this is the code i wrote
0 Kommentare
Antworten (1)
Aditya
am 4 Feb. 2025
Hi Bhawna,
The error message you're encountering suggests that there's an issue with the number of arguments being passed to a function, likely the pca function. In your case, it seems to be related to how compute_mapping is calling pca.
To troubleshoot and resolve this issue, let's go through a few steps:
function [mappedA, mapping] = compute_mapping(A, method, no_dims)
if strcmpi(method, 'PCA')
[coeff, score, latent, tsquared, explained, mu] = pca(A, 'NumComponents', no_dims);
mappedA = score; % The transformed data
mapping.coeff = coeff;
mapping.latent = latent;
mapping.explained = explained;
mapping.mu = mu;
else
error('Unknown method.');
end
end
2. Arguments for pca: The pca function in MATLAB can take additional parameters, such as 'NumComponents', to specify the number of principal components. Make sure these parameters are correctly passed.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Dimensionality Reduction and Feature Extraction finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!