Skip to main content

No project description provided

Project description

fastc

Installation

pip install fastc

Train a model

from fastc import SentenceClassifier

tuples = [
    ("I just got a promotion! Feeling fantastic.", 0),
    ("Today was terrible. I lost my wallet and missed the bus.", 1),
    ("I had a great time with my friends at the party.", 0),
    ("I'm so frustrated with the traffic jam this morning.", 1),
    ("My vacation was wonderful and relaxing.", 0),
    ("I didn't get any sleep last night because of the noise.", 1),
    ("I'm so excited for the concert tonight!", 0),
    ("I'm disappointed with the service at the restaurant.", 1),
    ("The weather is beautiful and I enjoyed my walk.", 0),
    ("I had a bad day. Nothing went right.", 1),
    ("I'm thrilled to announce that we are expecting a baby!", 0),
    ("I feel so lonely and sad today.", 1),
    ("My team won the championship! We are the champions.", 0),
    ("I can't stand my job anymore, it's so stressful.", 1),
    ("I love spending time with my family during the holidays.", 0),
    ("My computer crashed and I lost all my work.", 1),
    ("I'm proud of my achievements this year.", 0),
    ("I'm exhausted and overwhelmed with everything.", 0),
]

classifier = SentenceClassifier(embeddings_model='microsoft/deberta-base')
classifier.load_dataset(tuples)
classifier.train()

Export a model

classifier.save_model('./sentiment-classifier/')

Load an existing model

# From a directory
classifier = SentenceClassifier('./sentiment-classifier/')

# From HuggingFace
classifier = SentenceClassifier('brunneis/sentiment-classifier')

Prediction

sentences = [
    'I am feeling well.',
    'I am in pain.',
]

# Single prediction
probabilities = classifier.predict_one(sentences[0])
print('positive' if probabilities[0] > .5 else 'negative')

# Batch predictions
probabilities_list = classifier.predict(sentences)
for probabilities in probabilities_list:
    print('positive' if probabilities[0] > .5 else 'negative')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

fastc-1.2406.1-py3-none-any.whl (17.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page