Skip to content

Instantly share code, notes, and snippets.

View macks22's full-sized avatar

Mack macks22

  • Washington D.C. Metropolitan Area
View GitHub Profile
@macks22
macks22 / jester-dense-subset-100x20
Created April 8, 2015 01:25
Dense subset of Jester dataset, with 100 users and 20 jokes.
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
4.08,-0.29,6.36,4.37,-2.38,-9.66,-0.73,-5.34,8.88,9.22,6.75,8.64,4.42,7.43,4.56,-0.97,4.66,-0.68,3.3,-1.21
-6.17,-3.54,0.44,-8.5,-7.09,-4.32,-8.69,-0.87,-6.65,-1.8,-6.8,-5.73,-5.0,-8.59,0.49,-8.93,-3.69,-2.18,-2.28,-6.12
6.84,3.16,9.17,-6.21,-8.16,-1.7,9.27,1.41,-5.19,-4.42,8.2,-7.86,-6.94,-7.96,0.29,-9.9,-7.09,-7.18,1.02,-0.29
-3.79,-3.54,-9.42,-6.89,-8.74,-0.29,-5.29,-8.93,-7.86,-1.6,-2.91,-0.29,-4.85,-0.49,-8.74,-6.99,-8.74,-2.91,-3.35,-0.29
1.31,1.8,2.57,-2.38,0.73,0.73,-0.97,5.0,-7.23,-1.36,3.83,1.75,5.63,-2.86,-1.8,-2.04,5.53,-0.29,-0.58,1.36
9.22,9.27,9.22,8.3,7.43,0.44,3.5,8.16,5.97,8.98,3.74,5.87,8.69,6.31,1.07,-9.13,3.69,-7.33,3.88,-7.48
8.79,-5.78,6.02,3.69,7.77,-5.83,8.69,8.59,-5.92,7.52,-4.85,-7.28,-6.75,-1.99,-3.79,4.42,4.85,-8.83,-7.96,0.49
-3.5,1.55,2.33,-4.13,4.22,-2.28,-2.96,-0.49,2.91,1.99,-1.99,5.53,-4.66,4.9,2.52,-0.68,0.0,-2.23,-6.6,-0.29
3.16,7.62,3.79,8.25,4.22,7.62,2.43,0.97,0.53,0.83,3.5,3.3,5.05,4.71,2.57,-0.73,1.02,-1.21,2.23,0.97
@macks22
macks22 / pmf-and-modified-bpmf-pymc.py
Last active May 13, 2021 13:37
Probabilistic Matrix Factorization (PMF) + Modified Bayesian BMF
"""
Implementations of:
Probabilistic Matrix Factorization (PMF) [1],
Bayesian PMF (BPMF) [2],
Modified BPFM (mBPMF)
using `pymc3`. mBPMF is, to my knowledge, my own creation. It is an attempt
to circumvent the limitations of `pymc3` w/regards to the Wishart distribution:
@macks22
macks22 / gmreg_gen_data.py
Created February 12, 2016 20:49
Data generation for Personalized Mixture of Gaussian Regressions.
def gen_data(nusers, nsamples, F, K):
"""Generate hyperparameters, parameters, and data for the Personalized
Mixture of Gaussian Regressions model.
Args:
nusers (int): Number of distinct users.
nsamples (int): Total number of samples to generate.
F (int): Number of features for feature vectors.
K (int): Number of clusters.
Return:
@macks22
macks22 / newsgroup_corpus.py
Created June 4, 2017 12:38
Provide a gensim-compatible corpus for the 20 newsgroup data, [based on this PR](https://github.com/RaRe-Technologies/gensim/pull/1388)
import os
import re
import sys
from gensim.corpora import textcorpus
from gensim import utils
class NewsgroupCorpus(textcorpus.TextDirectoryCorpus):
@macks22
macks22 / comment_out_circular_imports.py
Created September 15, 2018 13:40
swagger-codegen-circular-import-fixer
import os
import logging
import argparse
logger = logging.getLogger(__name__)
def scan_and_fix_if_needed(module_path, dry_run=False):
# first read in the file
logger.info(f"scanning module {module_path}")
@macks22
macks22 / regret-and-pvr-simulations.ipynb
Created March 16, 2019 19:58
Simulations of regret and potential value remaining (PVR) for Binomial and Beta-Binomial distributed data.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@macks22
macks22 / json_serialize_numpy_support.py
Created March 30, 2020 21:42
Example of using custom JSONEncoder and object_hook to add numpy array support to built-in JSON serialization
import json
import numpy as np
def is_diagonal(matrix):
return np.count_nonzero(matrix - np.diag(np.diagonal(matrix))) == 0
def is_identity(matrix):