Skip to content

Commit 034a350

Browse files
authored
Merge pull request #121 from mciwing/SimpleImputer-randomstate
[Data Science] Minor content changes
2 parents 611daba + 3214c28 commit 034a350

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

docs/data-science/algorithms/index.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,16 @@ X = [
183183
]
184184

185185
# use k-means to find customer segments
186-
model = KMeans(n_clusters=2)
186+
model = KMeans(n_clusters=2, random_state=42) # (1)!
187187
segments = model.fit_predict(X)
188188

189189
print(segments)
190190
```
191191

192+
1. Setting the `random_state` parameter ensures that you get the same results
193+
when executing the code. Reproducibility is discussed more in-depth in
194+
upcoming chapters.
195+
192196
```title=">>> Output"
193197
[1 0 1 0 1]
194198
```

docs/data-science/algorithms/unsupervised/clustering.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,10 @@ Each row in the data set
530530
Solve the following tasks to apply k-means to the semiconductor data:
531531

532532
1. Are there any missing values in the data?
533-
2. Deal with potential missing values; choose any suitable strategy. For a
534-
refresher on missing values, visit the
535-
[Data preprocessing](../../data/preprocessing.md#missing-values) chapter.
533+
2. Deal with potential missing values; choose any suitable strategy. We
534+
recommend to utilize the [`SimpleImputer`](https://scikit-learn.org/stable/modules/generated/sklearn.impute.SimpleImputer.html) with your chosen strategy. The application
535+
of the `SimpleImputer` should be straightforward as it implements the
536+
methods you already know, e.g., `fit_transform()`.
536537
3. Do you need to scale the features? If so, apply a `StandardScaler`.
537538
4. Use the elbow method to determine the number of clusters.
538539
5. Fit the k-means algorithm with the optimal number of clusters.

0 commit comments

Comments
 (0)