Skip to content

Instantly share code, notes, and snippets.

View theotheo's full-sized avatar
🌴
On vacation

theotheo

🌴
On vacation
View GitHub Profile
@agramfort
agramfort / ranking.py
Created March 18, 2012 13:10 — forked from fabianp/ranking.py
Pairwise ranking using scikit-learn LinearSVC
"""
Implementation of pairwise ranking using scikit-learn LinearSVC
Reference: "Large Margin Rank Boundaries for Ordinal Regression", R. Herbrich,
T. Graepel, K. Obermayer.
Authors: Fabian Pedregosa <fabian@fseoane.net>
Alexandre Gramfort <alexandre.gramfort@inria.fr>
"""
@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
@larsmans
larsmans / gist:3745866
Created September 18, 2012 21:00
Inspecting scikit-learn CountVectorizer output with a Pandas DataFrame
>>> from pandas import DataFrame
>>> from sklearn.feature_extraction.text import CountVectorizer
>>> docs = ["You can catch more flies with honey than you can with vinegar.",
... "You can lead a horse to water, but you can't make him drink."]
>>> vect = CountVectorizer(min_df=0., max_df=1.0)
>>> X = vect.fit_transform(docs)
>>> print(DataFrame(X.A, columns=vect.get_feature_names()).to_string())
but can catch drink flies him honey horse lead make more than to vinegar water with you
0 0 2 1 0 1 0 1 0 0 0 1 1 0 1 0 2 2
1 1 2 0 1 0 1 0 1 1 1 0 0 1 0 1 0 2
@willurd
willurd / web-servers.md
Last active July 26, 2024 13:45
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@KasperBrandt
KasperBrandt / IATI: DBPedia abstract, thumbnail and HDI
Created July 29, 2013 19:59
SPARQL query for retrieving the abstract, thumbnail and HDI information of a country. Should be performed on the DBPedia endpoint: http://dbpedia.org/sparql
SELECT ?thumbnail ?abstract ?hdirank ?hdiyear
WHERE {
<##DBPedia_link##> <http://dbpedia.org/ontology/thumbnail> ?thumbnail .
<##DBPedia_link##> <http://dbpedia.org/ontology/abstract> ?abstract .
FILTER(langMatches(lang(?abstract), "en")) .
<##DBPedia_link##> <http://dbpedia.org/property/hdiRank> ?hdirank .
<##DBPedia_link##> <http://dbpedia.org/property/hdiYear> ?hdiyear
}
@markheckmann
markheckmann / server.R
Created November 19, 2013 23:26
client/server interaction with shiny - part 2
library(shiny)
shinyServer( function(input, output, session) {
output$results <- renderPrint({
input$mydata
})
# observer if value of the data sent from the client changes
# if yes generate a new random color and send it back to
@fperez
fperez / ProgrammaticNotebook.ipynb
Last active May 2, 2024 19:14
Creating an IPython Notebook programatically
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DrDub
DrDub / selectfile.py
Created January 3, 2016 11:44
A file selection class build for ipywidgets without any extra dependencies.
import os
import ipywidgets as widgets
class FileBrowser(object):
def __init__(self):
self.path = os.getcwd()
self._update_files()
@devStepsize
devStepsize / azure_face_local_image.py
Created May 5, 2016 19:07
Detect faces in a local image using the Azure Face API in Python
import json
import urllib
import requests
from pprint import pprint
from os.path import expanduser
headers = {
'Content-Type': 'application/octet-stream',
'Ocp-Apim-Subscription-Key': 'your-api-key',