Skip to content

Instantly share code, notes, and snippets.

View sea-shunned's full-sized avatar
🕶️

Cameron Shand sea-shunned

🕶️
View GitHub Profile
@sea-shunned
sea-shunned / silh_width.py
Created April 18, 2020 14:33
Full and partial silhouette width calculation. Code used in https://sea-shunned.github.io/post/silhouette_partial/
from itertools import permutations, product
from collections import defaultdict
import time
from pathlib import Path
import numpy as np
import pandas as pd
from sklearn.metrics import silhouette_score
from scipy.spatial.distance import pdist, squareform, cdist
import matplotlib.pyplot as plt
@sea-shunned
sea-shunned / word_counter.py
Last active September 30, 2019 13:00
Number of words tracker for thesis
import subprocess
import argparse
import csv
from datetime import datetime, timedelta
from pathlib import Path
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
@sea-shunned
sea-shunned / constructor_dict.py
Created March 6, 2019 13:17
Alternative two-arg dict constructor method
import numpy as np
# Base class
class Base:
# Dict for creating instances with common data values
init_dict = {
'type_1': np.eye(3),
'type_2': np.random.random((4, 4))**0.5,
'type_3': np.linalg.inv(np.random.random((3, 3)))
}