Skip to content

Instantly share code, notes, and snippets.

@Jian-Qiao
Created August 23, 2017 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jian-Qiao/a015b6348bc14dcbfdcb6f670b622ab0 to your computer and use it in GitHub Desktop.
Save Jian-Qiao/a015b6348bc14dcbfdcb6f670b622ab0 to your computer and use it in GitHub Desktop.
tf_vectorizer1 = CountVectorizer(max_df=0.95, min_df=2, max_features=400,
stop_words='english')
tf_vectorizer2 = CountVectorizer(max_df=0.95, min_df=2, max_features=200,
stop_words='english')
tf1 = tf_vectorizer1.fit_transform(np.array(Description_cleaned.replace(np.nan, '')))
tf2 = tf_vectorizer2.fit_transform(np.array(Search_Term.replace(np.nan,'')))
TF = TfidfTransformer()
#tf_idf_Bullets = TF.fit_transform(tf1)
tf_idf_Description=TF.fit_transform(tf1)
tf_idf_Search_Term= TF.fit_transform(tf2)
Trans_Description=pd.DataFrame(tf_idf_Description.toarray())
Trans_Description.index=Description_cleaned.index
Trans_Search_Term=pd.DataFrame(tf_idf_Search_Term.toarray())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment