Skip to content

Commit

Permalink
Merge pull request #6 from tqchen/dev
Browse files Browse the repository at this point in the history
Fix the bug in MAC
  • Loading branch information
tqchen committed May 17, 2014
2 parents e3eca30 + 5275b12 commit b58471c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion python/Makefile
@@ -1,6 +1,6 @@
export CC = gcc
export CXX = g++
export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -fopenmp
export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -fopenmp

# specify tensor path
SLIB = libxgboostpy.so
Expand Down
9 changes: 5 additions & 4 deletions python/xgboost.py
Expand Up @@ -36,7 +36,8 @@ def ctypes2numpy( cptr, length ):
class DMatrix:
# constructor
def __init__(self, data=None, label=None, missing=0.0, weight = None):
self.handle = xglib.XGDMatrixCreate()
# force into void_p, mac need to pass things in as void_p
self.handle = ctypes.c_void_p( xglib.XGDMatrixCreate() )
if data == None:
return
if isinstance(data,str):
Expand Down Expand Up @@ -118,8 +119,8 @@ def __init__(self, params={}, cache=[]):
""" constructor, param: """
for d in cache:
assert isinstance(d,DMatrix)
dmats = ( ctypes.c_void_p * len(cache) )(*[ ctypes.c_void_p(d.handle) for d in cache])
self.handle = xglib.XGBoosterCreate( dmats, len(cache) )
dmats = ( ctypes.c_void_p * len(cache) )(*[ d.handle for d in cache])
self.handle = ctypes.c_void_p( xglib.XGBoosterCreate( dmats, len(cache) ) )
self.set_param( params )
def __del__(self):
xglib.XGBoosterFree(self.handle)
Expand Down Expand Up @@ -154,7 +155,7 @@ def eval_set(self, evals, it = 0):
for d in evals:
assert isinstance(d[0], DMatrix)
assert isinstance(d[1], str)
dmats = ( ctypes.c_void_p * len(evals) )(*[ ctypes.c_void_p(d[0].handle) for d in evals])
dmats = ( ctypes.c_void_p * len(evals) )(*[ d[0].handle for d in evals])
evnames = ( ctypes.c_char_p * len(evals) )(*[ ctypes.c_char_p(d[1]) for d in evals])
xglib.XGBoosterEvalOneIter( self.handle, it, dmats, evnames, len(evals) )
def eval(self, mat, name = 'eval', it = 0 ):
Expand Down

0 comments on commit b58471c

Please sign in to comment.