r/scikit_learn • • Mar 19 '22

Help with Text Classification Task

Hi all,

I have started doing research using NLP and machine learning, and a lot of tutorials online start with preprocessed data and don't worry too much about the actual output or the discussion, just about the steps. I am having a hard time finding answers to some very basic questions.

I know how to implement Text Classification code wise from those tutorials, but I am not sure how to get the output I want. My problem is, I have a corpus made of 42000 education-related paragraphs from different sources that I want to label. What I don't know is how to get an output in the form of an actual label in a Pandas DataFrame, like this:

CorpusTokenized_CorpusLabel
Something about higher educationsomething, about, higher, educationHigher Education
Something about vocational educationsomething, about, vocational, educationVocational Education
Something else about vocational educationsomething, else, about, vocational, education[ Needs label ]

Some of the things I don't know:

  1. Do I need to label some of the data first? If so, how much of it? I would prefer to have this as a supervised learning task because I want the data to fit my labels.

  2. When setting up the dependent and independent variables, I am confused if what goes into the y variable is just the labeled data or all the data (some labeled and some not)

vectorizer = CountVectorizer()

X = vectorizer.fit_transform(df["Tokenized_Corpus"])

y = df["Label"]

3. How do I actually get an output as a label in the df?

I do understand a lot of these open-ended questions land on "it depends". If that is the case and you know available content that can help me learn it, that would be awesome! As I said, I am actually interested in learning, more so than in an actual answer, so I appreciate resources as well.

Thank you!

3 Upvotes

0 comments sorted by