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

Add new learners (mostly regressors) #377

Merged
merged 29 commits into from
Oct 30, 2017
Merged

Conversation

desilinguist
Copy link
Member

@desilinguist desilinguist commented Oct 25, 2017

  1. Add the following new regressors:

    • BayesianRidge
    • DummyRegressor
    • HuberRegressors
    • Lars
    • MLPRegressor
    • RANSACRegressor
    • TheilSenRegressor
  2. Add the following new classifiers:

    • MLPClassifier
    • RidgeClassifier
  3. Add default parameter grids where appropriate for these new learners. Blank default parameter grids for learners that do not have any hyper-parameters that make sense to tune by default and the decision is better left to the user.

  4. Update documentation.

    • Add documentation for new learners.
    • Fix incomplete documentation for previously existing learners.
    • Add a note about empty default parameter grids.
  5. Update tests.

    • Add tests for new learners.
    • Refactor some old tests for consistency and ease of debugging.

@desilinguist desilinguist self-assigned this Oct 25, 2017
@desilinguist desilinguist added this to the 1.5 milestone Oct 25, 2017
@coveralls
Copy link

coveralls commented Oct 25, 2017

Coverage Status

Coverage increased (+0.07%) to 91.994% when pulling dfca715 on feature/add-new-regressors into efa0a5b on master.

skll/learner.py Outdated
KNeighborsClassifier:
[{'n_neighbors': [1, 5, 10, 100],
'weights': ['uniform', 'distance']}],
KNeighborsRegressor:
[{'n_neighbors': [1, 5, 10, 100],
'weights': ['uniform', 'distance']}],
MLPClassifier:
[{}],
Copy link
Contributor

@Lguyogiro Lguyogiro Oct 26, 2017

Choose a reason for hiding this comment

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

I know searching over hidden_layer_sizes takes too long to search over by default, but what about the other parameters like activation, solver, learning_rate, etc?

Copy link
Member Author

@desilinguist desilinguist Oct 26, 2017

Choose a reason for hiding this comment

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

I didn't include the other parameters either because:

(a) Many of the hyper-parameters are conditionally dependent on each other. For example, learning_rate is only used when solver = sgd, learning_rate_init is only used when solver = sgd or adam, and early_stopping is only used when solver = sgd. So, it's very different from other learners in that sense and there isn't an easy way to put together a product over all the parameters in the grid that will all be valid together.

(b) Many of the hyper-parameters shouldn't just be blindly iterated over. For example, the lbfgs solver is not great when you have a lot of data but when you have a small amount of data, it's better but still quite slow. Whether or not to use early stopping interacts with whether you have sufficient data in the first place.

IMO, these decisions about which sets of hyper-parameters should be searched together depends on the experiment and the data and are best left to the user. However, if you have a suggestion for a default parameter grid that makes sense (without a lot of extra logic to deal with conditional dependence) then I am happy to try it out.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, an option could be to have sgd solver and a single hidden layer be the default for any MLP and then have a grid iterate over activation, learning_rate, and learning_rate_init. In that case, if you want to do something different, you will have to change the solver via fixed_parameters and then also specify your own set of parameters to search via param_grids. Thoughts? @Lguyogiro @aoifecahill @mulhod ?


# train an AdaBoostRegressor on the training data and evalute on the
# testing data
learner = Learner('MLPClassifier', model_kwargs={'solver': 'lbfgs'})
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this comment say "train an MLPClassifier on the training data and evaluate on the testing data" ?

Copy link
Contributor

@Lguyogiro Lguyogiro left a comment

Choose a reason for hiding this comment

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

Looks good to me. I'm looking forward to trying out some of these new learners.

- And also some default fixed parameters that seem a little more reasonable.
- Also filter out convergence warnings since we don't want those to clutter the test logs.
@coveralls
Copy link

coveralls commented Oct 26, 2017

Coverage Status

Coverage increased (+0.07%) to 92.003% when pulling 5102a96 on feature/add-new-regressors into efa0a5b on master.

@desilinguist
Copy link
Member Author

@aoifecahill @mulhod this is now ready for review. @Lguyogiro you can probably take another look since I added the MLP grid this time around.

from sklearn.linear_model.base import LinearModel
from sklearn.metrics import (accuracy_score,
confusion_matrix,
precision_recall_fscore_support,
SCORERS)
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we not need this any more?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was imported but never used in that file so I removed it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, makes sense, thanks!

@desilinguist desilinguist merged commit f2064eb into master Oct 30, 2017
@desilinguist desilinguist deleted the feature/add-new-regressors branch October 30, 2017 14:04
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.

None yet

5 participants