Closed schmidj closed 9 months ago
Can you demonstrate this issue with an example? This will help me debug the issue.
I created a small example and does not result in an issue:
# Load example dataset
Xy_train = bn.import_example('titanic')
Xy_train.drop(labels='Cabin', axis=1, inplace=True)
Xy_train = Xy_train.dropna(axis=0)
tarvar='Survived'
model = bn.structure_learning.fit(Xy_train,
methodtype='tan',
class_node = 'Survived')
model = bn.parameter_learning.fit(model,
Xy_train,
methodtype='bayes',
scoretype='bdeu')
y_train_pred = bn.predict(model, Xy_train, variables = tarvar, verbose=4)
please reopen this issue when the issue is still there.
Hi,
I was wondering why I get an indexerror when I want to predict a categorical (non-binary) variable. I created a post about the error message here. I eventually found one possible source for this error: In the function _get_prob() line 1549, instead of creating
allcomb = np.array(list(itertools.product([0, 1], repeat=len(query.variables))))
allcomb shoud rather beif (query.df == None): n = len(query.values) allcomb = np.linspace([0],[n-1],n) # array with number of values of target variable
else: allcomb = query.df.values[:,0:(len(query.df.values)-2)]
In this case, predictions are not limited to binary variables anymore. Am I right?