X-Git-Url: https://code.communitydata.science/cdsc_reddit.git/blobdiff_plain/4c8bd14992b3c763cd5203ef9c8bf37cc76102b7..6baa08889b2f46c14f2baa5e3d2136cf165b1673:/term_cosine_similarity.py?ds=inline diff --git a/term_cosine_similarity.py b/term_cosine_similarity.py index 44af4e6..f4f1c6e 100644 --- a/term_cosine_similarity.py +++ b/term_cosine_similarity.py @@ -8,7 +8,7 @@ import pandas as pd import fire from itertools import islice from pathlib import Path -from similarities_helper import build_cosine_similarities +from similarities_helper import cosine_similarities spark = SparkSession.builder.getOrCreate() conf = spark.sparkContext.getConf() @@ -57,12 +57,11 @@ https://stanford.edu/~rezab/papers/dimsum.pdf. If similarity_threshold=0 we get sim_dist.entries.toDF().write.parquet(str(output_parquet),mode='overwrite',compression='snappy') - spark.stop() - #instead of toLocalMatrix() why not read as entries and put strait into numpy sim_entries = pd.read_parquet(output_parquet) df = tfidf.select('subreddit','subreddit_id_new').distinct().toPandas() + spark.stop() df['subreddit_id_new'] = df['subreddit_id_new'] - 1 df = df.sort_values('subreddit_id_new').reset_index(drop=True) df = df.set_index('subreddit_id_new')