#!/tools/bin/perl
#
# Lutz Prechelt, 94/02/14
#
# Encodes 'cancer' raw data file into a training file.
#
# usage: raw2cod inputfile >outputfile

$nr = 1;
@vals = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
while (<>) {
  @F = split (",");
  for ($i = 1; $i <= $#F-1; $i++) {  #skip field zero (id)
    $v = $F[$i];
    if ($v eq "?") {
      printf ("0.35 ");
    }
    else {
      printf ("%g ", $v/10);
    }
  }
  $v = $F[10];
  printf ("%s\n", $v == 2 ? "1 0" : "0 1");
}

