transpose dimensions of X in BayesNetwork

This commit is contained in:
2023-07-08 01:13:29 +02:00
parent 8a9c86a22d
commit 260997c872
2 changed files with 879 additions and 332 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -25,15 +25,19 @@ cdef class BayesNetwork:
def __dealloc__(self): def __dealloc__(self):
del self.thisptr del self.thisptr
def fit(self, X, y, features, className): def fit(self, X, y, features, className):
X_ = [X[:, i] for i in range(X.shape[1])]
features_bytes = [x.encode() for x in features] features_bytes = [x.encode() for x in features]
self.thisptr.fit(X, y, features_bytes, className.encode()) self.thisptr.fit(X_, y, features_bytes, className.encode())
return self return self
def predict(self, X): def predict(self, X):
return self.thisptr.predict(X) X_ = [X[:, i] for i in range(X.shape[1])]
return self.thisptr.predict(X_)
def predict_proba(self, X): def predict_proba(self, X):
return self.thisptr.predict_proba(X) X_ = [X[:, i] for i in range(X.shape[1])]
return self.thisptr.predict_proba(X_)
def score(self, X, y): def score(self, X, y):
return self.thisptr.score(X, y) X_ = [X[:, i] for i in range(X.shape[1])]
return self.thisptr.score(X_, y)
def addNode(self, name, states): def addNode(self, name, states):
self.thisptr.addNode(str.encode(name), states) self.thisptr.addNode(str.encode(name), states)
def addEdge(self, source, destination): def addEdge(self, source, destination):