Skip to main content
SciNet
  • Home
  • All Courses
  • Calendar
  • Certificates
  • SciNet
    Main Site Documentation my.SciNet
  • CCDB
  • More
Close
Toggle search input
English
English Français
You are currently using guest access
Log in
SciNet
Home All Courses Calendar Certificates SciNet Collapse Expand
Main Site Documentation my.SciNet
CCDB
Expand all Collapse all
  1. MSC1090 - Fall 2026
  2. Assignment 10

Assignment 10

Completion requirements
Opened: Thursday, 19 November 2026, 10:00 AM
Due: Thursday, 26 November 2026, 11:59 PM

Are species real?

Taxonomists group organisms into species by looking at their bodies. The categories feel natural — a Gentoo penguin does not look like an Adelie — but a species is a hypothesis: a claim that the individuals fall into discrete, recognizable kinds. In this assignment you will test that claim with a computer that has never seen a species name. It gets four measurements from 342 penguins — bill length, bill depth, flipper length and body mass — and is asked to find groups. Then you look at the labels and ask: did it rediscover the species?

The data are the Palmer Archipelago penguin measurements (Gorman, Williams & Fraser 2014), distributed with the palmerpenguins project. You can find the data here. There are three species — Adelie, Chinstrap and Gentoo — and the measurements are in millimetres and grams. This is real field data, not a simulation: two birds are missing measurements, some birds sit on the boundary between species, and the “right” answer is not always obvious.

The pipeline is the important part. You will run k-means without the labels, choose k from the geometry alone (the cross-validation elbow using the within-cluster sum of squares), and only then use the labels to score the result. We will use purity (the fraction of birds that belong to the majority species of their cluster) as our score. A high score is not the goal; the goal is to see which birds the computer groups differently, and whether or not the groups are species.


2) Create a script named Species.Analysis.R

Your script will receive a two arguments from the Linux command line, the data file name and \(k_{\rm max}\).

Your script should:

  • load the data (entries with missing data should be excluded),
  • run 10-fold cross-validation on k-means models, with \(k\) values ranging from 1 to \(k_{\rm max}\), using within-cluster sum of squares as your validation metric,
  • save the cross-validation plot as penguin_wcss.pdf,
  • print a sentence choosing the optimum value of k and justifying that choice,
  • refit the k-means model using the best value of \(k\) and the whole data set,
  • print the composition of every cluster followed by the overall purity of the model.
  • create and save a 4-panel plot.  In each panel are the histograms (one per cluster) of one of the 4 features, colour-coded by cluster.  Label the plots appropriately, and use the data in the original units.

Your script should be modular: each part above could be performed with functions. You should also implement defensive programming, and use coding best-practices.  The values of \(k_{\rm max}\) should not be below 10.


Assignments will be graded on a 10 point basis.

Due date: November 26th, 2026, 11:59 p.m., with 0.5 point penalty per day for late submission until the cut-off date, December 3rd, 9:00a.m.

You are currently using guest access (Log in)
Data retention summary


All content on this website is made available under the Creative Commons Attribution 4.0 International licence, with the exception of all videos which are released under the Creative Commons Attribution-NoDerivatives 4.0 International licence.
Powered by Moodle