Skip to content

Instantly share code, notes, and snippets.

@bwhite
bwhite / rank_metrics.py
Created September 15, 2012 03:23
Ranking Metrics
"""Information Retrieval metrics
Useful Resources:
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt
http://www.nii.ac.jp/TechReports/05-014E.pdf
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf
Learning to Rank for Information Retrieval (Tie-Yan Liu)
"""
import numpy as np
@bgusach
bgusach / multireplace.py
Last active July 10, 2024 14:14
Python string multireplacement
def multireplace(string, replacements, ignore_case=False):
"""
Given a string and a replacement map, it returns the replaced string.
:param str string: string to execute replacements on
:param dict replacements: replacement dictionary {value to find: value to replace}
:param bool ignore_case: whether the match should be case insensitive
:rtype: str
"""
@thomasjk10
thomasjk10 / fol_link.py
Last active March 25, 2023 07:25
Following links in python using Beautiful Soup
@shibuiwilliam
shibuiwilliam / keras_fizzbuzz
Created February 11, 2017 12:44
fizzbuzz in Keras
import numpy as np
from keras.models import Sequential
from keras.layers import Dense
from keras.utils import np_utils
from keras.layers import Dense
from keras.models import Model
# create training data
def binary_encode(i, num_digits):
@joewiz
joewiz / environment-variables.xq
Last active September 25, 2021 12:28
Display all environment variables and their values
xquery version "3.1";
element environment-variables {
for $var in available-environment-variables()
order by $var
return
element environment-variable {
attribute name { $var },
attribute value { environment-variable($var) }
}
@binaryfoundry
binaryfoundry / fizzbuzz.py
Created January 30, 2018 15:18
Port of Joel Grus Fizz Buzz in Tensorflow to Keras
from keras.models import Sequential
from keras.layers import Dense
import numpy as np
np.random.seed(7)
NUM_DIGITS = 12
def binary_encode(i, num_digits):
return np.array([i >> d & 1 for d in range(num_digits)])
anonymous
anonymous / autoML_classification.ipynb
Created February 28, 2018 02:55
autoML_classification
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PatrikHlobil
PatrikHlobil / nested_iterator.py
Last active February 9, 2024 23:29
Get all keys or values of a nested dictionary or list in Python
def iterate_all(iterable, returned="key"):
"""Returns an iterator that returns all keys or values
of a (nested) iterable.
Arguments:
- iterable: <list> or <dictionary>
- returned: <string> "key" or "value"
Returns: