about summary refs log tree commit diff
path: root/sourcecodes/parameter_learning/prepareInput.m
diff options
context:
space:
mode:
authorziejd22019-01-28 16:37:57 -0600
committerziejd22019-01-28 16:37:57 -0600
commit995f6673b5e725d6907ccd4f8e25033e8524f116 (patch)
tree5df08d9503394eab1190a01a640f3c338e8c74d6 /sourcecodes/parameter_learning/prepareInput.m
parentbb9d93322abf825368dedaafc2376ef8fdfc1e2f (diff)
downloadBNW-995f6673b5e725d6907ccd4f8e25033e8524f116.tar.gz
Deleting old versions of files
Diffstat (limited to 'sourcecodes/parameter_learning/prepareInput.m')
-rw-r--r--sourcecodes/parameter_learning/prepareInput.m7
1 files changed, 7 insertions, 0 deletions
diff --git a/sourcecodes/parameter_learning/prepareInput.m b/sourcecodes/parameter_learning/prepareInput.m
index 5268f872..3147d54e 100644
--- a/sourcecodes/parameter_learning/prepareInput.m
+++ b/sourcecodes/parameter_learning/prepareInput.m
@@ -1,4 +1,5 @@
 function  [ ] = prepareInput( pre )
+   % Jan. 2019: Modifying to allow for missing data.
    %   
    %  This function takes files that are uploaded to BNW and creates output
    %    files that can be used for structure and parameter learning.
@@ -74,6 +75,11 @@ for i = 1:ncases
     end
 end
 
+% Remove all rows that have missing data from data file
+remove_count = sum(any(strcmp(data,"NA"),2));
+data(any(strcmp(data,"NA"),2),:)=[];
+ncases = ncases - remove_count;
+
 % Determine whether or not the nodes are continuous or discrete.
 % First, treat them as all discrete and get the states and number of stats(levels).
 levels = cell(1,nnodes);
@@ -242,6 +248,7 @@ dout = fopen(descfile,'w');
 fprintf(dout,['As loaded, the input file had the following properties:\n\n']);
 dout = fopen(descfile,'a');
 fprintf(dout,'There are %i variables and %i cases(rows).\n',size(labels,2),ncases);
+fprintf(dout,'%i cases(rows) have been removed because they contained NA (missing data).\n',remove_count);
 fprintf(dout,'The variable names are:\n');
 fprintf(dout,'%s\t',labels{1:end-1});
 fprintf(dout,'%s\n\n',labels{end});