Error using fprintf Invalid file identifier. Use fopen to generate a valid file identifier.

1 visualización (últimos 30 días)
Hello, I have a problem, every program I try to run gives me this error.What should I do?
mycode :
clc
clear
% Loading dataset
mine=xlsread('mine.xls');
addpath('tensor_toolbox','poblano_toolbox');
mine(:,16)=1392 - mine(:,16);
Target=mine(:,9);
mine(:,9) = [];
mine(isnan(Target) ,:) = [];
Target(isnan(Target)) = [];
mine(:,16)=[];
% impute by tensor
mine = num2cell(mine);
for i=1:size(mine,1)
for j=1:size(mine,2)
if isnan(mine{i,j})
mine{i,j} =[];
else
mine{i,j} = mine{i,j} + 1;
end
end
end
dataMatrix=mine;
column14 = dataMatrix(:,14);
dataMatrix(:,14) = [];
bdeu = 2;
[bnet,ll,temp1,~] = structureEM(dataMatrix',bdeu,20,20,'EM',1);
clc
dataMatrix = temp1';
dataMatrix=cell2num(dataMatrix);
%% Read and Prepare data
% dataMatrix(isnan(dataMatrix)) = 0;
R = 3;
Ptmp = zeros(size(dataMatrix));
Ptmp(dataMatrix ~= 0) = 1;
X = tensor(dataMatrix);
P = tensor(Ptmp);
%% Create initial guess using 'nvecs'
M_init = create_guess('Data', X, 'Num_Factors', R, ...
'Factor_Generator', 'nvecs');
ncg_opts = ncg('defaults');
ncg_opts.StopTol = 1.0e-9;
ncg_opts.RelFuncTol = 1.0e-30;
ncg_opts.MaxIters = 10^4;
ncg_opts.DisplayIters = 500;
ncg_opts;
[M,~,output] = cp_wopt(X, P, R, 'init', M_init, ...
'alg', 'ncg', 'alg_options', ncg_opts);
exitflag = output.ExitFlag;
%% data imputed
dataMatrixImput = double(M);
dataMatrixImput(dataMatrix ~= 0) = dataMatrix(dataMatrix ~= 0);
mine=dataMatrixImput;
% set train and test
num_neighbors=4;
i=randperm(667);
Train=mine(i(1:570),:);
TargetTrain=Target(i(1:570));
Test = mine(i(480:end),:);
TargetTest = Target(i(480:end));
% Classification with KNN
knn_mdl = fitcknn(Train,TargetTrain);
knn_mdl.NumNeighbors = num_neighbors;
KNN_PredictedLabels=predict(knn_mdl,Test);
err=KNN_PredictedLabels-TargetTest;
AA=0;
for i=1:length(err)
if err(i)==0
AA=AA+1;
end
end
disp((AA/length(err))*100);
answer :
var 1 ncats=5 cats=2 3 4 5
var 2 ncats=10 cats=2 3 10
var 3 ncats=10 cats=2 3 10
var 4 ncats=10 cats=2 10
var 5 ncats=10 cats=2 10
var 6 ncats=4 cats=2 3 4
var 7 ncats=5 cats=2 3 4 5
var 8 ncats=13 cats=2 3 5 10 13
var 9 ncats=4 cats=2 3 4
var 10 ncats=10 cats=2 3 4 5 6 7 10
var 11 ncats=6 cats=2 3 4 5 6
var 12 ncats=23 cats=1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
var 13 ncats=31 cats=1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 29 30 31
var 14 ncats=111 cats=29 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 86 87 89 90 91 93 95 101 111
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14
call hill-climbing SL method
building options file: /tmp/tp1b66ff2d_7a21_41cf_90f5_371c7d516528
Error using fprintf
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in write_options_structurelearning (line 41)
case 'inputfile', fprintf(fd,'inputfile=%s\n',args{i+1});
Error in call_structurelearning (line 252)
write_options_structurelearning(optname,...
Error in structureEM (line 165)
[bnet,bb,topsort] =
call_structurelearning(0,[],datCompleted,[],allowmat,-1,16000,verb,6,-1,-1,bdeu,maxpar);
Error in Tensor1_on_knn (line 27)
[bnet,ll,temp1,~] = structureEM(dataMatrix',bdeu,20,20,'EM',1);
>>
  6 comentarios
Mohammad baba
Mohammad baba el 14 de Jun. de 2020
image-analyst
Thanks for your help. I emailed the person who posted this toolbox on the GitHub site and I'm looking forward to hearing from you.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by