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

Store Chow-Liu structure in lists while it is being built #648

Merged
merged 1 commit into from
Nov 17, 2019

Conversation

alexhenrie
Copy link
Contributor

This decreases the time it takes to train a Chow-Liu net by about 5%. (Tuples, being immutable, are expensive to manipulate.)

Test program:

import numpy as np
from neurtu import delayed, Benchmark
from pomegranate import BayesianNetwork
from random import random

X = np.round(np.random.rand(10000, 100))
train = delayed(BayesianNetwork)().from_samples(X, algorithm='chow-liu')

print(Benchmark(wall_time=True, cpu_time=True, repeat=3)(train))

Before:

      wall_time  cpu_time                                                                                                     
mean   9.900260  9.883265
max    9.965771  9.914445
std    0.073636  0.037711

After:

      wall_time  cpu_time                                                                                                     
mean   9.445535  9.361896
max    9.481115  9.454669
std    0.052243  0.080365

@jmschrei
Copy link
Owner

Good catch, thanks!

@jmschrei jmschrei merged commit 2d34149 into jmschrei:master Nov 17, 2019
mareksmid-lucid pushed a commit to mareksmid-lucid/pomegranate that referenced this pull request Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants