Skip to content

Commit 7c37749

Browse files
authored
Merge pull request #5460 from plotly/fix-docs-build
Fix failing docs build
2 parents dbf7c26 + e8c451d commit 7c37749

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

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)