Skip to content

Instantly share code, notes, and snippets.

View acdick's full-sized avatar
🎯
Focusing

Adam Dick acdick

🎯
Focusing
View GitHub Profile
@acdick
acdick / product_similarity.py
Last active July 1, 2019 02:23
Creating a Content-Based Product Similarity Matrix for a Recommender System
import pandas as pd
# calculates the content-based product similarity matrix
# items is a Pandas dataframe containing all product details available for comparison
# returns the feature matrix and the correlation matrix
def product_similarity(items):
# drop multicollinear columns and columns not considered for similarity
items = items.drop(['Item', 'Style', 'Product', 'On Sale'], axis=1)
print(items.nunique())
@acdick
acdick / battleship_board.py
Created May 1, 2019 16:58
Setting Up a Random Battleship Board Game
import numpy as np
# generate battleship board and solution
def new_board():
# create a clear board
dim = 10
board = np.zeros((dim, dim), dtype=int)
# randomly place ships on the board
@acdick
acdick / bcg_matrix.py
Created April 7, 2019 06:57
Visualizing the BCG Matrix in Plotly
import plotly.plotly as py
import plotly.graph_objs as go
hover_text = []
color_range = []
for index, row in bcg_matrix.iterrows():
hover_text.append(('Borough: {borough}<br>'+
'Neighborhood: {neighborhood}<br>'+
'Share: {share}%<br>'+
'Growth: {growth}%<br>'+