eli5
explain_weights
Python
data science
machine learning

How can I print all eli5.explain_weights results without ellipsis?

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

Introduction

When eli5.explain_weights output shows ellipsis, the explanation itself is usually fine and the truncation is happening in the display layer. The fix is to ask ELI5 for enough rows and then render the result through a path that does not shorten long output, such as plain text, to_string, or a saved file.

Start From a Concrete Explanation Object

The first step is to confirm that the explanation object is being generated correctly. If that works, the problem is almost always about rendering rather than model interpretation.

python
1from sklearn.datasets import load_breast_cancer
2from sklearn.linear_model import LogisticRegression
3import eli5
4
5X, y = load_breast_cancer(return_X_y=True)
6feature_names = [f"f{i}" for i in range(X.shape[1])]
7
8model = LogisticRegression(max_iter=2000)
9model.fit(X, y)
10
11exp = eli5.explain_weights(model, feature_names=feature_names, top=100)
12print(type(exp).__name__)

If exp is created successfully, then the issue is how you are inspecting it.

Use Plain Text Rendering First

Notebook rendering and rich repr output often introduce truncation. The most reliable first step is to render the explanation as plain text.

python
full_text = eli5.format_as_text(exp)
print(full_text)

If the terminal still makes the output hard to inspect, save it to a file instead of trusting the console width.

python
with open("eli5_weights.txt", "w", encoding="utf-8") as f:
    f.write(full_text)

This removes notebook display rules and terminal-width behavior from the equation.

Make Sure top Is Large Enough

Sometimes what looks like truncation is actually ELI5 returning only the top N items because the top parameter is too small. If you want all feature weights, make top at least as large as the feature count.

python
1exp_all = eli5.explain_weights(
2    model,
3    feature_names=feature_names,
4    top=len(feature_names),
5)
6
7print(eli5.format_as_text(exp_all))

Without this, some features never appear at all, which is a different issue than display ellipsis.

Use the DataFrame API for Full Tabular Control

If you want to inspect the explanation as a table, explain_weights_df is often easier to control than the default notebook output. Pair it with explicit pandas display settings.

python
1import pandas as pd
2
3pd.set_option("display.max_rows", None)
4pd.set_option("display.max_columns", None)
5pd.set_option("display.max_colwidth", None)
6pd.set_option("display.width", 240)
7
8weights_df = eli5.explain_weights_df(
9    model,
10    feature_names=feature_names,
11    top=len(feature_names),
12)
13
14print(weights_df.to_string(index=False))

to_string is important here because the plain print(weights_df) path may still be shortened by pandas display defaults.

Save Review Artifacts Instead of Relying on Interactive Output

For team reviews, CI jobs, or model-governance workflows, on-screen inspection is fragile. Save the full explanation as an artifact and optionally save a smaller summary view for quick reading.

python
1weights_df.to_csv("eli5_weights_full.csv", index=False)
2
3summary = (
4    weights_df.assign(abs_weight=weights_df["weight"].abs())
5    .sort_values("abs_weight", ascending=False)
6    [["feature", "weight", "abs_weight"]]
7    .head(25)
8)
9
10summary.to_csv("eli5_weights_top25.csv", index=False)
11print(summary.to_string(index=False))

That gives you both a complete record and a manageable high-signal summary.

HTML Can Be Better for Shared Review

ELI5 can also render HTML, which is often easier to share with teammates than raw notebook output.

python
1html = eli5.format_as_html(exp_all)
2
3with open("eli5_weights.html", "w", encoding="utf-8") as f:
4    f.write(html)

HTML output is especially useful when non-technical reviewers need a readable artifact but do not want to dig through notebook cells.

Common Pitfalls

The biggest mistake is confusing display ellipsis with missing model explanations. Another is forgetting that the top parameter may be hiding features before any rendering happens. Developers also rely too heavily on notebook display instead of saving plain-text or tabular artifacts that are easier to audit and compare later.

Summary

  • Ellipsis usually comes from the rendering layer, not from ELI5 failing to compute the explanation.
  • Render with eli5.format_as_text first when you want the full output.
  • Set top high enough to include all the features you expect.
  • Use explain_weights_df plus to_string and pandas display settings for full tables.
  • Save text, CSV, or HTML artifacts when the explanation needs to be reviewed outside the notebook.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

All Rights Reserved.