Skip to content

Commit

Permalink
removed doc, example, and change name since risc is used on pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
davebulaval committed Apr 4, 2023
1 parent acd9792 commit 49ca164
Show file tree
Hide file tree
Showing 176 changed files with 223 additions and 190 deletions.
30 changes: 5 additions & 25 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Pull requests are the best way to propose changes to the codebase. We actively w

1. Fork the repo and create your branch from the **`dev` branch**.
2. If you've added code that should be tested, you **must** ensure it is properly tested.
3. If you've changed APIs, update the documentation.
3. If you've changed APIs, update the in-code documentation.
4. Ensure the CI/CD test suite passes.
5. Make sure your code lints.
6. Submit that pull request!
Expand Down Expand Up @@ -45,7 +45,7 @@ We use GitHub issues to track enhancement requests. Before you create an enhanc
* Make sure you have a clear idea of the enhancement you would like. If you have a vague idea, consider discussing
it first on the users list.

* Check the documentation to make sure your feature does not already exist.
* Check the in-code documentation to make sure your feature does not already exist.

* Do a [quick search](https://github.com/GRAAL-Research/risc/issues) to see whether your enhancement has already been suggested.

Expand All @@ -60,17 +60,16 @@ When creating your enhancement request, please:

## Prerequisites

We created three requirements files to install all the tools used for the development of the library. `tests/requirements.txt` define the requirements for the tests, `styling_requirements.txt` for the styling and `docs/requirements.txt` for the documentation.
We created three requirements files to install all the tools used for the development of the library. `tests/requirements.txt` define the requirements for the tests.

You can install all the requirements with

``` shell
pip install -r tests/requirements.txt
pip install -r styling_requirements.txt
pip install -r docs/requirements.txt
```

Also, you should run `python setup.py develop` to build the project and be able to build the documentation.
Also, you should run `python setup.py develop` to build the project.
``` shell
python setup.py develop
```
Expand Down Expand Up @@ -118,26 +117,7 @@ zsh -i run_tests_python_envs.sh # For ZSH terminal

## Documentation

When submitting a pull request for a new feature, try to include documentation for the new objects/modules introduced and their public methods.

All of RISC's html documentation is automatically generated from the Python files' documentation. To have a preview of what the final html will look like with your modifications, first start by rebuilding the html pages.

``` shell
cd docs
./rebuild_html_doc.sh
```

You can then see the local html files in your favorite browser. Here is an example using Firefox:

``` shell
firefox _build/html/index.html
```

or using Python

```shell
python -m http.server -d _build/html/
```
When submitting a pull request for a new feature, try to include in-code documentation for the new objects/modules introduced and their public methods.

## License
By contributing, you agree that your contributions will be licensed under its LGPLv3 License.
Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/deploy.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/docs.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
pip install -e .
- name: PyLint
run: |
pylint risc/ tests/ examples/
pylint risc/ tests/
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ dmypy.json
.idea
/datastore

risc/version.py
risc_generator/version.py
135 changes: 119 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,128 @@
"RISC, an open-source Python package data generator. RISC generates look-alike automobile "
"insurance contracts based on the Quebec regulatory insurance form in French and English."
<div align="center">

does not work in 3.11 due to SciPy
> > En Python 3.9
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/risc_generator)](https://pypi.org/project/RISCgen)
[![PyPI Status](https://badge.fury.io/py/risc_generator.svg)](https://badge.fury.io/py/risc)
[![PyPI Status](https://pepy.tech/badge/risc_generator)](https://pepy.tech/project/risc)
[![Downloads](https://pepy.tech/badge/risc_generator/month)](https://pepy.tech/project/risc)

[![Formatting](https://github.com/GRAAL-Research/risc/actions/workflows/formatting.yml/badge.svg?branch=stable)](https://github.com/GRAAL-Research/risc/actions/workflows/formatting.yml)
[![Linting](https://github.com/GRAAL-Research/risc/actions/workflows/linting.yml/badge.svg?branch=stable)](https://github.com/GRAAL-Research/risc/actions/workflows/linting.yml)
[![Tests](https://github.com/GRAAL-Research/risc/actions/workflows/tests.yml/badge.svg?branch=stable)](https://github.com/GRAAL-Research/risc/actions/workflows/tests.yml)

- Juste nouvelle affaires
- Pas de multiproduit
- Contrat de 12 mois
[![codecov](https://codecov.io/gh/GRAAL-Research/risc/branch/main/graph/badge.svg)](https://codecov.io/gh/GRAAL-Research/risc)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/62464699ff0740d0b8064227c4274b98)](https://www.codacy.com/gh/GRAAL-Research/risc/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=GRAAL-Research/risc&amp;utm_campaign=Badge_Grade)
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>

We have automatically/manually extracted the text of AMF contract.
We have removed the contract margin text (the insurance company logo on the left and the FPQ 1 policy number of type of policy).
We have cleaned remove all page reference as <PAGE_NUMBER>.
The text does not include page number.
[![pr welcome](https://img.shields.io/badge/PR-Welcome-%23FF8300.svg?)](https://img.shields.io/badge/PR-Welcome-%23FF8300.svg?)
[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](http://www.gnu.org/licenses/lgpl-3.0)
</div>

The simulated contract are new customer. Ca
## Here is RISC.

V1:
- Contrat juste avec un véhicule et un assuré
RISC is an open-source Python package data generator. It generates look-alike automobile insurance contracts based on
the Quebec regulatory insurance form in French and English.

V2:
- Contract avec plus d'un véhicule et un assuré
Use RISC to generate look-a-like Quebec Car insurance forms (FPQ1) both in French and English. RISC simulation is
deterministic; thus, it can generate an aligned insurance contract (i.e. same driver data) using an initial seed.
RISC uses a pretrained TVAE model on a private dataset to generate look-a-like car protections.
See our [article here]() for more detail about RISC implementation and generated dataset specification.

RISC was written in Python 3.9 and is compatible with the __latest version of PyTorch__ and
__Python >= 3.8__ (**SciPy seems difficult to build on Python 3.11. Thus, we don't support Python 3.11 for now).

## Getting Started:

```python
from risc_generator import TVAEFPQ1ContractFaker

seed = 42
n = 10

# Let's sample 10 insurance English insurance contracts (default configuration).
en_fpq1_synthetic_dataset = TVAEFPQ1ContractFaker(seed=seed).sample_contracts(number_sample=n)

# Now, let's do it for French contracts.
fr_fpq1_synthetic_dataset = TVAEFPQ1ContractFaker(language="fr", seed=seed).sample_contracts(number_sample=n)

# Since we have used the same seed, both datasets share the same insuree information.

# Use our own TVAE model:
fpq1_synthetic_dataset = TVAEFPQ1ContractFaker(tvae_synthetic_data_faker_model_path="a_path_to_a_tvae_.pkl",
language="fr", seed=seed).sample_contracts(number_sample=n)

# You can also create a new FPQ1ContractFaker using another type of model using our interface.

from risc_generator import FPQ1ContractFaker, ProtectionsFaker


class RuleBaseFPQ1ContractFaker(FPQ1ContractFaker):
def __init__(self, language: str = "en", seed: int = 42):
protection_faker = ProtectionsFaker(
model=ARuleBaseProtectionFaker()
)
super().__init__(protection_faker, language, seed=seed)
```




------------------

## Installation

Before installing RISC, you must have your environment's latest version of [PyTorch](https://pytorch.org/).

- **Install the stable version of RISC:**

```sh
pip install risc_generator
```

- **Install the latest development version of RISC:**

```sh
pip install -U git+https://github.com/GRAAL-Research/risc.git@dev
```

------------------

## Cite

Use the following for the article;

```
@misc{beaucheminrisc,
title={{RISC: Generating Realistic Synthetic Bilingual Insurance
Contract}},
author={David Beauchemin and Richard Khoury},
year={2023},
eprint={},
archivePrefix={arXiv}
}
```

and this one for the package;

```
@misc{risc,
author = {David Beauchemin},
title = {{RISC: an open-source Python package data generator to generate look-alike automobile insurance contracts based on the Quebec regulatory insurance form in French and English}},
year = {2023},
note = {\url{https://github.com/GRAAL-Research/risc}}
}
```

------------------

## Contributing to RISC

We welcome user input, whether it regards bugs found in the library or feature propositions! Make sure to have a
look at our [contributing guidelines](https://github.com/GRAAL-Research/risc/blob/main/.github/CONTRIBUTING.md)
for more details on this matter.

## License

RISC is LGPLv3 licensed, as found in
the [LICENSE file](https://github.com/GRAAL-Research/risc/blob/main/LICENSE).

------------------
17 changes: 0 additions & 17 deletions risc/faker/contract_faker/tvae_synthetic_fpq1_faker.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions risc_generator/faker/contract_faker/tvae_synthetic_fpq1_faker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
from typing import Union

from ...faker.contract_faker.contract_faker import FPQ1ContractFaker
from ...faker.protections_faker.protections_faker import ProtectionsFaker
from ...model.tvae_synthetic_protections_model_wrapper import TVAESyntheticProtectionsModelWrapper


class TVAEFPQ1ContractFaker(FPQ1ContractFaker):
def __init__(
self, tvae_synthetic_data_faker_model_path: Union[None, str] = None, language: str = "en", seed: int = 42
) -> None:
"""
A FPQ1 contract faker using a TVAE synthetic protections model to generate synthetic protections using CPU.
tvae_synthetic_data_faker_model_path (str): Path to a TVAE model (see `here
<https://docs.sdv.dev/sdv/single-table-data/modeling/synthesizers/tvaesynthesizer>`_
for details on TVAE model) if you want to use your. If None, we will
use our pre-trained model trained on a private dataset of a Canadian insurance company. By default,
`"None"`.
language (str): Either `'french'` (or `'fr'`) or `'english'` (or `'en'`). By default, `"en"`.
seed (int): The seed value to use for the generation seed. By default, 42.
"""
if tvae_synthetic_data_faker_model_path is None:
tvae_synthetic_data_faker_model_path = (
os.path.join(os.path.dirname(__file__), '../../resources', "tvae_model_q1_2023.pkl"),
)
protection_faker = ProtectionsFaker(
model=TVAESyntheticProtectionsModelWrapper(tvae_synthetic_data_faker_model_path)
)
super().__init__(protection_faker, language, seed=seed)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def main():

packages = find_packages()
setup(
name="RISC",
name="risc_generator",
version=version,
author="David Beauchemin",
author_email="david.beauchemin.5@ulaval.ca",
Expand Down
6 changes: 3 additions & 3 deletions tests/domain/contract/contract_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from unittest import TestCase
from unittest.mock import MagicMock

from risc import Protections, Premium
from risc.domain.insuree import Insuree
from risc.domain.vehicle import Vehicle
from risc_generator import Protections, Premium
from risc_generator.domain.insuree import Insuree
from risc_generator.domain.vehicle import Vehicle

INCLUDE = "include"
EXCLUDE = "exclude"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from risc.content import fr, en
from risc_generator.content import fr, en
from tests.domain.contract.contract_base import ContractTestBase

INCLUDE = "include"
Expand Down
4 changes: 2 additions & 2 deletions tests/domain/contract/declaration/test_declaration_header.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from risc import FPQ1Contract, Protections, Premium
from risc.content import fr, en
from risc_generator import FPQ1Contract, Protections, Premium
from risc_generator.content import fr, en
from tests.domain.contract.contract_base import ContractTestBase


Expand Down
4 changes: 2 additions & 2 deletions tests/domain/contract/declaration/test_declaration_item_1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from risc import Protections, FPQ1Contract, Premium
from risc.content import fr, en
from risc_generator import Protections, FPQ1Contract, Premium
from risc_generator.content import fr, en
from tests.domain.contract.contract_base import ContractTestBase

INCLUDE = "include"
Expand Down
4 changes: 2 additions & 2 deletions tests/domain/contract/declaration/test_declaration_item_2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from risc import Protections, FPQ1Contract, Premium
from risc.content import fr, en
from risc_generator import Protections, FPQ1Contract, Premium
from risc_generator.content import fr, en
from tests.domain.contract.contract_base import ContractTestBase

INCLUDE = "include"
Expand Down

0 comments on commit 49ca164

Please sign in to comment.