I wrote a blog post about this here.
I tweeted about it here and again
Inspired, of course, by the various wonderful comparisons in the sklearn docs, like this one for classifiers.
| import numpy as np | |
| from numpy.linalg import norm | |
| from sentence_transformers import SentenceTransformer | |
| # Define the model we want to use (it'll download itself) | |
| model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') | |
| sentences = [ | |
| "That is a very happy person", |
| from PyPDF2.generic import ( | |
| DictionaryObject, | |
| NumberObject, | |
| FloatObject, | |
| NameObject, | |
| TextStringObject, | |
| ArrayObject | |
| ) | |
| # x1, y1 starts in bottom left corner |
| ''' | |
| Most heatmap tutorials I found online use pyplot.pcolormesh with random sets of | |
| data from Numpy; I just needed to plot x, y, z values stored in lists--without | |
| all the Numpy mumbo jumbo. Here I have code to plot intensity on a 2D array, and | |
| I only use Numpy where I need to (pcolormesh expects Numpy arrays as inputs). | |
| ''' | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| #here's our data to plot, all normal Python lists |
| # Compiled source # | |
| ################### | |
| *.com | |
| *.class | |
| *.dll | |
| *.exe | |
| *.o | |
| *.so | |
| # Packages # |
| # taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/ | |
| # generate server.xml with the following command: | |
| # openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes | |
| # run as follows: | |
| # python simple-https-server.py | |
| # then in your browser, visit: | |
| # https://localhost:4443 | |
| import BaseHTTPServer, SimpleHTTPServer | |
| import ssl |
| import multiprocessing | |
| import time | |
| from random import randint | |
| PROCESSES = 5 | |
| WORKER_CALLS = 7 | |
| def worker(num): | |
| """worker function""" | |
| print 'Starting worker', num |