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
0 votes
0 answers
25 views

Can BM25 be used as an embedding algorithm?

I'v studied about BM25 algorithm. Untill now, I couldn't find an implementation of BM25 to give me an embedding of a text like TfidfTransformer and ...
0 votes
0 answers
11 views

Clustering methods for text and image features

I want to build a recommender system with unlabeled data and used TF-IDF to extract text features from a given short description and VGG-16 to extract image features. I am looking for a way to combine ...
  • 1
0 votes
0 answers
23 views

What is the difference between nmf.fit() nmf.fit_transform() in a easy way?

I am reading several questions on this topic. It seems quite clear to me for TFIDF why we have .fit_transform() and .transform() ...
0 votes
1 answer
58 views

how to evaluate the combination of tfidf and kmeans

For my nlp problem I'm using a combination of TFIDF and KMeans from the sklearn package. The tfidf gets the vectors and then I use Kmeans to cluster the texts based on the vectors. I have a few ...
  • 167
2 votes
2 answers
55 views

In sklearn tfidf what is the difference between term frequecy and document frequency

Looking at the sklearn tfidf page: https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.TfidfVectorizer.html and trying to understand the difference between term frequency ...
  • 167
0 votes
1 answer
73 views

how do you get the frequency of the terms generated by tfidf.get_feature_names_out()

After fitting with tfidf, I'm looking at the features that were generated: ...
  • 167
1 vote
1 answer
65 views

Do Sampling before or after TFIDF step?

This is a multiclass text classification problem. The dataset has a class imbalance and I'm planning to use a sampling technique before modeling. Should the sampling be done before/after the ...
0 votes
0 answers
15 views

Help using Bm25 to rank sentences

I'm starting to study how to rank words/sents and after using PageRank im advancing to bm25 using this tutorial enter link description here . I have a question regarding the query part. Is it possible ...
0 votes
0 answers
16 views

- Models to rank sentences

I am working with tasks made by some occupations and am trying to find out the importance of these tasks within the occupation. My solution was to use tf-idf and then text rank and use word2vec and ...
3 votes
1 answer
252 views

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

I have the following code: ...
  • 167
1 vote
1 answer
42 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 ...
  • 167
1 vote
0 answers
77 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
26 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
58 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
50 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
33 views

Is there a tokenizer to tokenize Swift language code in python

...
0 votes
0 answers
58 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
35 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 ...
  • 227
0 votes
0 answers
10 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
35 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
22 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
3k 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
33 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
1k 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
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
170 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 ...
3 votes
1 answer
1k 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 ...
  • 57
0 votes
0 answers
37 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 ...
2 votes
1 answer
173 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
2k 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
2 answers
34 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,321
1 vote
0 answers
227 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
43 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
169 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
1k 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
463 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
1k 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
375 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
230 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,321
1 vote
1 answer
603 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
315 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
2 votes
0 answers
233 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 ...
  • 21
3 votes
1 answer
264 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
313 views

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

...
1 vote
2 answers
930 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
115 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 ...
  • 113
1 vote
3 answers
819 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 ...
user avatar
1 vote
1 answer
28 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
72 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 : ...