Skip to content

Instantly share code, notes, and snippets.

View geblanco's full-sized avatar

Guillermo Blanco geblanco

View GitHub Profile
@geblanco
geblanco / interactive_map_from_addresses.py
Created May 5, 2021 11:28
Simple script to paint in an interactive map a set of addreses from a csv file.
# !pip install requests urllib3 geopy pandas folium
# partially taken from:
# https://towardsdatascience.com/pythons-geocoding-convert-a-list-of-addresses-into-a-map-f522ef513fd6\
import requests
import json
import urllib
from geopy.geocoders import Nominatim, GoogleV3
import pandas as pd
import folium
@geblanco
geblanco / sklearn.classification_report.py
Created March 5, 2021 12:44
Pretty print classification report from a previous classification report dict (Useful when saving dict to disk and later print without recalculating everything). Not tested for multi labeled data
# extracted from: https://github.com/scikit-learn/scikit-learn/blob/0fb307bf3/sklearn/metrics/_classification.py#L1825
def classification_report(data_dict):
"""Build a text report showing the main classification metrics.
Read more in the :ref:`User Guide <classification_report>`.
Parameters
----------
report : string
Text summary of the precision, recall, F1 score for each class.
Dictionary returned if output_dict is True. Dictionary has the
5a6,8
> import json
>
> import sklearn.metrics as metrics
6a10,11
> from sklearn.metrics import precision_recall_curve
> from dvc.api import make_checkpoint
10c15
< if len(sys.argv) != 3:
---
@geblanco
geblanco / generateSquareIcon.js
Last active May 25, 2020 12:07
Generate a square icon of any given size with a given text. Useful to easily create favicons based on text. Used in https://github.com/m0n0l0c0/Pomodoro
// requires canvas, npm i canvas
var Canvas = require('canvas')
var fs = require('fs')
// Constants
var DIM = { width : 24, border : 1.3, font : 14 }
var COLOR = { light: '#ec9a97', text:'#3189cc' , border:'#e13d35' }
function paintCircularText(filePath=null, text=null, fill=false, border=true, callback=null){
@geblanco
geblanco / evaluate-squad-v2.0.py
Last active December 4, 2019 10:12
Modified version of SQuAD 2.0 evaluate script to save exact and f1 scores for each question.
"""Official evaluation script for SQuAD version 2.0.
In addition to basic functionality, we also compute additional statistics and
plot precision-recall curves if an additional na_prob.json file is provided.
This file is expected to map question ID's to the model's predicted probability
that a question is unanswerable.
"""
import argparse
import collections
import json
@geblanco
geblanco / extract_ipython_code.py
Last active June 25, 2019 12:47
Extracts all the content inside an *.ipynb file and write it to a file of code, non code cells go as comments
import os
import sys
import json
languages = dict(
python=dict(ext='py', comment='#'),
javascript=dict(ext='js', comment='//')
)
if len(sys.argv) < 2: