Skip to content

Commit

Permalink
0703 code tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanrongen committed Mar 7, 2024
1 parent 843796d commit ef111af
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions _freeze/materials/mva-kmeans/execute-results/html.json

Large diffs are not rendered by default.

Binary file modified _freeze/materials/mva-kmeans/figure-html/unnamed-chunk-12-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/materials/mva-kmeans/figure-html/unnamed-chunk-18-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/materials/mva-kmeans/figure-html/unnamed-chunk-19-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/materials/mva-kmeans/figure-html/unnamed-chunk-25-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/materials/mva-kmeans/figure-html/unnamed-chunk-28-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _freeze/materials/mva-kmeans/figure-html/unnamed-chunk-29-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 8 additions & 3 deletions materials/mva-kmeans.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ We reformat and rename the scaled data:
# convert NumPy arrays to Pandas DataFrame
penguins_scaled_py = pd.DataFrame(penguins_scaled_py)
penguins_scaled_py = penguins_scaled_py.rename(columns={0: 'bdepth_scaled', 1: 'blength_scaled'})
penguins_scaled_py = (penguins_scaled_py
.rename(columns = {0: 'bdepth_scaled',
1: 'blength_scaled'}))
```


Expand All @@ -262,13 +264,16 @@ penguins_py['id'] = range(1, len(penguins_py) + 1)
penguins_scaled_py['id'] = range(1, len(penguins_scaled_py) + 1)
# merge the data by ID
penguins_augment_py = pd.merge(penguins_py.dropna(), penguins_scaled_py, on = 'id')
penguins_augment_py = (pd.merge(penguins_py.dropna(),
penguins_scaled_py,
on = 'id'))
# add the cluster designation
penguins_augment_py['cluster'] = kmeans.fit_predict(penguins_scaled_py)
# and convert it into a factor
penguins_augment_py['cluster'] = penguins_augment_py['cluster'].astype('category')
penguins_augment_py['cluster'] = (penguins_augment_py['cluster']
.astype('category'))
```

Expand Down

0 comments on commit ef111af

Please sign in to comment.