3D heatmap plot library
Project description
Getting Started
Install the Pypi package using pip
pip install heatmap3Dlib
Clone the repo
Get a copy of this repo using git clone
git clone https://github.com/MatteoBiviano/heatmap_3Dlib.git
Function heatmap_3d
Brief
Function that use matplotlib voxels for visualize grid search results
Parameters
:param path: path for the dataframe contains grid search results
dataframe must be in one of these form:
- <name_metric_tuned, "criterion", param1, param2, param3>
- <param1, param2, param3>
:param optimal: list of optimal values combination (e.g. [max_depth, min_samples_split, min_samples_leaf])
:param param1: first parameter tuned (x-axis)
:param param2: second parameter tuned (y-axis)
:param param3: third parameter tuned (z-axis)
:param modul: number of spaces between each pair of heatmaps plotted
:param metric: metric used in grid search (e.g. "f1", "accuracy", ...)
:param crt: (optional) pair (name_column, criterion) where name is the name used for identify the column in dataframe, while criterion is the criterion used in grid search (e.g. "gini", "entropy", ...)
:param color_map: (optional) color template for the heatmap
:param define_opt: (optional) is the list of RGBA using for identify optimal value (e.g. [1, 0, 0, 1]). If is not defined, alpha=1 identify optimal value
Return
return: tuple <axis, figure, colorbar>
Complete example of using
See the Examples folder where you will find examples of gridsearch results
import heatmap3Dlib
from heatmap3Dlib import plot3D as p3D
x_ticks = ["", "None", " 2", "","5", " 10", "", "15 ", " 20"]
y_ticks = ["", "", "2", "5", "10", "15", "20"]
z_ticks = [" 1"," 5", " 10", " 15", " 20"]
ax, fig, cbr = p3D.heatmap_3d(path = "Examples/recall_resultDT.csv", metric = "recall", optimal = [0, 2, 20],
crt = ("criterion",'gini'),
param1 = "max_depth",
param2 = "min_samples_split",
param3 = "min_samples_leaf",
modul=2)
ax.set_xticklabels(x_ticks, fontsize=12)
ax.set_yticklabels(y_ticks, fontsize=12)
ax.set_zticklabels(z_ticks, fontsize=12)
ax.set_xlabel("max_depth", fontsize=15, labelpad=10)
ax.set_ylabel("min_samples_split", fontsize=15, labelpad=10)
ax.set_zlabel("min_samples_leaf", fontsize=15, labelpad=10)
ax.set_title(f"Criterion - - {ctr[1]}", fontsize=15, loc='center', pad=15)
ax.view_init(30,300)
fig.savefig("DT_all.png", format="png")
Function heatmap_bi
Brief
Function that use matplotlib voxels for visualize grid search results. Created to be imported into PowerBi
Parameters
:param dataset: dataframe contains grid search results
:param optimal: list of optimal values combination (e.g. [max_depth, min_samples_split, min_samples_leaf])
:param param1: first parameter tuned (x-axis)
:param param2: second parameter tuned (y-axis)
:param param3: third parameter tuned (z-axis)
:param modul: number of spaces between each pair of heatmaps plotted
:param metric: metric used in grid search (e.g. "f1", "accuracy", ...)
:param crt: (optional) pair (name_column, criterion) where name is the name used for identify the column in dataframe, while criterion is the criterion used in grid search (e.g. "gini", "entropy", ...)
:param color_map: (optional) color template for the heatmap
:param define_opt: (optional) is the list of RGBA using for identify optimal value (e.g. [1, 0, 0, 1]). If is not defined, alpha=1 identify optimal value
Return
return: tuple <axis, figure, colorbar>
Complete example of using
# Insert this code in PowerBi Python script editor
import heatmap3Dlib
from heatmap3Dlib import plot3D as p3D
import matplotlib.pyplot as plt
crt = ("criterion",'gini')
ax, fig, cbr = p3D.heatmap_bi(dataset = dataset, metric = "recall", optimal = [0, 2, 20],
crt = crt,
param1 = "max_depth",
param2 = "min_samples_split",
param3 = "min_samples_leaf",
modul=2)
ax.set_xticklabels(x_ticks, fontsize=12)
ax.set_yticklabels(y_ticks, fontsize=12)
ax.set_zticklabels(z_ticks, fontsize=12)
ax.set_xlabel("max_depth", fontsize=15, labelpad=10)
ax.set_ylabel("min_samples_split", fontsize=15, labelpad=10)
ax.set_zlabel("min_samples_leaf", fontsize=15, labelpad=10)
ax.set_title(f"Criterion - crt[1]", fontsize=15, loc='center', pad=15)
ax.view_init(30,300)
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
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file heatmap3Dlib-0.2.2-py3-none-any.whl.
File metadata
- Download URL: heatmap3Dlib-0.2.2-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5904c28c0fe363fbd7108649b640166b1b37a8f3bce9913b6bea9a5270e455e6
|
|
| MD5 |
4939e1974623a07f06565e072e554647
|
|
| BLAKE2b-256 |
d2d2d88874d41fe1360f74aae358716b90c8eec3af59d6ed0bd237e8a6a7ccc5
|