Questions tagged [tfidf]

tf–idf (term frequency–inverse document frequency), is a numerical statistic using in nlp that is intended to reflect how important a word is to a document in a collection or corpus. It is often used as a weighting factor in searches of information retrieval, text mining, and user modeling. tf–idf increases proportionally the number of times a word appears in the document.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
35 views

How can Cosine similarity differ from BERT to Word2vec?

I was trying to measure the similarity between new-text and the closest ones from corpus by using TF-IDF and BERT. I got the most accurate ones with TF-IDF opposed to BERT. I got: ...
2 votes
1 answer
172 views

Is there a way to map words to their synonyms in tfidf?

I have the following code: ...
1 vote
1 answer
11 views

Why is max_features ordered by term frequency instead of inverse document frequency

In the docs: https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.TfidfVectorizer.html it is explained that max_features is ordered by ...
1 vote
0 answers
20 views

How can I decide the threshold value for relevance score in a search problem?

I am using a LSA/TF-IDF/BM25/Ensemble models for text search and finally calculating similarity score to rank my search. I would like to decide a threshold value for the score, below which I would not ...
1 vote
1 answer
16 views

Effectiveness of tf-idf on documents with repeated keywords

I was doing some ML reading and came upon tf-idf. The tf portion counts the relative frequency of a relevant word in a document, while idf measures how common or rare a word is across the corpus. The ...
0 votes
0 answers
29 views

How Can I print the values of Tfidf vectorizer?

I have a code like this model = make_pipeline(TfidfVectorizer(),MultinomialNB()) Now I was giving data to the model like this ...
  • 11
0 votes
0 answers
17 views

How do I use TF-IDF for set of keywords?

I have a set of keyword K = {K1,K2,K3,...} K1 = (president governor) k2 = (foot ball players goal) K3=(Hero Heroine song singer) etc. like these and each K1...Kn belongs to some category like in ...
  • 11
1 vote
1 answer
17 views

Is there a tokenizer to tokenize Swift language code in python

...
0 votes
0 answers
31 views

Is TF-IDF for text classification transferable between corpuses?

I am using TF-IDF for text classification and my solution works well according to the performance metric of my choice (F1 macro). To speed up the training process I have used PCA to reduce the ...
0 votes
1 answer
29 views

Optimal clusters for K-means not clear - any ideas?

I have a toy dataset of 10,000 strings of people's names, addresses and birthdays. As a quirk of the data collection process it is highly likely there are duplicate people caused by typos and I am ...
  • 197
0 votes
0 answers
9 views

Naive Bayes TfidfVectorizer predicts everything to one class

I'm trying to run Multinomial Bayes classificator on various balanced data sets and comparing 2 different vectorizers: TfidfVectorizer and CountVectorizer. I have 3 classes: NEG, NEU and POS. I have ...
1 vote
1 answer
33 views

NLP Basic input doubt

I actually have a basic doubt in NLP, When we consider traditional models like Decision trees, The feature column order is important, Like first column is fixed with some particular attribute. So If, ...
  • 109
1 vote
1 answer
14 views

How to justify logarithmically scaled frequency for tf in tf-idf?

I am studying tf-idf (term frequency - inverse document frequency). The original logic for tf was straightforward: count of term t / number of total terms in the document. However, I came across the ...
0 votes
1 answer
1k views

'list' object has no attribute 'lower' TfidfVectorizer

I have a dataframe with two text columns and I converted them to a list. I seperated the train and test data as well. But while making a base model TfidfVectorizer throws me an error of 'list' object ...
1 vote
1 answer
22 views

Document Similarity with User Preference

To measure the similarity between two documents, one can use, e.g. TF-IDF/Cosine Similarity. Supposing that after calculating the similarity scores of Doc A against ...
2 votes
2 answers
391 views

What are the exact differences between Word Embedding and Word Vectorization?

I am learning NLP. I have tried to figure out the exact difference between Word Embedding and Word Vectorization. However, seems like some articles use these words interchangeably. But I think there ...
  • 23
0 votes
0 answers
120 views

Input 0 of layer max_pooling1d_3 is incompatible with the layer Error

Ok, so basically, i have some Tf-Idf features and some additional features like wordcount, sentiment on my data. Now, according to my knowledge, when we use Convolutional layer, the data needs to be ...
1 vote
1 answer
23 views

Distinguishing text with opposite meanings in SVM (False Information Detection)

I am currently working on a Binary Text Classification Model (False Information Detection) using Support Vector Machine and used TF-IDF as text vectorizer in Python. I have already tried training the ...
0 votes
1 answer
97 views

How to have a fixed no of features for input layer of a neural network when using TF-IDF

So basically my question is hypothetically lets say: I have a column containing 2000 rows of texts, and when I apply tf-idf, I get 27 features like shown below. Now once I do that, I could consider ...
2 votes
1 answer
696 views

My custom stop-words list using tf-idf

I want to make my own stop words list, I computed tf-idf scores for my terms. Can I consider those words highlighted with red to be stop word? and what should my threshold be for stop words that ...
  • 45
0 votes
0 answers
58 views

How to find similar document (using gensim) given two or more other documents?

I am developing a similarity program to compare documents, and I’ve successfully trained my model with Gensim (TFIDF and LSI) in order to compare two documents of each other, and it works great. I can ...
  • 101
0 votes
0 answers
36 views

How to unify weights in my dataset

I have a symptom-disease network that consists of four attributes: symptom, disease, co-occurrence and TF-IDF. I'm considering the TF-IDF attribute as the weight of my network edges and symptom and ...
0 votes
0 answers
29 views

DBSCAN getting one huge cluster with noisy points

I'm currently trying to cluster customer service email answers (NLP). When I use DBSCAN with TF-IDF embeddings + Annoy indexes, I get good clusters. But, when I use DBSCAN with FastText embeddings + ...
0 votes
0 answers
8 views

Natural Language gender classification task with very small training set

The task involving determining the gender of the creator of a Reddit post. Given a post and its title, I need a model to output a probability vector $[p_{male},p_{female}]$. The difficulty here is ...
2 votes
1 answer
69 views

Why tfidf of one document is not zero?

I'm new to nlp. Recently I wanted to do little nlp tasks, and faced strange thing. That is I have run the following code ...
  • 123
0 votes
2 answers
915 views

What is the best way to limit number of features in TF-IDF?

I am using the tf-idf to build representations. It is large dataset and it quickly becomes too much for my RAM if I convert the matrix to a Data-Frame. What is the best way to reduce the number of ...
0 votes
0 answers
36 views

Keyword Imputation Using Machine Learning and NLP

I am fairly new to machine learning and data imputation so forgive me if I am using wrong words or not feasible ideas. I have a table as follows, with text in the Headline column and a list of ...
0 votes
2 answers
28 views

Encoding feature containing both text and string?

I have a feature which has following entries:- | Exterior | | -------- | | Vinyl | | Wd Sdng | | MetalSd | | Wd Sdng | | HdBoard | | BrkFace | | Wd Sdng | ...
  • 1,293
1 vote
0 answers
167 views

How to measure the pairwise similarity between two textual data sets?

I have N textual data sets, and each one is composed of thousands of documents. I want to compare them to find which data sets are more similar (Similar to what it ...
  • 119
2 votes
1 answer
42 views

Using word embeddings as features in classification algorithms?

I see there are ways to combine word vectors to form documents by taking averages or weighted averages. However, as a result of averaging there is a loss of information. Are there ways to retain the ...
2 votes
0 answers
105 views

Can I rescale TF matrix or TF-IDF matrix using StandardScaler prior to Logisitc Lasso regression?

I am trying to use Logistic Lasso to classify documents as 1 or 0. I've tried using both the TF matrix and TF-IDF matrix representations of the documents as my predictors. I've found that if I use the ...
0 votes
4 answers
749 views

Creating & handling large matrices in python? [closed]

I need to create a large matrix of size 400,000*400,000 and do some transformation on it. I am not able to do it using python in my laptop due to memory constraints. What technologies I can use to ...
1 vote
1 answer
263 views

TF-IDF for 400,000+ unique words in corpus?

I have a corpus with over 400,000 unique words. I would like to build a TF-IDF matrix for this corpus. I have tried doing this on my laptop (16GB RAM) and Google Colab, but am unable to do so due to ...
1 vote
1 answer
382 views

Running PCA on top of tf-idf features?

Is it a good idea to run PCA on top of attributes obtained with Tf-Idf? The tf-idf returns a lot of attributes so in that case I believe it is a good idea to run PCA to reduce the number of dimensions....
1 vote
2 answers
232 views

How do I get ngrams for all combinations of words in a sentence?

Lets say I have a sentence "I need multiple ngrams". If I create bigrams using Tf idf vectorizer it will create bigrams only using consecutive words. i.e. I will get "I need", &...
0 votes
0 answers
125 views

Sparse matrix after vectorization giving size = 1

I am working on a NLP problem https://www.kaggle.com/c/nlp-getting-started. I want to perform vectorization after train_test_split but when I do that, the resulting ...
  • 1,293
1 vote
1 answer
334 views

tf-idf for sentence level features

Many papers mention comparing sentences using the tf-idf metric, e.g. Paper. They state: The first one is based on tf-idf where the value of the the corresponding dimension in the vector ...
  • 113
1 vote
1 answer
241 views

How to match a corpus with a string of words using a TF-IDF matrix?

I am trying to match strings of words with a website that has bulletpoints whose text is most similar to it. The way I thought of doing it is to get all of the documents from each bulletpoint into one ...
  • 133
1 vote
0 answers
153 views

Hashing trick for dimensionality reduction

I am building a model that uses TF-IDF NLP features in Spark Mllib. The TF-IDF HashingTF function in Mllib uses the 'hashing trick' to efficiently allocate terms to features. My question is: does the ...
  • 11
3 votes
1 answer
186 views

How to apply TFIDF in structured dataset in Python?

I know that TFIDF is an NLP method for feature extraction. and I know that there are libraries that calculate TFIDF directly from the text. This is not what I want though In my case, my text dataset ...
  • 517
1 vote
0 answers
233 views

How does sklearn's tf-idf vectorizer pick the bigrams and trigrams?

...
1 vote
2 answers
595 views

How to decide to go with BOW or TFIDF

I know that there are methods that help in selecting features such as Matual Info, and Info Gain, etc. But for datasets with thousands of records and thousands of features it is time consuming to ...
  • 517
1 vote
0 answers
94 views

Matching documents from different sets with tfidf and cosine distance

I have two different set of documents S1, S2, with 30 text documents each. Using some text representation method, such as tfidf ...
1 vote
3 answers
708 views

How to create a big data frame in Python

I have a sparse matrix, $X$, created by TfidfVectorizer and its size is $(500000, 200000)$. I want to convert $X$ to a data frame but I'm always getting a memory error. I tried ...
's user avatar
1 vote
1 answer
27 views

Integer encoding and weighing when one feature consists of more names [closed]

Hello I am trying to make a content based movie recommendation system and one feature is genre of the movie. I will give an integer number to each genre randomly. However, some movies are of more than ...
  • 25
2 votes
1 answer
22 views

When does it make sense to add numbers with different units?

Given two vectors containing numbers that have different natures / units, (example length in Meters and weight in Kilograms), does it make sense to calculate euclidean distance between these two ...
1 vote
1 answer
63 views

Classification using texts as features

I want to build a classification model to match customers and products. I have a description of each product, and a description of each customer, and the label : ...
0 votes
2 answers
131 views

How to decide which method to use TFIDF, or BOW

In a huge dataset for NLP it is taking very long time to classify my dataset therefore, trying each feature extraction method separetly is time consuming and not effecient. Is there a way that can ...
  • 517
0 votes
2 answers
241 views

Why is the idf important in tf-idf when it seems to just re-scale your features?

I am trying to understand why tf-idf is useful. As I understand the formula to work out the tf-idf is: Can someone explain what is wrong with the reasoning below: Imagine I have 100 documents that ...
0 votes
0 answers
24 views

Which would be an ideal model to get a specific sub string from a bigger string?

I have a corpus of documents whose some lines have information like this: wt 210 1b 14.4 oz (98 kg) or ...