finish mushroom

This commit is contained in:
tqchen
2014-02-24 23:06:57 -08:00
parent 9d6ef11eb5
commit c4949c0937
8 changed files with 88 additions and 3 deletions

21
demo/mushroom/maptree.py Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/python
import sys
def loadnmap( fname ):
nmap = {}
for l in open(fname):
arr = l.split()
nmap[int(arr[0])] = arr[1].strip()
return nmap
fo = sys.stdout
nmap = loadnmap( 'featname.txt' )
for l in open( 'dump.txt'):
idx = l.find('[f')
if idx == -1:
fo.write(l)
else:
fid = int( l[idx+2:len(l)].split('>')[0])
rl = l[0:idx]+'['+nmap[fid]+']' + l.split()[1].strip()+'\n'
fo.write(rl)

View File

@@ -2,3 +2,5 @@
python mapfeat.py
python mknfold.py agaricus.txt 1
../../xgboost mushroom.conf
../../xgboost mushroom.conf task=dump model_in=0003.model
python maptree.py