/ISL-python

Solutions to labs and excercises from An Introduction to Statistical Learning, as Jupyter Notebooks.

Primary LanguageJupyter NotebookMIT LicenseMIT

ISL-python

An Introduction to Statistical Learning is a textbook by Gareth James, Daniela Witten, Trevor Hastie and Robert Tibshirani. Conceptual and applied exercises are provided at the end of each chapter covering supervised learning.

This repository contains my solutions to the labs and exercises as Jupyter Notebooks written in Python using:

  • Numpy
  • Pandas
  • Matplotlib
  • Seaborn
  • Patsy
  • StatsModels
  • Sklearn

Perhaps of most interest will be the recreation of some functions from the R language that I couldn't find in the Python ecosystem. These took me some time to reproduce but the implementation details are not essential to the concepts taught in the book so please feel free to reuse. For example, a reproduction of R's lm() four-way diagnostic plot for linear regression in Chapter 3. Also, a collection of all required datasets is provided in .csv format.

To view notebooks

Links to view each notebook below. The code is provided here.

Chapter 2 - Statistical Learning: Conceptual
Chapter 2 - Statistical Learning: Applied

Chapter 3 - Linear Regression: Conceptual
Chapter 3 - Linear Regression: Applied

Chapter 4 - Classification: Conceptual
Chapter 4 - Classification: Applied

Chapter 5 - Resampling Methods: Conceptual
Chapter 5 - Resampling Methods: Applied

Chapter 6 - Linear Model Selection and Regularization: Labs
Chapter 6 - Linear Model Selection and Regularization: Conceptual
Chapter 6 - Linear Model Selection and Regularization: Applied

Chapter 7 - Moving Beyond Linearity: Labs
Chapter 7 - Moving Beyond Linearity: Applied

Chapter 8 - Tree-Based Methods: Labs
Chapter 8 - Tree-Based Methods: Conceptual
Chapter 8 - Tree-Based Methods: Applied

Chapter 9 - Support Vetor Machines: Labs
Chapter 9 - Support Vetor Machines: Conceptual
Chapter 9 - Support Vetor Machines: Applied

To run notebooks

Running the notebooks enables you to execute the code and play around with any interactive features.

To run:

  1. Install Jupyter Notebooks. I recommend doing this via the Annaconda/Conda method to ensure that package versions play nicely together.
  2. cd to this repo
  3. Run jupyter notebook to run the Jupyter server locally on your machine. It should launch in your browser.
  4. In the Jupyter browser app, navigate to the notebook you'd like to explore.