split.cpp (1061B)
1 #include <iostream> 2 3 //split_lib = ctypes.CDLL('./cpp/libsplit.so') 4 //split_lib.split.restype = BestSplit 5 //split_lib.split.argtypes = [ 6 // ctypes.POINTER(ctypes.c_float), # together 7 // ctypes.c_float, # prop to train on 8 // ctypes.c_float, # prop to val on 9 // ctypes.POINTER(ctypes.c_int), # dims 10 //] 11 //bestSplit, ltGini, gtGini = split_lib.split(ctypes.POINTER(together), self.propDimsTrain, self.propValSplits, ctypes.POINTER(dims)) 12 // 13 // 14 // 15 //class BestSplit(ctypes.Structure): 16 // _fields_ = [("index", ctypes.c_int), 17 // ("splitVal", ctypes.c_int), 18 // ("ltGini", ctypes.c_float), 19 // ("gtGini", ctypes.c_float) 20 // ] 21 // 22 // 23 24 25 extern "C" { 26 struct BestSplit{ 27 int index; 28 float splitVal; 29 float ltGini; 30 float gtGini; 31 }; 32 33 34 BestSplit split(float* together, float propToTrainOn, float propToValWith, int* dims){ 35 36 printf("%f\n", together[0]); 37 printf("%f\n", propToTrainOn); 38 printf("%f\n", propToValWith); 39 printf("%i\n", dims[0]); 40 41 return BestSplit(); 42 43 } 44 }