Skip to content

Commit

Permalink
Utils.pln
Browse files Browse the repository at this point in the history
removed
  • Loading branch information
janvitek committed Apr 25, 2013
1 parent cdb3fa4 commit e42da6d
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 33 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ Team
```
SriSatish Ambati
Cliff Click
Jan Vitek
Petr Maj
Tomas Nykodym
Kevin Normoyle
Expand All @@ -61,6 +60,7 @@ Cyprien Noel
Lauren Brems
Opensource:
Jan Vitek
Michal Malohlava
Mr.Jenkins
```
Expand All @@ -76,7 +76,6 @@ Trevor Hastie
```

Systems, Data, FileSystems and Hadoop

```
Doug Lea
Chris Pouliot
Expand All @@ -85,7 +84,6 @@ Charles Zedlewski
Niall Dalton
```


Investors
---------------------------
```
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/hex/rf/Confusion.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import water.*;
import water.ValueArray.Column;
import water.util.Utils;
import water.util.*;
import water.util.L.Tag.Sys;

import com.google.common.primitives.Ints;

Expand Down Expand Up @@ -128,7 +129,7 @@ static public Confusion make(RFModel model, int modelSize, Key datakey, int clas
if( classWt != null )
for( int i=0; i<classWt.length; i++ )
if( classWt[i] != 1.0 )
Utils.pln("[CM] Weighted votes "+i+" by "+classWt[i]);
L.info(Sys.CONFM,"Weighted votes ",i," by ",classWt[i]);
return C;
}

Expand Down Expand Up @@ -359,9 +360,7 @@ public final void report() {
+ " Validated on (rows): " + _rows + "\n"
+ " Rows skipped during validation: " + _skippedRows + "\n"
+ " Mispredictions per tree (in rows): " + Arrays.toString(_errorsPerTree)+"\n";


Utils.pln(s);
L.info(Sys.RANDF,s);
}

/** Returns classification error. */
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/hex/rf/DABuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import jsr166y.ForkJoinTask;
import jsr166y.RecursiveAction;
import water.*;
import water.util.Utils;
import water.util.*;
import water.util.L.Tag.Sys;

class DABuilder {

Expand All @@ -30,7 +31,7 @@ static DABuilder create(final DRF drf) {
private final void checkAndLimitFeatureUsedPerSplit(final DataAdapter dapt) {
int validCols = _drf._rfmodel._va._cols.length-1; // for classIdx column
if (validCols < _drf._numSplitFeatures) {
Utils.pln("Limiting features from " + _drf._numSplitFeatures +
L.warn(this,Sys.RANDF,"Limiting features from " + _drf._numSplitFeatures +
" to " + validCols + " because there are no more valid columns in the dataset");
_drf._numSplitFeatures= validCols;
}
Expand Down Expand Up @@ -105,7 +106,7 @@ protected DataAdapter inhaleData(Key [] keys) {
// And invoke collected jobs
ForkJoinTask.invokeAll(dataInhaleJobs);
dapt.shrink();
Utils.pln("[RF] Inhale done in " + t_inhale);
L.info(this,Sys.RANDF,"Inhale done in " + t_inhale);
return dapt;
}
}
11 changes: 6 additions & 5 deletions src/main/java/hex/rf/DRF.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import water.*;
import water.ValueArray.Column;
import water.Timer;
import water.util.Utils;
import water.util.*;
import water.util.L.Tag.Sys;

/** Distributed RandomForest */
public final class DRF extends water.DRemoteTask {
Expand Down Expand Up @@ -192,13 +193,13 @@ public final void compute2() {
Timer t_extract = new Timer();
// Build data adapter for this node.
DataAdapter dapt = DABuilder.create(this).build(_keys);
Utils.pln("[RF] Data adapter built in " + t_extract );
L.info(this,Sys.RANDF,"Data adapter built in " + t_extract );
// Prepare data and compute missing parameters.
Data t = Data.make(dapt);
_numSplitFeatures = howManySplitFeatures(t);
int ntrees = howManyTrees();

Utils.pln("[RF] Building "+ntrees+" trees");
L.info(this,Sys.RANDF,"Building "+ntrees+" trees");
RandomForest.build(this, t, ntrees, _depth, 0.0, StatType.values()[_stat],_parallel,_numSplitFeatures);
// Wait for the running jobs
tryComplete();
Expand Down Expand Up @@ -290,7 +291,7 @@ private void extractMinorities(ValueArray ary, int[] strataSamples) {

for(int i : nodesIdxs) {
if( _gHist[i] < (int)(_strataSamples[i]/_sample) )
Utils.pln("There is not enough samples of class " + i + ".");
L.info(this,Sys.RANDF,"There is not enough samples of class " + i + ".");
}
// Decide which classes need to be extracted
SortedSet<Integer> uClasses = new TreeSet<Integer>();
Expand Down Expand Up @@ -330,6 +331,6 @@ static void dumpRFParams(
_.sample = (int)(sample * 100);
_.file = "";

Utils.pln("Web arguments: " + _ + " key "+ary._key);
L.info(Sys.RANDF,"Web arguments: " + _ + " key "+ary._key);
}
}
7 changes: 4 additions & 3 deletions src/main/java/hex/rf/DataAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import water.MemoryManager;
import water.ValueArray;
import water.util.Utils;
import water.util.*;
import water.util.L.Tag.Sys;

/**A DataAdapter maintains an encoding of the original data. Every raw value (of type float)
* is represented by a short value. When the number of unique raw value is larger that binLimit,
Expand Down Expand Up @@ -151,7 +152,7 @@ void shrink() {
// to many NaNs in the column => ignore it
ignored = true;
raw = null;
Utils.pln("[RF] Ignore column: " + this);
L.info(this,Sys.RANDF,"Ignore column: " + this);
return;
}
int n = vs.length - ndups - nans;
Expand Down Expand Up @@ -190,7 +191,7 @@ void shrink() {
else binned[i] = (short) (-idx - 1); // this occurs when we are looking for a binned value, we return the smaller value in the array.
assert binned[i] < binned2raw.length;
}
if( n > binLimit ) Utils.pln(this+" this column's arity was cut from "+n+" to "+smax);
if( n > binLimit ) L.info(this,Sys.RANDF,this+" this column's arity was cut from "+n+" to "+smax);
raw = null; // GCced
}

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/hex/rf/RandomForest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public static void build(
int numSplitFeatures) {
Timer t_alltrees = new Timer();
Tree[] trees = new Tree[ntrees];
Utils.pln("[RF] number of split features: "+ drf.numSplitFeatures());
Utils.pln("[RF] starting RF computation with "+ data.rows()+" rows ");
L.info(Sys.RANDF,"Number of split features: "+ drf.numSplitFeatures());
L.info(Sys.RANDF,"Starting RF computation with "+ data.rows()+" rows ");

Random rnd = Utils.getRNG(data.seed() + ROOT_SEED_ADD);
Sampling sampler = createSampler(drf);
Expand All @@ -47,7 +47,7 @@ public static void build(
if (!parallelTrees) DRemoteTask.invokeAll(new Tree[]{trees[i]});
}
if(parallelTrees)DRemoteTask.invokeAll(trees);
Utils.pln("All trees ("+ntrees+") done in "+ t_alltrees);
L.info(Sys.RANDF,"All trees ("+ntrees+") done in "+ t_alltrees);
}

static Sampling createSampler(final DRF drf) {
Expand Down Expand Up @@ -131,7 +131,7 @@ else if(ARGS.rawKey != null) // data loaded in K/V, not parsed yet
DKV.remove(fk);
}
if(ARGS.ntrees == 0) {
Utils.pln("Nothing to do as ntrees == 0");
L.info(Sys.RANDF,"Nothing to do as ntrees == 0");
UDPRebooted.T.shutdown.broadcast();
return;
}
Expand Down Expand Up @@ -172,7 +172,7 @@ else if(ARGS.rawKey != null) // data loaded in K/V, not parsed yet
assert ARGS.ntrees >=0;
assert ARGS.binLimit > 0 && ARGS.binLimit <= Short.MAX_VALUE;

Utils.pln("[RF] Arguments used:\n"+ARGS.toString());
L.info(Sys.RANDF,"Arguments used:\n"+ARGS.toString());
final Key modelKey = Key.make("model");
DRFFuture drfResult = DRF.execute(modelKey,
cols,
Expand All @@ -192,13 +192,13 @@ else if(ARGS.rawKey != null) // data loaded in K/V, not parsed yet
ARGS.exclusive);
DRF drf = drfResult.get(); // block on all nodes!
RFModel model = UKV.get(modelKey);
Utils.pln("[RF] Random forest finished in "+ drf._t_main);
L.info(Sys.RANDF,"Random forest finished in "+ drf._t_main);

Timer t_valid = new Timer();
// Get training key.
Key valKey = drf.aryKey();
if(ARGS.outOfBagError && !ARGS.stratify){
Utils.pln("[RF] Computing out of bag error");
L.info(Sys.RANDF,"Computing out of bag error");
Confusion.make( model, valKey, classcol, null, true).report();
}
// Run validation.
Expand All @@ -212,7 +212,7 @@ else if(ARGS.rawKey != null) // data loaded in K/V, not parsed yet
Confusion.make( model, valKey, classcol, null, false).report();
}

Utils.pln("[RF] Validation done in: " + t_valid);
L.info(Sys.RANDF,"Validation done in: " + t_valid);
UDPRebooted.T.shutdown.broadcast();
}
}
6 changes: 4 additions & 2 deletions src/main/java/hex/rf/Tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import jsr166y.RecursiveTask;
import water.*;
import water.Timer;
import water.util.L;
import water.util.Utils;
import water.util.L.Tag.Sys;

public class Tree extends CountedCompleter {
static public enum StatType { ENTROPY, GINI };
Expand Down Expand Up @@ -113,14 +115,14 @@ public void compute() {
? new LeafNode(_data.unmapClass(spl._split), d.rows())
: new FJBuild (spl, d, 0, _seed).compute();

if (_verbose > 1) Utils.pln(computeStatistics().toString());
if (_verbose > 1) L.info(this,Sys.RANDF,computeStatistics().toString());
_stats = null; // GC

// Atomically improve the Model as well
appendKey(_job.dest(),toKey());
StringBuilder sb = new StringBuilder("[RF] Tree : ").append(_data_id+1);
sb.append(" d=").append(_tree.depth()).append(" leaves=").append(_tree.leaves()).append(" done in ").append(timer).append('\n');
Utils.pln(_tree.toString(sb, _verbose > 0 ? Integer.MAX_VALUE : 200).toString());
L.info(this,Sys.RANDF,_tree.toString(sb, _verbose > 0 ? Integer.MAX_VALUE : 200).toString());
}
// Wait for completation
tryComplete();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/water/util/L.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract public class L {
public static interface Tag {
/** Which subsystem of h2o? */
public static enum Sys implements Tag {
RANDF, GENLM, KMEAN, PARSE, STORE, WATER, HDFS_, HTTPD, CLEANR;
RANDF, GENLM, KMEAN, PARSE, STORE, WATER, HDFS_, HTTPD, CLEANR, CONFM;
}

/** What kind of message? */
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/water/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public static int sum(int[] from) {
return result;
}

public static void pln(String s) { System.out.println(s); }

public static String sampleToString(int[] val, int max) {
if (val == null || val.length < max) return Arrays.toString(val);

Expand Down
4 changes: 3 additions & 1 deletion src/test/java/hex/rf/RFRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import java.util.regex.Pattern;
import water.Arguments;
import water.TestUtil;
import water.util.L;
import water.util.Utils;
import water.util.L.Tag.Sys;

/** Launch RF in a new vm and records results.
*/
Expand Down Expand Up @@ -104,7 +106,7 @@ static class RFProcess extends Thread {

/* Creates RFPRocess and spawns new process. */
RFProcess(String cmd) throws Exception {
Utils.pln("'"+JAVA+" "+cmd+"'");
L.info(this,Sys.RANDF,"'"+JAVA+" "+cmd+"'");
List<String> c = new ArrayList<String>();
c.add(JAVA); for(String s : cmd.split(" ")) { s = s.trim(); if (s.length()>0) c.add(s); }
ProcessBuilder bldr = new ProcessBuilder(c);
Expand Down

0 comments on commit e42da6d

Please sign in to comment.