Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault on gaussian_naive_bayes.apply() with SparseRealFeatures #351

Closed
policecar opened this issue Jan 9, 2012 · 10 comments
Closed

segfault on gaussian_naive_bayes.apply() with SparseRealFeatures #351

policecar opened this issue Jan 9, 2012 · 10 comments
Assignees

Comments

@policecar
Copy link

No description provided.

@ghost ghost assigned lisitsyn Jan 9, 2012
@lisitsyn
Copy link
Member

lisitsyn commented Jan 9, 2012

thanks, scheduled to fix ;)

@lisitsyn
Copy link
Member

lisitsyn commented Jan 9, 2012

policecar,

could you please pull latest sources and check if it is failing still? I didn't managed to reproduce your issue, but fixed some errors that were in the classifier code.

Thanks.

@policecar
Copy link
Author

i pulled, compiled, and ran the code again – no more segfault : )
but this time i get

Python(16510) malloc: *** error for object 0x100f8d208: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug

@lisitsyn
Copy link
Member

lisitsyn commented Jan 9, 2012

Could you please attach code reproducing it?

@policecar
Copy link
Author

def gaussiannaivebayes_sparse():

import numpy as nu
from shogun.Features import SparseRealFeatures, Labels
from shogun.Classifier import GaussianNaiveBayes

data = nu.load('./tmp/feats.npz')
feats_train = data['feats_train'].item()
feats_test = data['feats_test'].item()
labels = data['labels']

feats_train = SparseRealFeatures( feats_train.astype(nu.float64).transpose() )
labels = Labels( nu.array( labels[0], dtype=nu.float64 ))
feats_test = SparseRealFeatures( feats_test.astype(nu.float64).transpose() )

gnb=GaussianNaiveBayes( feats_train, labels )
gnb_train = gnb.train()
output=gnb.apply( feats_test ).get_labels()
return gnb, gnb_train, output

if __name__=='__main__':
print 'GaussianNaiveBayes'
gaussiannaivebayes_sparse()

there's still an error in my test data but the malloc_error occurs equally if i apply naive bayes to the training data

@policecar
Copy link
Author

looks like my current code runs without throwing any errors...
thanks for the quick fix the other day!

@lisitsyn
Copy link
Member

I'm sorry I didn't react on last message. Anyway, I'll close this issue after one more fix as it is working now

@policecar
Copy link
Author

one more thing, how about computing the conditional probabilities using the log which would yield a sum instead of the product of all conditional probabilities per feature vector, and thereby avoiding issues with underflow ?

@policecar
Copy link
Author

hehe, i just noticed that's what you just did. thanks plenty!

@lisitsyn
Copy link
Member

Well that's exactly what I did in a14a48a :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants