From 01b3da5230650841ab23f6f374e08a8fa1f850d3 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 22 Jan 2024 16:35:43 -0500 Subject: [PATCH 1/7] Update requirements.txt --- doc/requirements.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 3d1a83d96d5..826f81e9721 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -4,11 +4,11 @@ ipywidgets==7.7.2 jupyter-client<7 jupyter notebook -pandas==1.1.5 -statsmodels==0.12.1 -scipy==1.5.4 +pandas==1.5.3 +statsmodels +scipy patsy==0.5.1 -numpy==1.19.5 +numpy plotly-geo igraph geopandas==0.8.1 @@ -16,7 +16,7 @@ pyshp==2.1.2 shapely==1.7.1 psutil requests -networkx==2.6.3 +networkx squarify scikit-image==0.18.1 scikit-learn From 5d9cc376aeb70da61fe05c91580900350e06a37c Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 22 Jan 2024 17:01:12 -0500 Subject: [PATCH 2/7] Update requirements.txt --- doc/requirements.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 826f81e9721..16a52b54523 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -4,11 +4,11 @@ ipywidgets==7.7.2 jupyter-client<7 jupyter notebook -pandas==1.5.3 -statsmodels -scipy +pandas==1.1.5 +statsmodels==1.12.1 +scipy==1.5.4 patsy==0.5.1 -numpy +numpy==1.19.5 plotly-geo igraph geopandas==0.8.1 @@ -18,7 +18,7 @@ psutil requests networkx squarify -scikit-image==0.18.1 +scikit-image scikit-learn sphinx==3.5.4 sphinx_bootstrap_theme From 623ea966f80aff2142d00103f3435aec6bafc1f0 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 22 Jan 2024 17:04:01 -0500 Subject: [PATCH 3/7] Update requirements.txt --- doc/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 16a52b54523..0591b9303a9 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -5,7 +5,7 @@ jupyter-client<7 jupyter notebook pandas==1.1.5 -statsmodels==1.12.1 +statsmodels==0.12.1 scipy==1.5.4 patsy==0.5.1 numpy==1.19.5 From 4aa9fe232f7fee1ca24afffe1d531f306d7e197d Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 22 Jan 2024 17:05:50 -0500 Subject: [PATCH 4/7] Update requirements.txt --- doc/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 0591b9303a9..7519f0e11f2 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -4,7 +4,7 @@ ipywidgets==7.7.2 jupyter-client<7 jupyter notebook -pandas==1.1.5 +pandas==1.2.0 statsmodels==0.12.1 scipy==1.5.4 patsy==0.5.1 From 61a09b96ceeda04e65d38da36213854946fc4889 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 22 Jan 2024 17:28:18 -0500 Subject: [PATCH 5/7] Update conda_build_config.yaml --- packages/python/plotly/recipe/conda_build_config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/python/plotly/recipe/conda_build_config.yaml b/packages/python/plotly/recipe/conda_build_config.yaml index abcf8353472..86b425eca79 100644 --- a/packages/python/plotly/recipe/conda_build_config.yaml +++ b/packages/python/plotly/recipe/conda_build_config.yaml @@ -1,2 +1,2 @@ python: - - 3.6 + - 3.8 From 5ae9da403efdec34a448c895ecca4fa87d4a532a Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 22 Jan 2024 17:28:22 -0500 Subject: [PATCH 6/7] Update ml-pca.md --- doc/python/ml-pca.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/doc/python/ml-pca.md b/doc/python/ml-pca.md index cbd38e0fd9c..2160f671395 100644 --- a/doc/python/ml-pca.md +++ b/doc/python/ml-pca.md @@ -6,9 +6,9 @@ jupyter: extension: .md format_name: markdown format_version: '1.3' - jupytext_version: 1.14.1 + jupytext_version: 1.16.1 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 language_info: @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.8.8 + version: 3.10.11 plotly: description: Visualize Principle Component Analysis (PCA) of your high-dimensional data in Python with Plotly. @@ -105,17 +105,18 @@ fig.show() When you will have too many features to visualize, you might be interested in only visualizing the most relevant components. Those components often capture a majority of the [explained variance](https://en.wikipedia.org/wiki/Explained_variation), which is a good way to tell if those components are sufficient for modelling this dataset. -In the example below, our dataset contains 10 features, but we only select the first 4 components, since they explain over 99% of the total variance. +In the example below, our dataset contains 8 features, but we only select the first 2 components. ```python import pandas as pd import plotly.express as px from sklearn.decomposition import PCA -from sklearn.datasets import load_boston +from sklearn.datasets import fetch_california_housing -boston = load_boston() -df = pd.DataFrame(boston.data, columns=boston.feature_names) -n_components = 4 +housing = fetch_california_housing(as_frame=True) +df = housing.data + +n_components = 2 pca = PCA(n_components=n_components) components = pca.fit_transform(df) @@ -127,7 +128,7 @@ labels['color'] = 'Median Price' fig = px.scatter_matrix( components, - color=boston.target, + color=housing.target, dimensions=range(n_components), labels=labels, title=f'Total Explained Variance: {total_var:.2f}%', @@ -136,6 +137,10 @@ fig.update_traces(diagonal_visible=False) fig.show() ``` +```python +df +``` + ## PCA analysis in Dash [Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. To run the app below, run `pip install dash`, click "Download" to get the code and run `python app.py`. From 9dc9d5fd19bc86c022f127c30d64a12cdf3fe04e Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Mon, 22 Jan 2024 17:36:23 -0500 Subject: [PATCH 7/7] Update requirements.txt --- doc/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 7519f0e11f2..b329e22271b 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -16,9 +16,9 @@ pyshp==2.1.2 shapely==1.7.1 psutil requests -networkx +networkx==2.6.3 squarify -scikit-image +scikit-image==0.18.1 scikit-learn sphinx==3.5.4 sphinx_bootstrap_theme