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
#[macro_use] | |
extern crate yew; | |
use yew::prelude::*; | |
struct Model { | |
hello: String, | |
} | |
enum Msg { | |
DoIt, |
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
def neo4j_most_similar(model, key): | |
with driver.session() as session: | |
find_movie_query = "MATCH (m:MovieId {name: '%s'}) return id(m)" % key | |
result = session.run(find_movie_query) | |
for r in result: | |
similar_movies = model.most_similar(str(r.value())) | |
for s_movie in similar_movies: | |
find_movie_query = "MATCH (m:MovieId) where id(m) = %s return m.name" % s_movie[0] | |
similar_movie_names = session.run(find_movie_query) | |
for sm in similar_movie_names: |
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
from gensim.models import KeyedVectors | |
filename = 'emb/movies.emb' | |
model = KeyedVectors.load_word2vec_format(filename, binary=False) | |
model.most_similar('260169') |
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
with open("emb/movies.emb", "r") as movies_file, driver.session() as session: | |
next(movies_file) | |
reader = csv.reader(movies_file, delimiter=" ") | |
params = [] | |
for row in reader: | |
movie_id = row[0] | |
params.append({ | |
"id": int(movie_id), | |
"embedding": [float(item) for item in row[1:]] |
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
print('Create the edge list') | |
with driver.session() as session, open("graph/movies.edgelist", "w") as edges_file: | |
result = session.run("""\ | |
MATCH (m:MovieId)--(other) | |
RETURN id(m) AS source, id(other) AS target | |
""") | |
writer = csv.writer(edges_file, delimiter=" ") | |
for row in result: |
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
print('Create the movieid-belongsto->genres relationship') | |
with driver.session() as session: | |
with open('movies.csv') as f: | |
reader = csv.DictReader(f, delimiter=",") | |
for line in reader: | |
movieid = line['movieId'] | |
genres = line['genres'].split('|') | |
movies = {"records": [{'movieId': movieid, 'genres': genres}]} | |
create_movie_genre_relationship = ''' | |
UNWIND {records} as record |
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
import Dependencies._ | |
lazy val nd4jVersion = "0.7.2" | |
lazy val root = (project in file(".")). | |
settings( | |
inThisBuild(List( | |
organization := "com.example", | |
scalaVersion := "2.12.5", | |
)), |
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder