Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

321
Views
What does it mean for an attribute name to end in an underscore?

Similar question: What's the advantage of a trailing underscore in Python naming?. This addresses advantages/disadvantages, whereas this addresses the reasoning behind doing it, both broadly and specifically to sklearn.

I am looking through the sklearn documentation, and I noticed that the sklearn.model_selection.GridSearchCV attributes all end in underscore. For example:

  • cv_results_
  • best_params_
  • best_score_

Why is this? What does the underscore do? Please be as broad as possible in your answer (i.e. don't just refer to sklearn's GridSearchCV.

I'm assuming this isn't just an sklearn thing, and I have no idea what the appropriate tag is for this so I'm tagging sklearn. Please correct the tags (or me!).

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

For sklearn, there is a specific interpretation. Check the sklearn developer guideline, which has a note on this. The convention is used for attributes of estimators that have a meaningful value after fit() was called.

These are then used to for instance check if the estimator was fitted, see for instance here:

class LinearModel(six.with_metaclass(ABCMeta, BaseEstimator)):
    """Base class for Linear Models"""

    [...]

    def _decision_function(self, X):
        check_is_fitted(self, "coef_")

   [...]
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!