Skip to content

Instantly share code, notes, and snippets.

@fclesio
Created April 21, 2021 21:47
Show Gist options
  • Save fclesio/b23a085fbaf3bbcd6abf35c63532afad to your computer and use it in GitHub Desktop.
Save fclesio/b23a085fbaf3bbcd6abf35c63532afad to your computer and use it in GitHub Desktop.
Pandas to Fasttext
import pandas as pd
import fasttext
df = pd.read_csv('B2W-Reviews01.csv', sep=';')
df['label'] = '__label__' + df['site_category_lv1']
df = df.sample(n=10000)
df[['label', 'review_text']].to_csv('gfjakhsdgkfjhgsd.txt', index=None, header=None)
model = fasttext.train_supervised(input="gfjakhsdgkfjhgsd.txt", epoch=1)
model.predict('Copo Acrílico Com Canudo 500ml Rocie', k=5)
model.save_model('model.bin')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment