Skip to content

Commit 532ead9

Browse files
authored
Merge branch 'doc-prod' into fix-docs-issues
2 parents b630ada + 7c37749 commit 532ead9

File tree

3 files changed

+15
-34
lines changed

3 files changed

+15
-34
lines changed

doc/python/animations.md

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -339,27 +339,6 @@ sliders_dict = {
339339
"steps": []
340340
}
341341

342-
# make data
343-
year = 1952
344-
for continent in continents:
345-
dataset_by_year = dataset[dataset["year"] == year]
346-
dataset_by_year_and_cont = dataset_by_year[
347-
dataset_by_year["continent"] == continent]
348-
349-
data_dict = {
350-
"x": list(dataset_by_year_and_cont["lifeExp"]),
351-
"y": list(dataset_by_year_and_cont["gdpPercap"]),
352-
"mode": "markers",
353-
"text": list(dataset_by_year_and_cont["country"]),
354-
"marker": {
355-
"sizemode": "area",
356-
"sizeref": 200000,
357-
"size": list(dataset_by_year_and_cont["pop"])
358-
},
359-
"name": continent
360-
}
361-
fig_dict["data"].append(data_dict)
362-
363342
# make frames
364343
for year in years:
365344
frame = {"data": [], "name": str(year)}
@@ -396,6 +375,9 @@ for year in years:
396375

397376
fig_dict["layout"]["sliders"] = [sliders_dict]
398377

378+
# make data
379+
fig_dict["data"] = fig_dict["frames"][0]['data']
380+
399381
fig = go.Figure(fig_dict)
400382

401383
fig.show()

doc/python/dendrogram.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fig.show()
7979

8080
#### Plot a Dendrogram with a Heatmap
8181

82-
See also the [Dash Bio demo](https://dash-bio.plotly.host/dash-clustergram/).
82+
This example uses randomly generated sample data to demonstrate how to plot a dendrogram with a heatmap.
8383

8484
```python
8585
import plotly.graph_objects as go
@@ -89,12 +89,11 @@ import numpy as np
8989
from scipy.spatial.distance import pdist, squareform
9090

9191

92-
# get data
93-
data = np.genfromtxt("http://files.figshare.com/2133304/ExpRawData_E_TABM_84_A_AFFY_44.tab",
94-
names=True,usecols=tuple(range(1,30)),dtype=float, delimiter="\t")
95-
data_array = data.view((float, len(data.dtype.names)))
96-
data_array = data_array.transpose()
97-
labels = data.dtype.names
92+
# Generate sample data
93+
np.random.seed(1)
94+
X = np.random.rand(15, 15)
95+
labels = [f'Sample_{i}' for i in range(15)]
96+
data_array = X
9897

9998
# Initialize figure by creating upper dendrogram
10099
fig = ff.create_dendrogram(data_array, orientation='bottom', labels=labels)

doc/python/ml-pca.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,16 @@ fig.show()
105105

106106
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.
107107

108-
In the example below, our dataset contains 8 features, but we only select the first 2 components.
108+
In the example below, our dataset contains 10 features, but we only select the first 2 components.
109109

110110
```python
111111
import pandas as pd
112112
import plotly.express as px
113113
from sklearn.decomposition import PCA
114-
from sklearn.datasets import fetch_california_housing
114+
from sklearn.datasets import load_diabetes
115115

116-
housing = fetch_california_housing(as_frame=True)
117-
df = housing.data
116+
diabetes = load_diabetes()
117+
df = pd.DataFrame(diabetes.data, columns=diabetes.feature_names)
118118
n_components = 2
119119

120120
pca = PCA(n_components=n_components)
@@ -123,11 +123,11 @@ components = pca.fit_transform(df)
123123
total_var = pca.explained_variance_ratio_.sum() * 100
124124

125125
labels = {str(i): f"PC {i+1}" for i in range(n_components)}
126-
labels['color'] = 'Median Price'
126+
labels['color'] = 'Disease Progression'
127127

128128
fig = px.scatter_matrix(
129129
components,
130-
color=housing.target,
130+
color=diabetes.target,
131131
dimensions=range(n_components),
132132
labels=labels,
133133
title=f'Total Explained Variance: {total_var:.2f}%',

0 commit comments

Comments
 (0)