about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/SLP/misc/export_cases.m
diff options
context:
space:
mode:
authorziejd22017-09-28 15:04:40 -0500
committerziejd22017-09-28 15:04:40 -0500
commit8070dc963753142bb86c4ed698d91fd623ed28e7 (patch)
treed0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/SLP/misc/export_cases.m
parent7cc31810d53176e805532b2789955f4eedbce6bb (diff)
downloadBNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning.

I am calling this BNW_1.02. It can be accessed at:
compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/SLP/misc/export_cases.m')
-rw-r--r--sourcecodes/bnt-master/SLP/misc/export_cases.m57
1 files changed, 57 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/SLP/misc/export_cases.m b/sourcecodes/bnt-master/SLP/misc/export_cases.m
new file mode 100644
index 00000000..4ab0d790
--- /dev/null
+++ b/sourcecodes/bnt-master/SLP/misc/export_cases.m
@@ -0,0 +1,57 @@
+function S = export_cases(data, names, file, misv)
+% filepath = export_cases(data, names, 'filename', missing_value)
+%  filename and missing_value [default [] if iscell(data) or -9999 if not] are optional
+% 
+% Exports BNT datasets to Netica cases (* for missing data)
+%
+% Written by Francois.Olivier.C.H@gmail.com
+% 
+% Informations could be found here http://www.norsys.com/downloads/
+%
+% version 80807
+
+% inits
+if nargin==1, file=['dnet' datestr(now,'-yymmdd-HHMMSS')]; end
+if nargin<2, error('Variable Names needed'); end
+if length(file)>5,
+  if prod(double(file((end-3):end)~='.cas')), file=[file '.cas']; end
+  name = file(1:end-5);
+else
+  name = file;
+  file = [file '.cas'];
+end
+if nargin<4, misv=-9999; end
+if iscell(data), data = bnt_to_mat(data,misv); end
+
+[N m]=size(data);
+if length(names)~=N, error('Sizes must be the same'); end
+
+% header of the file
+fid = fopen(file, 'w');
+fprintf(fid, '// exported from the Bayes Net Toolbox with export_cases function \n');
+fprintf(fid, '// please report bugs to francois.olivier.c.h@gmail.com\n\n');
+
+% write names
+for i=1:N
+  fprintf(fid, '%s\t',names{i});
+end
+
+% exports
+for l=1:m,
+  fprintf(fid, '\n');
+  for i=1:N,
+    if data(i,l)~=misv,
+      fprintf(fid, '%s',['x' num2str(data(i,l))]);
+    else
+      fprintf(fid, '%s','*');
+    end
+    if i<N, fprintf(fid, '\t'); end
+  end
+end
+
+% closes file
+fprintf(fid,'\n');
+fclose(fid);
+
+% outputs string
+S = [pwd '/' file];