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

Performance Improvements #32

Merged
merged 4 commits into from
Apr 11, 2017
Merged

Conversation

cheerfulstoic
Copy link
Contributor

I was using the Bagging with a large amount of data and it was really slow. I've made some improvements (though it's still pretty slow ;).

The biggest improvement was pulling out the index = attributes.index(attribute) so that it didn't happen over and over again in each loop.

It also seemed like the fitness variable was being used, but I was only using the discrete. I'm happy to put that back if that's not true for continuous

Copy link
Owner

@igrigorik igrigorik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff -- thanks! A minor nitpick..

result[i] += 1
end.values.inject(0) do |sum, count|
percentage = count.to_f / length
sum + -percentage * Math.log2(percentage)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can simplify to sum - ...? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Fixed here and in another place in id3_tree.rb

@igrigorik
Copy link
Owner

👍

@igrigorik igrigorik merged commit 846448a into igrigorik:master Apr 11, 2017
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