Input: a line scaling standard or scaling none, then a CSV with a station column and numeric attributes.
Optionally standardize (StandardScaler), fit PCA(n_components=2), and print scaling: standard; explained variance: PC1 84.2%, PC2 14.3%, total 98.5%, then for each component PC1 loadings: trips_per_day +0.53, mean_min -0.52, … — flip the sign of a component so that its largest absolute loading is positive (PCA signs are arbitrary) — and PC1 is dominated by: trips_per_day (largest absolute loading of PC1).
Data for this lab
Your program reads its data from standard input. Download the file, then give it to your program as shown below.
Start with data set 1: its expected output is given.
scaling standard
station,trips_per_day,mean_min,casual_share,km_to_centre
North Gate,420,9,0.10,1.2
Library,380,8,0.12,0.8
City Hall,450,10,0.08,0.5
Riverside,120,28,0.65,4.5
Park,150,32,0.70,3.8
Beach,90,35,0.80,9.0
Airport,60,22,0.30,12.0
Station Sq,300,12,0.20,2.0
Write it here, in Jupyter or in your IDE, then paste it. Run it on the sample input yourself before comparing.
Your code stays in your browser — it is never sent to or stored on the server.