semvec/pypi-packages huggingface dataset:
episcanner 0.1.0
Dashboard quickstart template
License: MIT
Requires Python: >=3.10,<4.0

# Dengue Epi-Scanner App

H2O Wave application that uses up-to-date dengue incidence data from Infodengue, to analyze Dengue's expansion wave in
the south of Brazil.

[![watch the video](https://img.youtube.com/vi/LQmMhVWVJUs/hqdefault.jpg)](https://youtu.be/LQmMhVWVJUs)

### Run with miniforge environment:

**Pre-requisites**
* [Miniforge](https://github.com/conda-forge/miniforge) installed

 ```bash
 # Installing dependencies and activating the conda environment
$ mamba env create -f conda/env-base.yaml
$ conda activate episcanner 
$ poetry install
```

```bash
# Then in the terminal, start the app
$ wave run --no-reload --no-autostart epi_scanner.app
```

### Running with docker-compose

**Pre-requisites**
* Docker installed and running
* docker-compose installed
* [Miniforge](https://github.com/conda-forge/miniforge) installed

Using docker compose makes it a little easier to build and run the app.

```bash
# Build image
$ make docker-build

# Start container
$ make docker-start

# Stop and remove network and all containers
$ make docker-stop
```

*You can open the app at http://localhost:10101/*

### To update data for states or municipalities

```
# Run:

$ python scripts/create_data_parquet.py RJ dengue
> epi_scanner/data/RJ_dengue.parquet
```
focal-loss-torch 0.1.2
Simple pytorch implementation of focal loss
License: MIT

# focal_loss_torch
Simple pytorch implementation of focal loss introduced by Lin et al [[1]](#1).

## Usage
Install the package using pip
```bash
pip install focal_loss_torch
```

Focal loss is now accessible in your pytorch environment:
```python
from focal_loss.focal_loss import FocalLoss

# Withoout class weights
criterion = FocalLoss(gamma=0.7)

# with weights 
# The weights parameter is similar to the alpha value mentioned in the paper
weights = torch.FloatTensor([2, 3.2, 0.7])
criterion = FocalLoss(gamma=0.7, weights=weights)

# to ignore index 
criterion = FocalLoss(gamma=0.7, ignore_index=0)

# To make it behaves as CrossEntropy loss
criterion = FocalLoss(gamma=0)
```

### Examples
For Binary-classification
```python
batch_size = 10
m = torch.nn.Sigmoid()
logits = torch.randn(batch_size)
target = torch.randint(0, 2, size=(batch_size,))
loss = criterion(m(logits), target)
```

For Multi-Class classification
```python
batch_size = 10
n_class = 5
m = torch.nn.Softmax(dim=-1)
logits = torch.randn(batch_size, n_class)
target = torch.randint(0, n_class, size=(batch_size,))
criterion(m(logits), target)
```

For Multi-Class Sequence classification
```python
batch_size = 10
max_length = 20
n_class = 5
m = torch.nn.Softmax(dim=-1)
logits = torch.randn(batch_size, max_length, n_class)
target = torch.randint(0, n_class, size=(batch_size, max_length))
criterion(m(logits), target)
```


## Contributions
Contributions, criticism or corrections are always welcome. 
Just send me a pull request!

## References 
<a id="1">[1]</a> 
Lin, T. Y., et al.
"Focal loss for dense object detection."
arXiv 2017." arXiv preprint arXiv:1708.02002 (2002).