question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

check_estimator is stricter than what is stated in the Estimator API doc

See original GitHub issue

This issue was raised in a discussion regarding the LightGBM scikit-learn compatible estimators: https://github.com/microsoft/LightGBM/issues/2628#issuecomment-574369813

The problem is that check_estimator complains about private attributes set in the __init__ of a scikit-learn estimator while our documentation just state the following (while not explicitly prohibiting setting private attributes in __init__):

The arguments accepted by __init__ should all be keyword arguments with a default value. In other words, a user should be able to instantiate an estimator without passing any arguments to it. The arguments should all correspond to hyperparameters describing the model or the optimisation problem the estimator tries to solve. These initial arguments (or parameters) are always remembered by the estimator. Also note that they should not be documented under the “Attributes” section, but rather under the “Parameters” section for that estimator.

In addition, every keyword argument accepted by __init__ should correspond to an attribute on the instance. Scikit-learn relies on this to find the relevant attributes to set on an estimator when doing model selection.

from: https://scikit-learn.org/0.22/developers/develop.html#instantiation

The strict check is defined in sklearn.utils.estimator_checks.check_no_attributes_set_in_init.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:29 (21 by maintainers)

github_iconTop GitHub Comments

5reactions
ogriselcommented, Jan 27, 2020

I think that setting private attributes in __init__ is fine as long as the public attributes defined as constructor params (that is the model hyperparametrs) can be get/set at any moment either via getattr / setattr or via get_params / set_params and that subsequent calls to the fit / predict / transform automatically take those changes into account.

3reactions
StrikerRUScommented, Feb 22, 2020

Hello guys!

Is there any progress on this? Will it be possible to resolve this issue by next release?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tax Withholding Estimator | Internal Revenue Service
Use this tool to estimate the federal income tax you want your employer to withhold from your paycheck. This is tax withholding.
Read more >
Salary Paycheck Calculator – Calculate Net Income - ADP
1. Determine taxable income by deducting any pre-tax contributions to benefits 2. Withhold all applicable taxes (federal, state and local) 3. Deduct any...
Read more >
California Hourly Paycheck and Payroll Calculator - Gusto
Use Gusto's hourly paycheck calculator to determine withholdings and calculate take-home pay for your hourly employees in California.
Read more >
sklearn.feature_extraction.text.CountVectorizer
By default, it is 'strict', meaning that a UnicodeDecodeError will be raised. ... that have a document frequency strictly higher than the given...
Read more >
Middle Class Tax Refund Estimator | FTB.ca.gov
Filed your 2020 tax return by October 15, 2021; Meet the California adjusted gross income (CA AGI) limits described on the Middle Class...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found