Skip to content

Commit

Permalink
Update _corr.py
Browse files Browse the repository at this point in the history
added `with_numbers` parameter for correlation matrix
  • Loading branch information
mail4umar committed Oct 26, 2024
1 parent 0338aa5 commit 053fe3d
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions verticapy/core/vdataframe/_corr.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def _aggregate_matrix(
mround: int = 3,
show: bool = True,
chart: Optional[PlottingObject] = None,
with_numbers: bool = True,
**style_kwargs,
) -> PlottingObject:
"""
Expand Down Expand Up @@ -508,7 +509,7 @@ def _aggregate_matrix(
"vmax": vmax,
"vmin": vmin,
"mround": mround,
"with_numbers": True,
"with_numbers": with_numbers,
}
return vpy_plt.HeatMap(data=data, layout=layout).draw(**kwargs)
values = {"index": columns}
Expand Down Expand Up @@ -548,6 +549,7 @@ def _aggregate_vector(
mround: int = 3,
show: bool = True,
chart: Optional[PlottingObject] = None,
with_numbers: bool = True,
**style_kwargs,
) -> PlottingObject:
"""
Expand Down Expand Up @@ -728,7 +730,7 @@ def _aggregate_vector(
"vmax": vmax,
"vmin": vmin,
"mround": mround,
"with_numbers": True,
"with_numbers": with_numbers,
}
return vpy_plt.HeatMap(data=data, layout=layout).draw(**kwargs)
for idx, column in enumerate(cols):
Expand All @@ -755,6 +757,7 @@ def corr(
focus: Optional[str] = None,
show: bool = True,
chart: Optional[PlottingObject] = None,
with_numbers: bool = True,
**style_kwargs,
) -> PlottingObject:
"""
Expand Down Expand Up @@ -872,10 +875,10 @@ def corr(
}
)
fig = data.corr(method = "pearson")
fig.write_html("SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_corr_matrix.html")
fig.write_html("/project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_corr_matrix.html")
.. raw:: html
:file: SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_corr_matrix.html
:file: /project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_corr_matrix.html
You can also use the parameter focus to only compute a correlation vector.
Expand All @@ -887,10 +890,10 @@ def corr(
:suppress:
fig = data.corr(method = "pearson", focus = "score1")
fig.write_html("SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_corr_vector.html")
fig.write_html("/project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_corr_vector.html")
.. raw:: html
:file: SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_corr_vector.html
:file: /project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_corr_vector.html
It is less expensive and it allows you to focus your search on one specific
column.
Expand All @@ -912,6 +915,7 @@ def corr(
"mround": mround,
"show": show,
"chart": chart,
"with_numbers": with_numbers,
**style_kwargs,
}
if focus:
Expand Down Expand Up @@ -1254,10 +1258,10 @@ def cov(
}
)
fig = data.cov()
fig.write_html("SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_cov_matrix.html")
fig.write_html("/project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_cov_matrix.html")
.. raw:: html
:file: SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_cov_matrix.html
:file: /project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_cov_matrix.html
You can also use the parameter focus to only compute a covariance vector.
Expand All @@ -1269,10 +1273,10 @@ def cov(
:suppress:
fig = data.cov(method = "pearson", focus = "score1")
fig.write_html("SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_cov_vector.html")
fig.write_html("/project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_cov_vector.html")
.. raw:: html
:file: SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_cov_vector.html
:file: /project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_cov_vector.html
It is less expensive and it allows you to focus your search on one specific
column.
Expand Down Expand Up @@ -1432,10 +1436,10 @@ def regr(
}
)
fig = data.regr(method = "beta")
fig.write_html("SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_regr_beta_matrix.html")
fig.write_html("/project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_regr_beta_matrix.html")
.. raw:: html
:file: SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_regr_beta_matrix.html
:file: /project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_regr_beta_matrix.html
Draw the regression matrix using the Alpha coefficient.
Expand All @@ -1459,10 +1463,10 @@ def regr(
}
)
fig = data.regr(method = "alpha")
fig.write_html("SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_regr_alpha_matrix.html")
fig.write_html("/project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_regr_alpha_matrix.html")
.. raw:: html
:file: SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_regr_alpha_matrix.html
:file: /project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_regr_alpha_matrix.html
Draw the regression matrix using the R2 correlation coefficient.
Expand All @@ -1486,10 +1490,10 @@ def regr(
}
)
fig = data.regr(method = "r2")
fig.write_html("SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_regr_r2_matrix.html")
fig.write_html("/project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_regr_r2_matrix.html")
.. raw:: html
:file: SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_regr_r2_matrix.html
:file: /project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_regr_r2_matrix.html
For more examples, please look at the :ref:`chart_gallery.corr` page of the
:ref:`chart_gallery`. Those ones are related to correlation matrix, but the
Expand Down Expand Up @@ -1739,7 +1743,7 @@ def acf(
data = load_amazon()
.. raw:: html
:file: SPHINX_DIRECTORY/figures/datasets_loaders_load_amazon.html
:file: /project/data/VerticaPy/docs/figures/datasets_loaders_load_amazon.html
Draw the ACF Plot.
Expand Down Expand Up @@ -1769,10 +1773,10 @@ def acf(
width = 600,
height = 400,
)
fig.write_html("SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_acf_plot.html")
fig.write_html("/project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_acf_plot.html")
.. raw:: html
:file: SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_acf_plot.html
:file: /project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_acf_plot.html
For more examples, please look at the :ref:`chart_gallery.acf` page of the
:ref:`chart_gallery`.
Expand Down Expand Up @@ -1973,7 +1977,7 @@ def pacf(
data = load_amazon()
.. raw:: html
:file: SPHINX_DIRECTORY/figures/datasets_loaders_load_amazon.html
:file: /project/data/VerticaPy/docs/figures/datasets_loaders_load_amazon.html
Draw the PACF Plot.
Expand Down Expand Up @@ -2003,10 +2007,10 @@ def pacf(
width = 600,
height = 450,
)
fig.write_html("SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_pacf_plot.html")
fig.write_html("/project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_pacf_plot.html")
.. raw:: html
:file: SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_pacf_plot.html
:file: /project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_pacf_plot.html
For more examples, please look at the :ref:`chart_gallery.acf` page of the
:ref:`chart_gallery`. Those ones are related to ACF plots, but the customization
Expand Down Expand Up @@ -2167,7 +2171,7 @@ def iv_woe(
data = load_titanic()
.. raw:: html
:file: SPHINX_DIRECTORY/figures/datasets_loaders_load_titanic.html
:file: /project/data/VerticaPy/docs/figures/datasets_loaders_load_titanic.html
Draw the IV Bar chart.
Expand All @@ -2183,10 +2187,10 @@ def iv_woe(
vp.set_option("plotting_lib", "plotly")
data = load_titanic()
fig = data.iv_woe(y = "survived", nbins = 20)
fig.write_html("SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_iv_woe_plot.html")
fig.write_html("/project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_iv_woe_plot.html")
.. raw:: html
:file: SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_iv_woe_plot.html
:file: /project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_iv_woe_plot.html
.. hint::
Expand Down Expand Up @@ -2277,7 +2281,7 @@ def iv_woe(self, y: str, nbins: int = 10) -> TableSample:
data = load_titanic()
.. raw:: html
:file: SPHINX_DIRECTORY/figures/datasets_loaders_load_titanic.html
:file: /project/data/VerticaPy/docs/figures/datasets_loaders_load_titanic.html
Draw the IV Bar chart.
Expand All @@ -2290,12 +2294,12 @@ def iv_woe(self, y: str, nbins: int = 10) -> TableSample:
from verticapy.datasets import load_titanic
data = load_titanic()
html_file = open("SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_iv_woe_table.html", "w")
html_file = open("/project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_iv_woe_table.html", "w")
html_file.write(data["age"].iv_woe(y = "survived", nbins = 20)._repr_html_())
html_file.close()
.. raw:: html
:file: SPHINX_DIRECTORY/figures/core_vDataFrame_vDFCorr_iv_woe_table.html
:file: /project/data/VerticaPy/docs/figures/core_vDataFrame_vDFCorr_iv_woe_table.html
.. hint::
Expand Down

0 comments on commit 053fe3d

Please sign in to comment.