Skip to content

Instantly share code, notes, and snippets.

View wyattowalsh's full-sized avatar
:shipit:
Hey there, welcome to my GitHub profile! 👋

Wyatt Walsh wyattowalsh

:shipit:
Hey there, welcome to my GitHub profile! 👋
View GitHub Profile
@wyattowalsh
wyattowalsh / ordinary-least-squares.py
Last active February 7, 2024 15:33
Implementation of Ordinary Least Squares in Python using NumPy
def ols(X, y, fit_intercept=True):
"""Ordinary Least Squares (OLS) Regression model with intercept term.
Fits an OLS regression model using the closed-form OLS estimator equation.
Intercept term is included via design matrix augmentation.
Params:
X - NumPy matrix, size (N, p), of numerical predictors
y - NumPy array, length N, of numerical response
fit_intercept - Boolean indicating whether to include an intercept term
@wyattowalsh
wyattowalsh / ridge.py
Created January 12, 2021 11:32
Implementation of Ridge Regression in Python Using Numpy
def ridge(X, y, l2):
"""Ridge Regression model with intercept term.
L2 penalty and intercept term included via design matrix augmentation.
This augmentation allows for the OLS estimator to be used for fitting.
Params:
X - NumPy matrix, size (N, p), of numerical predictors
y - NumPy array, length N, of numerical response
l2 - L2 penalty tuning parameter (positive scalar)
@wyattowalsh
wyattowalsh / lasso.py
Last active January 13, 2021 00:27
Implementation of the Lasso for Linear Regression in Python Using NumPy
def lasso(X, y, l1, tol=1e-6, path_length=100, return_path=False):
"""The Lasso Regression model with intercept term.
Intercept term included via design matrix augmentation.
Pathwise coordinate descent with co-variance updates is applied.
Path from max value of the L1 tuning parameter to input tuning parameter value.
Features must be standardized (centered and scaled to unit variance)
Params:
X - NumPy matrix, size (N, p), of standardized numerical predictors
y - NumPy array, length N, of numerical response
@wyattowalsh
wyattowalsh / elastic_net.py
Last active January 15, 2021 06:00
Implementation of the Elastic Net for Regression in Python Using NumPy
def elastic_net(X, y, l, alpha, tol=1e-4, path_length=100, return_path=False):
"""The Elastic Net Regression model with intercept term.
Intercept term included via design matrix augmentation.
Pathwise coordinate descent with co-variance updates is applied.
Path from max value of the L1 tuning parameter to input tuning parameter value.
Features must be standardized (centered and scaled to unit variance)
Params:
X - NumPy matrix, size (N, p), of standardized numerical predictors
y - NumPy array, length N, of numerical response
@wyattowalsh
wyattowalsh / ols.py
Created January 30, 2021 00:33
Implementations of Ordinary Least Squares (OLS) in Python
def ols_numpy(X, y, fit_intercept=True):
"""
Fits an OLS regression model using the closed-form OLS estimator equation.
Intercept term is included via design matrix augmentation.
Params:
X - NumPy matrix, size (N, p), of numerical predictors
y - NumPy array, length N, of numerical response
fit_intercept - Boolean indicating whether to include an intercept term
Returns:
NumPy array, length p + 1, of fitted model coefficients
@wyattowalsh
wyattowalsh / ridge.py
Created January 30, 2021 00:39
Implementations of Ridge Regression in Python
def ridge(X, y, l2):
"""Ridge Regression model with intercept term.
L2 penalty and intercept term included via design matrix augmentation.
This augmentation allows for the OLS estimator to be used for fitting.
Params:
X - NumPy matrix, size (N, p), of numerical predictors
y - NumPy array, length N, of numerical response
l2 - L2 penalty tuning parameter (positive scalar)
Returns:
NumPy array, length p + 1, of fitted model coefficients
@wyattowalsh
wyattowalsh / dsnotes_index.md
Last active February 2, 2021 21:35
Data Science Notes Index

Project Context

There are certainly many topics that are good for a data scientist to know and practice! I've tried my best so far to research and develop what I would consider an outline of the different topics broken up into the major sections of interest and practice. This is by no means a comprehensive list, but is ever developing and so far contains most topics. The goal with this is to present the reader with a solid index of the different topics with easily accessible content of the topic's context, overview, and more specific details.

In the Jupyter Book framework (and as specified in the _toc.yml project file) this strategy breaks down into parts, each containing chapters of which can single pages or collections of pages, where each page can be either a single page or collection of pages. [[Read more about Jupyter Book structure here](https://jupyterbook.org/c

@wyattowalsh
wyattowalsh / daily_update.yml
Created April 1, 2021 11:54
GitHub Action File to Start the Daily Update Pipeline
# action to update my kaggle basketball dataset (see more here https://www.kaggle.com/wyattowalsh/basketball)
name: Update Kaggle Basketball Dataset - Daily
# Controls when the action will run.
on:
schedule:
- cron: "15 3 * * *" # update every night at 3:15am
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Machine Learning for NBA Game Attendance Prediction

This project seeks to provide a tool to accurately predict the attendance of NBA games in order to better inform the business decisions of different stakeholders across the organization. Predicting game attendance is crucial to making optimized managerial decisions such as planning necessary staffing needs or procuring the proper level of supplies (janitorial, food services, etc). The project is currently being worked on in its second version, version_2. In version 1, an entire machine learning pipeline is established throughout a host of modules ranging from web scraping for data collection to neural-network regression modeling for prediction. These efforts resulted in a high accuracy model with mean absolute error values for attendance around 800 people. However, improvements in data sources and modeling paradigms for improved accuracy are being sought in a few ways in the upcoming version. Click the link below to view the analysis and modeling versio

@wyattowalsh
wyattowalsh / setup.sh
Last active October 18, 2023 19:43
MacOS Command Line Setup Script: Oh-My-Zsh, Homebrew, PyEnv, NVM, Java, Poetry
#!/bin/zsh
echo "Installing xcode ..."
xcode-select --install
# Check for Homebrew,
# Install if we don't have it
if test ! $(which brew); then
echo "Installing homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"