[Python] How to oversample the review text data in a sentiment classification dataset using...

Discussão em 'Python' iniciado por Stack, Junho 16, 2025.

  1. Stack

    Stack Membro Participativo

    My dataset contains 2 columns. ['reviewtext'] which contains textual data(paragraphs), and ['rating']. The ['rating'] column has 5 unique values (1, 2, 3, 4, 5). However the values are unbalanced(

    5 3000
    4 3000
    3 2000
    2 2000
    1 2000


    These are the value counts) In order to oversample the data to balance these ratings, I have to oversample the text column as well. How do I oversample the text data using SMOTE or any other method?

    When I use SMOTE to oversample, it expects numerical data. So I tried vectorizing text before applying SMOTE. But the vectorized data is a sparse matrix formed from the entire dataset, and I cannot individually vectorize each individual entry separately. But in order to oversample, I need individual entries in the ['reviewtext'] column to be in vector form. How do I achieve this? Or is there another way I can vectorize individual text entries? Or is there a way to oversample the data without vectorizing the text data?

    Continue reading...

Compartilhe esta Página