or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

configuration.mdcore-analysis.mdindex.mdreport-display.md

report-display.mddocs/

0

# Report Generation and Display

1

2

Methods for rendering and outputting analysis reports in various formats. DataframeReport objects provide multiple output options including HTML files, notebook embedding, and experiment tracking integration.

3

4

## Capabilities

5

6

### HTML Report Generation

7

8

Generates self-contained HTML reports that can be saved to disk and viewed in web browsers. Provides full interactivity and high-quality visualizations optimized for desktop viewing.

9

10

```python { .api }

11

def show_html(self,

12

filepath: str = 'SWEETVIZ_REPORT.html',

13

open_browser: bool = True,

14

layout: str = 'widescreen',

15

scale: float = None) -> None:

16

"""

17

Generate and save an HTML report to disk.

18

19

Parameters:

20

- filepath: Path where HTML file will be saved

21

- open_browser: Whether to automatically open the report in default browser

22

- layout: Report layout ('widescreen' or 'vertical')

23

- scale: Scaling factor for report size (e.g., 0.8 for 80% size)

24

"""

25

```

26

27

#### Usage Examples

28

29

```python

30

import sweetviz as sv

31

32

# Create report

33

df = pd.read_csv('data.csv')

34

report = sv.analyze(df)

35

36

# Basic HTML output

37

report.show_html() # Saves to 'SWEETVIZ_REPORT.html'

38

39

# Custom filename and path

40

report.show_html('analysis/my_report.html')

41

42

# Vertical layout for narrow screens

43

report.show_html(layout='vertical')

44

45

# Scaled down for smaller displays

46

report.show_html(scale=0.8)

47

48

# Don't auto-open browser (useful in scripts)

49

report.show_html(open_browser=False)

50

51

# Combined options

52

report.show_html(

53

filepath='reports/analysis_2024.html',

54

layout='vertical',

55

scale=0.9,

56

open_browser=False

57

)

58

```

59

60

### Notebook Integration

61

62

Embeds reports directly in Jupyter notebooks and similar environments using iframe elements. Provides interactive viewing without leaving the notebook interface.

63

64

```python { .api }

65

def show_notebook(self,

66

w: Union[str, int] = None,

67

h: Union[str, int] = None,

68

scale: float = None,

69

layout: str = None,

70

filepath: str = None,

71

file_layout: str = None,

72

file_scale: float = None) -> None:

73

"""

74

Display report inline in Jupyter notebooks.

75

76

Parameters:

77

- w: Width of display window (percentage string like "100%" or pixels)

78

- h: Height of display window (pixels or "Full" for full height)

79

- scale: Scaling factor for embedded report

80

- layout: Report layout ('widescreen' or 'vertical')

81

- filepath: Optional path to also save HTML file

82

- file_layout: Layout for optional file output

83

- file_scale: Scale for optional file output

84

"""

85

```

86

87

#### Usage Examples

88

89

```python

90

# In Jupyter notebook

91

import sweetviz as sv

92

import pandas as pd

93

94

df = pd.read_csv('data.csv')

95

report = sv.analyze(df)

96

97

# Basic notebook display

98

report.show_notebook()

99

100

# Custom dimensions

101

report.show_notebook(w="100%", h=800)

102

103

# Vertical layout for narrow cells

104

report.show_notebook(layout='vertical', scale=0.8)

105

106

# Full height display

107

report.show_notebook(h="Full", w="100%")

108

109

# Display in notebook AND save file

110

report.show_notebook(

111

w="100%",

112

h=700,

113

filepath='backup_report.html'

114

)

115

116

# Different layouts for display vs file

117

report.show_notebook(

118

layout='vertical', # For notebook display

119

filepath='report.html',

120

file_layout='widescreen', # For saved file

121

file_scale=1.0

122

)

123

```

124

125

### Experiment Tracking Integration

126

127

Integrates with Comet.ml for experiment tracking and collaboration. Automatically logs reports when Comet.ml environment is configured, and provides explicit logging methods.

128

129

```python { .api }

130

def log_comet(self, experiment) -> None:

131

"""

132

Log report to a Comet.ml experiment.

133

134

Parameters:

135

- experiment: comet_ml.Experiment object

136

137

Raises:

138

Exception: If logging fails (prints error message)

139

"""

140

```

141

142

#### Usage Examples

143

144

```python

145

import sweetviz as sv

146

import comet_ml

147

148

# Initialize Comet experiment

149

experiment = comet_ml.Experiment(

150

api_key="your-api-key",

151

project_name="data-analysis"

152

)

153

154

# Create and log report

155

df = pd.read_csv('data.csv')

156

report = sv.analyze(df, target_feat='outcome')

157

158

# Explicit logging

159

report.log_comet(experiment)

160

161

# Automatic logging (when environment configured)

162

# Reports are automatically logged when using show_html() or show_notebook()

163

report.show_html() # Also logs to Comet if configured

164

```

165

166

## Layout Options

167

168

### Widescreen Layout

169

- **Best for**: Desktop displays, detailed analysis

170

- **Features**: Side-by-side detail panels, hover interactions

171

- **Default for**: HTML reports

172

173

### Vertical Layout

174

- **Best for**: Narrow screens, mobile devices, notebook cells

175

- **Features**: Stacked panels, click to expand details

176

- **Default for**: Notebook displays

177

178

## Configuration Defaults

179

180

Reports can use custom default settings via configuration files:

181

182

```python

183

# Override default settings

184

sv.config_parser.read("custom_config.ini")

185

186

# Example INI content:

187

# [Output_Defaults]

188

# html_layout = vertical

189

# html_scale = 0.9

190

# notebook_layout = widescreen

191

# notebook_scale = 0.8

192

# notebook_width = 100%

193

# notebook_height = 700

194

```

195

196

## Display Parameters

197

198

### Width and Height (Notebook)

199

- **Percentage**: `w="100%"` - Relative to container

200

- **Pixels**: `w=800`, `h=600` - Absolute dimensions

201

- **Full Height**: `h="Full"` - Expands to content height

202

203

### Scale Parameter

204

- **Range**: Floating-point values (e.g., 0.5 to 2.0)

205

- **Default**: 1.0 (100% size)

206

- **Common values**: 0.8 (compact), 1.2 (larger)

207

208

### File Output

209

- All display methods can optionally save HTML files

210

- Use `filepath` parameter for concurrent display and save

211

- Use `file_layout` and `file_scale` for different file settings

212

213

## Error Handling

214

215

Display methods may encounter:

216

217

```python

218

# Handle file permission errors

219

try:

220

report.show_html('/protected/path/report.html')

221

except PermissionError:

222

report.show_html('report.html') # Save in current directory

223

224

# Handle invalid layout values

225

try:

226

report.show_html(layout='invalid')

227

except ValueError as e:

228

print(f"Layout error: {e}")

229

report.show_html(layout='widescreen') # Use valid layout

230

231

# Handle Comet logging issues

232

try:

233

report.log_comet(experiment)

234

except Exception as e:

235

print(f"Comet logging failed: {e}")

236

```

237

238

## Performance Considerations

239

240

- **Large Reports**: Use `scale` parameter to reduce memory usage

241

- **Notebook Memory**: Limit dimensions for large datasets

242

- **File Size**: HTML reports include all data and can be large

243

- **Browser Performance**: Very large reports may be slow to render