Skip to content

Instantly share code, notes, and snippets.

View alex2awesome's full-sized avatar

alex2awesome alex2awesome

  • New York Times
  • NYC
View GitHub Profile
@alex2awesome
alex2awesome / lda_sklearn_gensim.py
Created December 22, 2020 01:08
Quick LDA with SKLearn Pipelining
import pandas as pd
from gensim.sklearn_api import LdaTransformer
from gensim.corpora import Dictionary
from sklearn.base import BaseEstimator, MetaEstimatorMixin
import re
from sklearn.pipeline import Pipeline
from sklearn.feature_extraction.text import CountVectorizer
from collections import defaultdict
@alex2awesome
alex2awesome / remove_leading_zeros_heatmap.py
Created December 22, 2020 00:32
Custom Formatting for Seaborn Annotations
## Because Seaborn doesn't allow custom formatting for annotations, you have to do this crazy workaround to access the text:
def formatFloat(fmt, val):
ret = fmt % val
if ret.startswith("0."):
return ret[1:]
if ret.startswith("-0."):
return "-" + ret[2:]
return ret
//so far, this opens a new page and embeds the video in this page.
javascript:
window.open().document.write(
'<iframe id = \"video\" title=\"YouTube video player\" class=\"youtube-player\" type=\"text/html\"' +
'width=\"560 \" height=\"315\" src=\"http://www.youtube.com/embed/
' + location.search.split(/=/)[1] + '\"' +
'frameborder=\"0\" allowFullScreen></iframe>')