This file contains 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
# required libraries in order of appearance | |
import pandas as pd | |
import urllib | |
from bs4 import BeautifulSoup | |
from skimage import io | |
# create pandas dataframe from MoMA csv | |
df = pd.read_csv('Artworks.csv',encoding='utf-8') | |
# only take entries with a URL | |
dfurl = df[df.URL.notnull()] |
This file contains 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
/** | |
* | |
* @param one first Vector | |
* @param two second Vector | |
* @return cosine similarity as defined by <pre>dot(one,two) / ||one|| * ||two||</pre> | |
* returns 1 for same direction (similar)<br> | |
* returns 0 for perpendicular<br> | |
* returns -1 for opposite direction | |
*/ | |
public double getCosineDistance(double[] one, double[] two) { |