scikit-learn / scikit-learn/scikit-learn

Remove Hardcoded Thresholds in Repr

Open
#11,897 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

API module:base Needs Decision
Dominant language
Python
Stars
67.3k
Forks
27.4k
Avg merge
1d 15h
Merged PRs (30d)
58

Description

Description

Repr cuts off outputs when they are going to be longer than 500 characters.

While the python docs dont say it is a requirement, they do state "For many types, this function makes an attempt to return a string that would yield an object with the same value when passed to eval"

It would be nice to be able to do something similar to numpy, where we can set the threshold ourselves, so if desired repr can be used with eval to reconstruct an object. For reference, this is how np allows users to set it

np.set_printoptions(threshold=np.inf)
Steps/Code to Reproduce

Calling repr on any objects with a large number of params

Expected Results

Full output of below (without the ...)

Actual Results
Pipeline(memory=None,
     steps=[('minmaxscaler', MinMaxScaler(copy=True, feature_range=(0, 1))), ('selectfrommodel', SelectFromModel(estimator=LogisticRegression(C=100.0, class_weight=None, dual=False, fit_intercept=True,
          intercept_scaling=1, max_iter=100, multi_class='ovr', n_jobs=1,
          penalty='l2', rando...n_jobs=1,
            oob_score=False, random_state=None, verbose=0,
            warm_start=False))])

Note the ... after random

Versions

All

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the long estimator repr described in the issue and locate the repr implementation and its existing tests. Determine how a user-configurable output threshold should interact with truncated repr strings. Done means the threshold can be controlled without breaking normal repr behavior, with coverage for both truncated and full output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.