-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsv.randomForest_permute.pl
More file actions
executable file
·55 lines (40 loc) · 1.18 KB
/
csv.randomForest_permute.pl
File metadata and controls
executable file
·55 lines (40 loc) · 1.18 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl -w
use Util;
@ARGV = Util::explainCmdLine(@ARGV);
use Getopt::Std;
my(%options);
getopts("o:i:", \%options);
my $append = "TRUE";
my $niter = -1;
if(exists $options{"i"}) {
$niter = $options{"i"};
}
my($opts) = "";
if(exists $options{"o"}) {
$opts = $options{"o"};
}
if($niter == -1 || scalar(@ARGV) < 4) {
print "Permute the specified response field and output the AUC to the specified output. Iterate the process the specified # of times\n";
print "Usage: ~ -i <iter> [-o \"randomForest options\"] <in.csv> <label_field> <predictor_field1_index> ... <predictor_fieldn_index> <out>\n";
exit(1);
}
my $inFile = shift @ARGV;
my $lFld = shift @ARGV;
my $out = pop @ARGV;
my ($dir, $stem, $suf) = Util::getDirStemSuffix($out);
my $rfOptions = "";
if($opts) {
$rfOptions = "-o '$opts'";
}
for(my($i) = 0; $i < $niter; $i++) {
# permute
my $perm = "/tmp/$stem.permuted$i";
Util::run("permuteField.pl $inFile $lFld $perm", 1);
if($i == 0) {
Util::run("csv.randomForest.pl $rfOptions $perm $lFld @ARGV $out", 1);
}
else {
Util::run("csv.randomForest.pl -a $rfOptions $perm $lFld @ARGV $out", 1);
}
Util::run("rm $perm", 0);
}