Skip to main content

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.

Imgur

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:

  1. A dataframe
  2. The name of a "feature" column
  3. The name of a "target" column
  4. Whether the color ramp should be inverted (default : False)
  5. A colormap (default : derived from target column)
  6. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

mosaiq-0.2.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file mosaiq-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mosaiq-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mosaiq-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 736cb4c788cbd6313d53535b3830dc882e1c2bf0f93a5c9940366bbbc0b4f9ef
MD5 a0c6af33bd44f64989589f9fc26557c1
BLAKE2b-256 618c2e2caedfcd3285df9073c02d2f94ce929f54a431e9a40aac8a092baf2b1d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page