Metadata-Version: 2.4
Name: morai
Version: 0.2.0
Summary: A mortality viewer
Author-email: John Koestner <johnkoestner@outlook.com>
License: The MIT License (MIT)
        
        Copyright (c) 2023 John Koestner
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: homepage, https://github.com/jkoestner/morai
Project-URL: repository, https://github.com/jkoestner/morai
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: arrow>=1.3.0
Requires-Dist: colorama>=0.4.6
Requires-Dist: fastexcel>=0.14.0
Requires-Dist: ipywidgets>=8.1.5
Requires-Dist: jupyterlab>=4.4.3
Requires-Dist: numpy>=1.26.4
Requires-Dist: openpyxl>=3.1.5
Requires-Dist: pandas>=2.3.0
Requires-Dist: plotly>=6.1.2
Requires-Dist: polars>=1.30.0
Requires-Dist: pyarrow>=20.0.0
Requires-Dist: pymort>=2.0.1
Requires-Dist: scikit-learn>=1.7.0
Requires-Dist: seaborn>=0.13.2
Requires-Dist: shap>=0.47.2
Requires-Dist: statsmodels>=0.14.4
Requires-Dist: tqdm>=4.67.1
Requires-Dist: dash>=3.0.4
Requires-Dist: dash-ag-grid>=31.3.1
Requires-Dist: dash-bootstrap-components>=2.0.3
Requires-Dist: dash-extensions>=2.0.4
Requires-Dist: gunicorn>=23.0.0
Requires-Dist: catboost>=1.2.8
Requires-Dist: graphviz>=0.20.3
Requires-Dist: lightgbm>=4.6.0
Requires-Dist: pygam>=0.9.1
Requires-Dist: xgboost>=3.0.2
Provides-Extra: dev
Requires-Dist: black>=25.1.0; extra == "dev"
Requires-Dist: isort>=6.0.1; extra == "dev"
Requires-Dist: jupyterlab-code-formatter>=3.0.2; extra == "dev"
Requires-Dist: jupyter-resource-usage>=1.1.1; extra == "dev"
Requires-Dist: pytest>=8.3.5; extra == "dev"
Requires-Dist: pytest-cov>=6.0.0; extra == "dev"
Requires-Dist: ruff>=0.11.0; extra == "dev"
Requires-Dist: sphinx<7.2,>=6.0; extra == "dev"
Requires-Dist: sphinx_rtd_theme>=3.0.2; extra == "dev"
Provides-Extra: ai-adv
Requires-Dist: h2o>=3.46.0; extra == "ai-adv"
Requires-Dist: pytorch>=2.0.1; extra == "ai-adv"
Provides-Extra: r
Requires-Dist: rpy2>=3.5.17; extra == "r"
Dynamic: license-file


<div align="center">
  <img src="morai/dashboard/assets/morai_logo.png"><br>
</div>

# Morai
![workflow badge](https://github.com/jkoestner/morai/actions/workflows/test-and-deploy.yml/badge.svg)
[![license badge](https://img.shields.io/github/license/jkoestner/morai)](https://github.com/jkoestner/morai/blob/main/LICENSE.md)
[![codecov](https://codecov.io/gh/jkoestner/morai/branch/main/graph/badge.svg?token=386HHBN1AK)](https://codecov.io/gh/jkoestner/morai)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

## Table of Contents
- [Morai](#morai)
  - [Table of Contents](#table-of-contents)
  - [Overview](#overview)
  - [Installation](#installation)
    - [Local Install](#local-install)
    - [Docker Install](#docker-install)
  - [Usage](#usage)
    - [CLI](#cli)
  - [Other Tools](#other-tools)
    - [Jupyter Lab Usage](#jupyter-lab-usage)
    - [Logging](#logging)
    - [Coverage](#coverage)

## Overview

**📖 Description:**

[Moirai](https://en.wikipedia.org/wiki/Moirai#:~:text=In%20ancient%20Greek%20religion%20and,Moirai) 
in greek mythology are known as the fates. They are personifications of destiny.
The name Morai was chosen as the package is designed to help actuaries review 
mortality and experience data.

**🔬 Jupyter Notebook:**

- [Data Process](https://nbviewer.org/github/jkoestner/morai/blob/main/notebooks/01.data_process.ipynb)
- [Exploratory](https://nbviewer.org/github/jkoestner/morai/blob/main/notebooks/02.exploratory.ipynb)
- [Predictive Models](https://nbviewer.org/github/jkoestner/morai/blob/main/notebooks/06.predictive_model.ipynb)
- And Others

**📊 Dashboard:**

- [Dashboard](https://morai.koestner.fun)
- Data Overview: ![dash_data_input](docs/screenshots/morai_data.gif)
- Data Tables: ![dash_data_tables](docs/screenshots/morai_tables.gif)
- Data CDC: ![dash_cdc](docs/screenshots/morai_cdc.gif)

## Installation

### Local Install
To install, this repository can be installed by running the following command in 
the environment of choice.

The following command can be run to install the packages in the pyproject.toml file.

```
uv pip install -e .
```

### Docker Install
The package can also be run in docker which provides a containerized environment, and can host the web dashboard.

```bash
version: "3.8"
services:
  morai:
    image: dmbymdt/morai:latest
    container_name: morai
    command: gunicorn -b 0.0.0.0:8001 morai.dashboard.app:server
    restart: unless-stopped
    environment:
      MORAI_FILES_PATH: /code/morai/files # setting the files path for morai
    ports:
      - '8001:8001'
    volumes:
      - $DOCKERDIR/morai/files:/code/morai/files # mounting the files directory
```

## Usage

### CLI

CLI can be used for easier commands of python scripts for both portfolio or manager. An example of a CLI command is shown below. When running the dashboard the `MORAI_FILES_PATH` environment variable needs to be set to the directory where the files are stored.

```commandline
morai dashboard
```

It also can be run locally by going to the dashboard folder and running below.

```python
python -m morai.dashboard.app
```

## Other Tools
### Jupyter Lab Usage

To have conda environments work with Jupyter Notebooks a kernel needs to be defined. This can be done defining a kernel, shown below when
in the conda environment.

```
python -m ipykernel install --user --name=morai
```

If plotly images are not showing in the default set up there may need to be some extensions added to JupyterLab.
The extension particularly needed is the jupyterlab-plotly extension.
This is also discussed more in this issue: [Plotly Issue](https://github.com/plotly/plotly.py/issues/2672)

### Logging

If wanting to get more detail in output of messages the logging can increased
```python
from morai.utils import custom_logger
custom_logger.set_log_level("DEBUG")
```

### Coverage

To see the test coverage the following command is run in the root directory.
```
pytest --cov=morai --cov-report=html
```
