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

Fix #225: Improve Display for naive_bayes #241

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

m7142yosuke
Copy link

@m7142yosuke m7142yosuke commented Nov 16, 2022

Fixes #225

Checklist

  • My branch is up-to-date with development branch.
  • Everything works and tested on latest stable Rust.
  • Coverage and Linting have been applied

Current behaviour

Currently println!("{}", &gnb) prints:

GaussianNB:
inner: BaseNaiveBayes { distribution: GaussianNBDistribution { class_labels: [0, 1, 2], class_count: [50, 50, 50], class_priors: [0.3333333333333333, 0.3333333333333333, 0.3333333333333333], var: [[0.12176398698426993, 0.1422760001411465, 0.0295040034446723, 0.01126400058841702], [0.26110400788880384, 0.09650000076294418, 0.21639999752045114, 0.03832399889564586], [0.3962559386291673, 0.10192399745559833, 0.2984959836425922, 0.07392400431251556]], theta: [[5.006000003814697, 3.41800000667572, 1.4639999961853027, 0.24400000482797624], [5.935999975204468, 2.770000009536743, 4.259999980926514, 1.3259999918937684], [6.588000001907349, 2.9739999914169313, 5.551999988555909, 2.0259999775886537]] }, _phantom_tx: PhantomData, _phantom_ty: PhantomData, _phantom_x: PhantomData, _phantom_y: PhantomData }

New expected behaviour

GaussianNB:
 inner: BaseNaiveBayes: {
 distribution: GaussianNBDistribution: {
    class_labels: [1, 2],
    class_count: [3, 3],
    class_priors: [0.3, 0.7],
    var: [[0.666666666666667, 0.22222222222222232], [0.666666666666667, 0.22222222222222232]],
    theta: [[-2.0, -1.3333333333333333], [2.0, 1.3333333333333333]]
}}

Change logs

@m7142yosuke
Copy link
Author

I'm just starting to learn rust, so I'm sorry if I'm wrong.
I implemented it differently from the format presented in #225 . Is it better to implement just like the example?

@Mec-iS
Copy link
Collaborator

Mec-iS commented Nov 16, 2022

thanks a lot!

could you try to do the same for other structures that implement Display? Could you find a way to avoid printing the _phantom fields?

@m7142yosuke m7142yosuke changed the title Add flag to pretty-print Fix #225: J Nov 22, 2022
@m7142yosuke m7142yosuke changed the title Fix #225: J Fix #225: Improve Display for naive_bayes Nov 22, 2022
@m7142yosuke
Copy link
Author

@Mec-iS
I tried. Can you review it?

@Mec-iS
Copy link
Collaborator

Mec-iS commented Nov 22, 2022

Good job.

This could be merged but it will fix only the Gaussian, what about the other distributions? Please double check that all of them return well formatted output.

EDIT: Also please test your branch with smartcore-jupyter by using:
:dep smartcore = {git = "https://github.com/m7142yosuke/smartcore.git", , branch = "feature/improve-display-for-naive-bayes", features = ["datasets"]}
at the top of the notebooks. These changes are meant mostly for Jupyter pretty printing so it would be good to have a look how the branch works in the notebooks. For example see this.

Copy link
Collaborator

@Mec-iS Mec-iS left a comment

Choose a reason for hiding this comment

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

please see comments for desirable changes

@codecov-commenter
Copy link

Codecov Report

Merging #241 (19e5115) into development (d15ea43) will increase coverage by 0.07%.
The diff coverage is 81.81%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@               Coverage Diff               @@
##           development     #241      +/-   ##
===============================================
+ Coverage        44.50%   44.58%   +0.07%     
===============================================
  Files               85       85              
  Lines             7226     7234       +8     
===============================================
+ Hits              3216     3225       +9     
+ Misses            4010     4009       -1     
Impacted Files Coverage Δ
src/naive_bayes/gaussian.rs 42.30% <81.81%> (+6.89%) ⬆️

... and 5 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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.

Improve Display for naive_bayes
3 participants