A generalized mosaic plotting function for categorical and numerical data.
Project description
Mosaiq for Python
This is a simplified mosaic plot technique that works for numeric/categorical data.
For categorical data, a frequency table of values is calculated. Only the top 7 most common categories are preserved. The rest are replaced by "NA_TOPN".
For numeric data, a histogram is calculated over the distribution. The precise numeric values are replaced by its respective bin.
Call it with the following arguments:
- A dataframe
- The name of a "feature" column
- The name of a "target" column
- Whether the color ramp should be inverted (default : False)
- A colormap (default : derived from target column)
- The number of categories to preserve in categorical data (default : 7)
# dat (pandas dataframe)
# feature (feature name string)
# target (target name string)
mosaiq(dat, feature, target)
Using this visualization makes it easy to iterate through all feature/target interactions in a given dataset:
for col in dat.columns:
if col == target:
continue # skip the plot if the column is the target
mosaiq(mdat, col, target)
plt.show()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file mosaiq-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: mosaiq-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d568d9b9015367074454123ea34c5f6c0e37e5419cf3b1dbf658c4ad66f7ab1 |
|
MD5 | 8015c37620386fbefc35ad801ef10f31 |
|
BLAKE2b-256 | e7ecf122d1f1f6cdb149c92325e9e23fd4e1ecf5fdcd34b30923a4ee0b0627ad |