weecology / weecology/DeepForest
Weighted Random Sampler for Multi-class detection
Open
Nobody has claimed this yet.
Feature Request
Ideas for Machine Learning!
- Dominant language
- Python
- Stars
- 774
- Forks
- 265
- PR merge metrics
- No merged PRs in 30d
Description
The vast majority of ecological data are imbalanced. We should have some default weighted random sampler options
from torch.utils.data import WeightedRandomSampler
from deepforest import main
m = main.deepforest()
[setup and load data]
dataset = m.train_ds
# Assuming 'dataset' is your PyTorch Dataset object
class_counts = [0] * len(dataset.classes)
for _, label in dataset:
class_counts[label] += 1
class_weights = 1. / torch.tensor(class_counts, dtype=torch.float)
sample_weights = [class_weights[label] for _, label in dataset]
sampler = WeightedRandomSampler(sample_weights, len(dataset))
and would get synced up through load dataset
and into the dataloader object
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in deepforest/main.py around the dataloader at line 270 and dataset loading at line 289, then trace how the training dataset reaches the loader. Determine how default weighted-random-sampler options should be configured and synchronized through dataset loading. Done means multi-class training can use the requested sampler through the dataloader.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100