MaartenGr / MaartenGr/BERTopic

Saving predictions

Open
#1,776 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.8k
Forks
920
Avg merge
22h 24m
Merged PRs (30d)
5

Description

Hi Maarten, I tried applying the transform function after training a model. So, I train the model and afterwards, I load my whole dataframe and preprocess the texts to make the predictions:

df= pd.read_csv(file_path)
df = df.loc[df["Text_cleaned"].apply(lambda x: isinstance(x, str))]
df.dropna(subset=["Text_cleaned"], inplace=True)
df["Text_cleaned"] = df["Text_cleaned"].astype(str)
texts = df['Text_cleaned'].tolist()
topics, probs = topic_model.transform(texts)

How can I now store the results in my df and export it as a csv file again?

All the best and thank you very much
Nikola

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

This is a usage question about applying BERTopic's transform function to texts loaded with pandas and exporting the resulting dataframe; no repository file or test is named. Start by reviewing the transform usage and dataframe workflow shown in the issue. Done means providing a clear, verified usage explanation or documenting the workflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data, machine-learning
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.