|
| 1 | +# Text Classification with Classifier |
| 2 | + |
| 3 | +Use when: User asks to classify text, detect spam, analyze sentiment, detect emotions, or use pre-trained ML models. |
| 4 | + |
| 5 | +## Pre-trained Models |
| 6 | + |
| 7 | +Run `classifier models` to see all available models. Common ones: |
| 8 | + |
| 9 | +| Model | Command | Use Case | |
| 10 | +|-------|---------|----------| |
| 11 | +| `sms-spam-filter` | `classifier -r sms-spam-filter "text"` | Spam detection | |
| 12 | +| `imdb-sentiment` | `classifier -r imdb-sentiment "text"` | Sentiment analysis | |
| 13 | +| `emotion-detection` | `classifier -r emotion-detection "text"` | Emotion classification | |
| 14 | + |
| 15 | +## Quick Classification |
| 16 | + |
| 17 | +```bash |
| 18 | +# Classify with a pre-trained model |
| 19 | +classifier -r <model-name> "text to classify" |
| 20 | + |
| 21 | +# Example: detect spam |
| 22 | +classifier -r sms-spam-filter "You won a free iPhone! Click here now!" |
| 23 | + |
| 24 | +# Example: sentiment analysis |
| 25 | +classifier -r imdb-sentiment "This movie was absolutely terrible" |
| 26 | + |
| 27 | +# Example: emotion detection |
| 28 | +classifier -r emotion-detection "I am so happy today" |
| 29 | +``` |
| 30 | + |
| 31 | +## Custom Training |
| 32 | + |
| 33 | +```bash |
| 34 | +# Train from text |
| 35 | +classifier train positive "Great product, love it" |
| 36 | +classifier train negative "Terrible quality, waste of money" |
| 37 | + |
| 38 | +# Train from files |
| 39 | +classifier train positive reviews/good/*.txt |
| 40 | +classifier train negative reviews/bad/*.txt |
| 41 | + |
| 42 | +# Classify after training |
| 43 | +classifier "This product exceeded my expectations" |
| 44 | +``` |
| 45 | + |
| 46 | +## Model Management |
| 47 | + |
| 48 | +```bash |
| 49 | +# List all available models |
| 50 | +classifier models |
| 51 | + |
| 52 | +# Show model details |
| 53 | +classifier info <model-name> |
| 54 | + |
| 55 | +# Save trained model |
| 56 | +classifier save my-model.json |
| 57 | + |
| 58 | +# Load saved model |
| 59 | +classifier load my-model.json |
| 60 | +``` |
| 61 | + |
| 62 | +## Best Practices |
| 63 | + |
| 64 | +1. For quick classification tasks, use pre-trained models first |
| 65 | +2. For custom domains, train with representative examples from each category |
| 66 | +3. Use `classifier models` to discover available pre-trained models |
| 67 | +4. Balance training data across categories for best results |
0 commit comments