diff --git a/wisard.py b/wisard.py index 5f6d969..45344af 100644 --- a/wisard.py +++ b/wisard.py @@ -28,8 +28,8 @@ def printProgressBar(label,time,etime,basecolor, cursorcolor, linecnt,progress,s str += color.END + cursorcolor + u'\u2588' + color.END + basecolor else: str += u'\u2591' - str += color.END + '| ' + "{:>3}".format(int(progress * 100.0)) + ' % ' + color.YELLOWBLACK + ' ' + etime + ' ' + color.WHITEBLACK + time + ' ' + color.END - sys.stdout.write("\r%s" % str.encode('utf-8')) + str += color.END + '| ' + "{:>3}".format(int(progress * 100.0)) + ' % ' + color.BLUE + ' ' + etime + ' ' + color.BLUE + time + ' ' + color.END + sys.stdout.write("\r%s" % str) sys.stdout.flush() return progress @@ -42,21 +42,21 @@ def compTime(deltatime,progress): tme = "{:0>2}:{:0>2}:{:02.0f}".format(int(hourse),int(minutese),secondse) return tm,tme -def decide_onebyone((clf,data)): +def decide_onebyone(clf,data): return [clf.wiznet_[cl].Classify(data, clf.ranges_, clf.offsets_, clf.notics) for cl in clf.classes_] -def decide_onebyone_noscale((clf,data)): +def decide_onebyone_noscale(clf,data): return [clf.wiznet_[cl].ClassifyNoScale(data, clf.notics) for cl in clf.classes_] -def train_onebyone((clf,X,y)): +def train_onebyone(clf,X,y): for i,data in enumerate(X): clf.wiznet_[clf.classes_[y[i]]].Train(data,clf.ranges_,clf.offsets_, clf.notics) -def train_onebyone_noscale((clf,X,y)): +def train_onebyone_noscale(clf,X,y): for i,data in enumerate(X): clf.wiznet_[clf.classes_[y[i]]].TrainNoScale(data, self.notics) -def decide_onebyone_b((clf,data)): +def decide_onebyone_b(clf,data): b = clf.b_def confidence = 0.0 res_disc_list = [clf.wiznet_[cl].Response(data,clf.ranges_,clf.offsets_, clf.notics) for cl in clf.classes_] @@ -76,7 +76,7 @@ def decide_onebyone_b((clf,data)): result = np.array(result_partial)/result_sum return result -def decide_onebyone_b_noscale((clf,data)): +def decide_onebyone_b_noscale(clf,data): b = clf.b_def confidence = 0.0 res_disc_list = [clf.wiznet_[cl].ResponseNoScale(data, clf.notics) for cl in clf.classes_] @@ -402,7 +402,7 @@ def decision_function_par_b_noscale(self,X): # parallel version (no debug wit def decision_function_seq_b(self,X): # sequential version (no debug with bleaching) D = np.empty(shape=[0, len(self.classes_)]) for data in X: - res = decide_onebyone_b((self,data)) # classify with bleaching (Work in progress) + res = decide_onebyone_b(self,data) # classify with bleaching (Work in progress) D = np.append(D, [res],axis=0) return D @@ -436,7 +436,7 @@ def decision_function_seq_b_debug(self,X): self.starttm_ = time.time() self.progress_ = 0.01 for data in X: - res = decide_onebyone_b((self,data)) # classify with bleaching (Work in progress) + res = decide_onebyone_b(self,data) # classify with bleaching (Work in progress) D = np.append(D, [res],axis=0) cnt += 1 tm,tme = compTime(time.time()-self.starttm_,self.progress_) @@ -450,7 +450,7 @@ def decision_function_seq_b_debug_noscale(self,X): self.starttm_ = time.time() self.progress_ = 0.01 for data in X: - res = decide_onebyone_b_noscale((self,data)) # classify with bleaching (Work in progress) + res = decide_onebyone_b_noscale(self,data) # classify with bleaching (Work in progress) D = np.append(D, [res],axis=0) cnt += 1 tm,tme = compTime(time.time()-self.starttm_,self.progress_) diff --git a/wisard_wrapper.pyx b/wisard_wrapper.pyx index caa2b30..90b4a5e 100644 --- a/wisard_wrapper.pyx +++ b/wisard_wrapper.pyx @@ -32,7 +32,7 @@ cdef extern from "Discriminator.h" namespace "wnn": cdef class PyDiscriminator: cdef Discriminator *thisptr # hold a C++ instance which we're wrapping def __cinit__(self, bits, size, maptype="random"): - self.thisptr = new Discriminator(bits, size, maptype) + self.thisptr = new Discriminator(bits, size, maptype.encode('utf-8')) def __dealloc__(self): del self.thisptr def getNBits(self):