Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Automated Data Visualization with AutoViz in Python

Tech 1

Data visualization transforms raw numbers into meaningful insights. AutoViz is a Python library that automates this process, turning datasets into charts with a single line of code.

AutoViz analyzes the characteristics of your data and selects the most suitable visualization types. It supports CSV, Excel, and Pandas DataFrames, works without requiring complex configuration, and offers customization options.

Installation

pip install autoviz

Quick Example

The following example shows how to load a CSV file and generate visualizations automatically:

from autoviz.AutoViz_Class import AutoViz_Class
import pandas as pd

df = pd.read_csv("mystery_data.csv")
AV = AutoViz_Class()
table_AV = AV.AutoViz("mystery_data.csv")

Parameter Guide

The AutoViz method accepts several parameters to control its behavior:

  • filename: Path to your data file. Leave as an empty string ("") if you pass data via dfte.
  • sep: Delimiter used in the file (e.g., ',', ';', '\t').
  • depVar: Name of the target column you want to predict or analyze. Leave empty if none.
  • dfte: A DataFrame object passed directly instead of a file.
  • header: Row number for column headers (0-based). Default is 0.
  • verbose: Verbosity level: 0 (minimal output), 1 (more details), 2 (save plots instead of displaying).
  • lowess: Boolean. Use LOWESS smoothing for small datasets (disabled for >100,000 rows).
  • chart_format: Output format: 'svg', 'png', 'jpg', or 'html'.
  • max_rows_analyzed: Limit on rows to analyze. Default is 150,000.
  • max_cols_analyzed: Limit on columns to analyze. Default is 30.
  • save_plot_dir: Directory to save plots. If None, creates AutoViz_Plots in the current directory.

Visualizing Data with a Target Variable

from autoviz import AutoViz_Class

AV = AutoViz_Class()

filename = "your_file.csv"
target_variable = "your_target_variable"

dft = AV.AutoViz(
    filename,
    sep=",",
    depVar=target_variable,
    dfte=None,
    header=0,
    verbose=1,
    lowess=False,
    chart_format="svg",
    max_rows_analyzed=150000,
    max_cols_analyzed=30,
    save_plot_dir=None
)

The output includes bar charts, line charts, scatter plots, and more. They are saved as HTML files in the current directory, viewable in a browser.

Visualizing a Pandas DataFrame Without a Target Variable

import pandas as pd
from autoviz import AutoViz_Class

AV = AutoViz_Class()

data = {'col1': [1, 2, 3, 4, 5], 'col2': [5, 4, 3, 2, 1]}
df = pd.DataFrame(data)

dft = AV.AutoViz(
    "",  # empty filename when using dfte
    sep=",",
    depVar="",
    dfte=df,
    header=0,
    verbose=1,
    lowess=False,
    chart_format="svg",
    max_rows_analyzed=150000,
    max_cols_analyzed=30,
    save_plot_dir=None
)

Generating Interactive Bokeh Charts

To create interactive visualizations, set chart_format="bokeh":

from autoviz import AutoViz_Class

AV = AutoViz_Class()

filename = "your_file.csv"
target_variable = "your_target_variable"
custom_plot_dir = "your_custom_plot_directory"

dft = AV.AutoViz(
    filename,
    sep=",",
    depVar=target_variable,
    dfte=None,
    header=0,
    verbose=1,
    lowess=False,
    chart_format="bokeh",
    max_rows_analyzed=150000,
    max_cols_analyzed=30,
    save_plot_dir=custom_plot_dir
)

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.