Skip to content

Instantly share code, notes, and snippets.

Joydeep Bhattacharjee infinite-Joy

View GitHub Profile
View main.rs
#[macro_use]
extern crate yew;
use yew::prelude::*;
struct Model {
hello: String,
}
enum Msg {
DoIt,
View graph_similarities.py
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:
View gensim_node2vec_most_similar.py
from gensim.models import KeyedVectors
filename = 'emb/movies.emb'
model = KeyedVectors.load_word2vec_format(filename, binary=False)
model.most_similar('260169')
View store_embeddings.py
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:]]
View create_edge_list_file.py
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:
View create_relationship.py
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
View build.sbt
import Dependencies._
lazy val nd4jVersion = "0.7.2"
lazy val root = (project in file(".")).
settings(
inThisBuild(List(
organization := "com.example",
scalaVersion := "2.12.5",
)),
View profiling_line_memory.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View profiling_time.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View debugging_using_python.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.