Skip to content

Fix dataset loading and off-by-one errors in Pima diabetes example - #254

Open
vaibhavc-coder wants to merge 3 commits into
mlpack:masterfrom
vaibhavc-coder:fix/pima-diabetes-loading-slicing
Open

vaibhavc-coder wants to merge 3 commits into
mlpack:masterfrom
vaibhavc-coder:fix/pima-diabetes-loading-slicing

Conversation

@vaibhavc-coder

Copy link
Copy Markdown

Fixes #253.

This PR adds a check for dataset loading failures so that the program exits gracefully if the dataset cannot be loaded.

It also fixes the slicing indices in two places where the program was displaying 11 samples instead of the intended 10.

The changes are limited to the fixes discussed in #253.

Thanks for the feedback!

@github-actions

Copy link
Copy Markdown

Binder 👈 Launch a binder notebook on branch vaibhavc-coder/ml-pack-examples/fix/pima-diabetes-loading-slicing

@rcurtin rcurtin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm surprised to have so many comments on a simple PR, but, we can significantly simplify the changes that you made here.

*/
#include <mlpack.hpp>
#include <sstream>
#include <iostream>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You don't need this, it is already included by mlpack.hpp.

{
std::cerr << "Failed to load the dataset." << std::endl;
return 1;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not just use Fatal in the call to Load()? Also, we should change from data::Load() to Load() since that changed in upstream mlpack recently. See https://www.mlpack.org/doc/user/load_save.html for the documentation.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the review! I switched to Load() with mlpack::Fatal and removed the redundant include and extra blank lines. I’ve pushed the updates to this PR.

//iterations, [> Number of optimization steps. <]
//"output.gif" [> Output file. <]);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't need to add an extra line here.

@rcurtin rcurtin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, I appreciate the fixes.

…tes.cpp

Co-authored-by: Ryan Curtin <ryan@ratml.org>
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.

Fix data loading and slicing in the Pima Indians Diabetes example

2 participants