-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve description and correct plot for ‘auto’ correlation (#1119)
* fix: correct plot and formatting for ‘auto’ correlation * fix: create example ‘auto’ correlation notebook * fix: add example for 'auto' correlation in python script
- Loading branch information
Showing
2 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from pathlib import Path | ||
import pandas as pd | ||
|
||
from pandas_profiling import ProfileReport | ||
from pandas_profiling.utils.cache import cache_zipped_file | ||
|
||
""" | ||
The "Auto" correlation is an interpretable pairwise column metric of the following mapping: | ||
- Variable_type-Variable_type : Method, **Range** | ||
- Categorical-Categorical : Cramer's V, **[0,1]** | ||
- Numerical-Categorical : Cramer's V, **[0,1]** (using a discretized numerical column) | ||
- Numerical-Numerical : Spearman's Rho, **[-1,1]** | ||
""" | ||
|
||
# Download the UCI Bank Marketing Dataset- as seen in examples/bank_marketing_data/banking_data.py | ||
file_name = cache_zipped_file( | ||
"bank-full.csv", | ||
"https://archive.ics.uci.edu/ml/machine-learning-databases/00222/bank.zip", | ||
) | ||
|
||
df = pd.read_csv(file_name, sep=";") | ||
|
||
profile = ProfileReport( | ||
df, title="Profile Report of the UCI Bank Marketing Dataset", explorative=True | ||
) | ||
|
||
|
||
# The simplest way to change the number of bins is either through your script or notebook. | ||
# This changes the granularity of the association measure for Numerical-Categorical column pairs. | ||
profile.config.correlations["auto"].n_bins = 8 | ||
|
||
|
||
# The 'auto' correlation matrix is displayed with the other correlation matrices in the report. | ||
profile.to_file(Path("uci_bank_marketing_report.html")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters