Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A simple binary sentiment classification example that covers:
**Run the example:**
```bash
cd examples
uv run python basic_classification.py
uv run --extra huggingface python basic_classification.py
```

**What you'll learn:**
Expand All @@ -34,7 +34,7 @@ Demonstrates 3-class sentiment analysis (positive, negative, neutral):
**Run the example:**
```bash
cd examples
uv run python multiclass_classification.py
uv run --extra huggingface python multiclass_classification.py
```

**What you'll learn:**
Expand All @@ -53,7 +53,7 @@ Shows how to combine text and categorical features:
**Run the example:**
```bash
cd examples
uv run python Using_additional_features.py
uv run --extra huggingface python Using_additional_features.py
```

**What you'll learn:**
Expand All @@ -72,7 +72,7 @@ Explores advanced training configurations:
**Run the example:**
```bash
cd examples
uv run python advanced_training.py
uv run --extra huggingface python advanced_training.py
```

**What you'll learn:**
Expand All @@ -93,10 +93,10 @@ Demonstrates model explainability with ASCII histogram visualizations:
```bash
cd examples
# Regular mode - analyze predefined examples
uv run python simple_explainability_example.py
uv run --extra huggingface python simple_explainability_example.py

# Interactive mode - analyze your own text
uv run python simple_explainability_example.py --interactive
uv run --extra huggingface python simple_explainability_example.py --interactive
```

**What you'll learn:**
Expand All @@ -111,19 +111,19 @@ uv run python simple_explainability_example.py --interactive
To run any example:

1. **Install dependencies:**
```bash
uv sync
```
```bash
uv sync
```

2. **Navigate to examples directory:**
```bash
cd examples
```
```bash
cd examples
```

3. **Run an example:**
```bash
uv run python basic_classification.py
```
```bash
uv --extra huggingface run python basic_classification.py
```

## 📊 Example Outputs

Expand Down
14 changes: 8 additions & 6 deletions examples/advanced_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ def main():
)

classifier.train(
X_train, y_train, X_val, y_val,
X_train, y_train,
training_config=training_config,
X_val=X_val, y_val=y_val,
verbose=True
)

Expand Down Expand Up @@ -172,13 +173,13 @@ def main():
lr=1e-3,
patience_early_stopping=7,
num_workers=0,
cpu_run=False, # Don't override accelerator from trainer_params
trainer_params=advanced_trainer_params
)

advanced_classifier.train(
X_train, y_train, X_val, y_val,
X_train, y_train,
training_config=advanced_training_config,
X_val=X_val, y_val=y_val,
verbose=True
)

Expand Down Expand Up @@ -206,14 +207,14 @@ def main():
batch_size=16, # Larger batch size for CPU
lr=1e-3,
patience_early_stopping=3,
cpu_run=False, # Don't override accelerator from trainer_params
num_workers=0, # No multiprocessing for CPU
trainer_params={'deterministic': True, 'accelerator': 'cpu'}
)

cpu_classifier.train(
X_train, y_train, X_val, y_val,
X_train, y_train,
training_config=cpu_training_config,
X_val=X_val, y_val=y_val,
verbose=True
)

Expand Down Expand Up @@ -257,8 +258,9 @@ def main():
)

custom_classifier.train(
X_train, y_train, X_val, y_val,
X_train, y_train,
training_config=custom_training_config,
X_val=X_val, y_val=y_val,
verbose=True
)

Expand Down
3 changes: 2 additions & 1 deletion examples/basic_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ def main():
num_workers=0, # Use 0 for simple examples to avoid multiprocessing issues
)
classifier.train(
X_train, y_train, X_val, y_val,
X_train, y_train,
training_config=training_config,
X_val=X_val, y_val=y_val,
verbose=True
)
print("✅ Training completed!")
Expand Down
3 changes: 2 additions & 1 deletion examples/multiclass_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ def main():
trainer_params={'deterministic': True}
)
classifier.train(
X_train, y_train, X_val, y_val,
X_train, y_train,
training_config=training_config,
X_val=X_val, y_val=y_val,
verbose=True
)
print("✅ Training completed!")
Expand Down
3 changes: 2 additions & 1 deletion examples/simple_explainability_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ def main():
trainer_params={'deterministic': True}
)
classifier.train(
X_train, y_train, X_val, y_val,
X_train, y_train,
training_config=training_config,
X_val=X_val, y_val=y_val,
verbose=True
)
print("✅ Training completed!")
Expand Down
3 changes: 2 additions & 1 deletion examples/using_additional_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ def train_and_evaluate_model(X, y, model_name, use_categorical=False, use_simple
# Train model
print(" 🎯 Training model...")
classifier.train(
X_train, y_train, X_val, y_val,
X_train, y_train,
training_config=training_config,
X_val=X_val, y_val=y_val,
verbose=True
)
training_time = time.time() - start_time
Expand Down