This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import warnings | |
np.random.seed(1) # This line is here to get a nice plot on the first try, you can comment it | |
warnings.simplefilter('ignore', np.RankWarning) | |
%matplotlib inline | |
# Main parameters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import notion | |
from notion.client import NotionClient | |
from collections import Counter | |
from tqdm import tqdm | |
from pprint import pprint | |
from getpass import getpass | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import notion | |
from notion.client import NotionClient | |
from collections import Counter | |
from tqdm import tqdm | |
from pprint import pprint | |
from getpass import getpass | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Matplotlib animations can be saved as a widget in a Jupyter notebook. | |
# It's unclear to how to recover it in Python once the notebook kernel has been restarted. | |
# But the image data is there in the notebook, embedded in a JS script in the output of the cell | |
# with the individual frames encoded as base64 png images. | |
# So here's the way I found to extract the images and make a GIF out of them. | |
# It's not all automatic and needs some manual action. | |
# Steps: | |
# 1/ Open the notebook in a web browser. Open the developer tools, and in the console, start typing "anim" | |
# then TAB to autocomplete. A variable with a unique name looking like "animae693007f74d44b0b917c61003e9490f" should appear. | |
# Cut this variable name, and copy it in the following command that you can then execute: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import twitter | |
from tqdm import tqdm | |
from collections import defaultdict | |
import pickle | |
import pandas as pd | |
# Twitter API token |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.metrics import confusion_matrix | |
def print_cm(cm, labels): | |
"""pretty print for confusion matrixes""" | |
columnwidth = max([len(x) for x in labels]) | |
# Print header | |
print(" " * columnwidth, end="\t") | |
for label in labels: | |
print("%{0}s".format(columnwidth) % label, end="\t") | |
print() |