]> code.communitydata.science - cdsc_reddit.git/blobdiff - similarities/cosine_similarities.py
no longer do we need to get daily dumps
[cdsc_reddit.git] / similarities / cosine_similarities.py
index 609e4779673d0fc46aaa901949f605f8554359af..38b1d7c7c1643ac4c64cd85153cbda4bc9c3eec1 100644 (file)
@@ -1,30 +1,57 @@
 import pandas as pd
 import fire
 from pathlib import Path
 import pandas as pd
 import fire
 from pathlib import Path
-from similarities_helper import similarities
+from similarities_helper import similarities, column_similarities
 
 
-def cosine_similarities(infile, term_colname, outfile, min_df=None, included_subreddits=None, topN=500, exclude_phrases=False,from_date=None, to_date=None):
-    return similiarities(infile=infile, simfunc=column_similarities, term_colname=term_colname, outfile=outfile, min_df=min_df, included_subreddits=included_subreddits, topN=topN, exclude_phrases=exclude_phrases,from_date=from_date, to_date=to_date)
+def cosine_similarities(infile, term_colname, outfile, min_df=None, max_df=None, included_subreddits=None, topN=500, exclude_phrases=False, from_date=None, to_date=None, tfidf_colname='tf_idf'):
 
 
-def term_cosine_similarities(outfile, min_df=None, included_subreddits=None, topN=500, exclude_phrases=False, from_date=None, to_date=None):
-    return cosine_similarities('/gscratch/comdata/output/reddit_similarity/tfidf/comment_terms.parquet',
+    return similarities(infile=infile, simfunc=column_similarities, term_colname=term_colname, outfile=outfile, min_df=min_df, max_df=max_df, included_subreddits=included_subreddits, topN=topN, exclude_phrases=exclude_phrases,from_date=from_date, to_date=to_date, tfidf_colname=tfidf_colname)
+
+
+def term_cosine_similarities(outfile, min_df=None, max_df=None, included_subreddits=None, topN=500, exclude_phrases=False, from_date=None, to_date=None):
+
+    return cosine_similarities('/gscratch/comdata/output/reddit_similarity/tfidf/comment_terms_100k.parquet',
                                'term',
                                outfile,
                                min_df,
                                'term',
                                outfile,
                                min_df,
+                               max_df,
+                               included_subreddits,
+                               topN,
+                               exclude_phrases,
+                               from_date,
+                               to_date
+                               )
+
+def author_cosine_similarities(outfile, min_df=2, max_df=None, included_subreddits=None, topN=10000, from_date=None, to_date=None):
+    return cosine_similarities('/gscratch/comdata/output/reddit_similarity/tfidf/comment_authors_100k.parquet',
+                               'author',
+                               outfile,
+                               min_df,
+                               max_df,
                                included_subreddits,
                                topN,
                                included_subreddits,
                                topN,
-                               exclude_phrasesby.)
+                               exclude_phrases=False,
+                               from_date=from_date,
+                               to_date=to_date
+                               )
 
 
-def author_cosine_similarities(outfile, min_df=2, included_subreddits=None, topN=10000, from_date=None, to_date=None):
-    return cosine_similarities('/gscratch/comdata/output/reddit_similarity/tfidf/comment_authors.parquet',
+def author_tf_similarities(outfile, min_df=2, max_df=None, included_subreddits=None, topN=10000, from_date=None, to_date=None):
+    return cosine_similarities('/gscratch/comdata/output/reddit_similarity/tfidf/comment_authors_100k.parquet',
                                'author',
                                outfile,
                                min_df,
                                'author',
                                outfile,
                                min_df,
+                               max_df,
                                included_subreddits,
                                topN,
                                included_subreddits,
                                topN,
-                               exclude_phrases=False)
+                               exclude_phrases=False,
+                               from_date=from_date,
+                               to_date=to_date,
+                               tfidf_colname='relative_tf'
+                               )
+
 
 if __name__ == "__main__":
     fire.Fire({'term':term_cosine_similarities,
 
 if __name__ == "__main__":
     fire.Fire({'term':term_cosine_similarities,
-               'author':author_cosine_similarities})
+               'author':author_cosine_similarities,
+               'author-tf':author_tf_similarities})
 
 

Community Data Science Collective || Want to submit a patch?