Skip to content
Open
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
23 changes: 12 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('../src'))

sys.path.insert(0, os.path.abspath("../src"))
print(sys.path[0])
sys.setrecursionlimit(1500)


# -- Project information -----------------------------------------------------

project = 'tryangle'
copyright = '2021, Caesar Balona & Ronald Richman'
author = 'Caesar Balona & Ronald Richman'
project = "tryangle"
copyright = "2021, Caesar Balona & Ronald Richman"
author = "Caesar Balona & Ronald Richman"


# -- General configuration ---------------------------------------------------
Expand All @@ -30,29 +31,29 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.autosummary',
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.autosummary",
]
autosummary_generate = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
1 change: 1 addition & 0 deletions examples/plot_auto_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Finds optimal weights to combine chainladder and bornhuetter
ferguson methods to reduce prediction error.
"""

from tryangle.model_selection import TriangleSplit
from tryangle.utils.datasets import load_sample
from tryangle.ensemble import AutoEnsemble, Adam
Expand Down
1 change: 1 addition & 0 deletions examples/plot_gridsearch_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Since selecting development factors is a transformation,
it can be pipelined with an estimator
"""

from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import Pipeline
from tryangle import Development, CapeCod
Expand Down
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ classifiers = [
"Topic :: Office/Business :: Financial",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
dependencies = ["chainladder<=0.8.14", "pandas<2.0", "scikit-learn>=1.2"]
dependencies = [
"chainladder>=0.8,<=0.8.24"
]
license = { text = "MPL-2.0" }
requires-python = ">=3.11"
requires-python = ">=3.9"

[project.urls]
Homepage = "https://github.com/casact/tryangle"

[project.optional-dependencies]
dev = ["ruff", "black", "mypy", "pytest", "tox", "twine"]

dev = ["ruff", "black", "mypy", "pytest", "tox", "twine", "tox-uv"]
2 changes: 1 addition & 1 deletion src/tryangle/ensemble/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def preprocess(self, X, y=None, sample_weight=None):
clone(clf),
X,
X,
sample_weight=None,
fit_params={},
message_clsname=f"Preprocessing - {names[idx]}_expected",
message=self._log_message(names[idx], idx + 1, len(clfs)),
),
Expand Down
11 changes: 7 additions & 4 deletions src/tryangle/metrics/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

import numpy as np
from sklearn.metrics import mean_squared_error
from sklearn.metrics._scorer import _BaseScorer

from tryangle.metrics.base import get_actual_expected

from sklearn.metrics._scorer import _BaseScorer
from sklearn.metrics import mean_squared_error


class AVEScore(_BaseScorer):
"""Base AvE scoring class"""
Expand All @@ -17,9 +16,13 @@ def __init__(
self,
score_func=mean_squared_error,
sign=-1,
kwargs={"squared": False},
kwargs=None,
weighted=False,
):

if kwargs is None:
kwargs = {}

self.weighted = weighted
super().__init__(score_func, sign, kwargs)

Expand Down
6 changes: 3 additions & 3 deletions src/tryangle/utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def load_sample(key, *args, **kwargs):
columns=columns,
cumulative=True,
*args,
**kwargs
**kwargs,
)
sample_weight = Triangle(
sample_weight,
Expand All @@ -46,7 +46,7 @@ def load_sample(key, *args, **kwargs):
columns=["premium"],
cumulative=True,
*args,
**kwargs
**kwargs,
).latest_diagonal

return TryangleData(claim, sample_weight)
Expand All @@ -73,7 +73,7 @@ def load_test_sample(key, *args, **kwargs):
columns=["claim"],
cumulative=True,
*args,
**kwargs
**kwargs,
)

if key.lower() in ["swiss"]:
Expand Down
5 changes: 3 additions & 2 deletions tests/test_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

import os
from distutils import dir_util
import shutil

import numpy as np
import pytest
from chainladder.utils import load_sample

from tryangle.core.base import TryangleData
from tryangle.core.methods import BornhuetterFerguson, CapeCod, Chainladder
from tryangle.ensemble.base import AutoEnsemble
Expand Down Expand Up @@ -46,7 +47,7 @@ def data_dir(tmpdir, request):
test_dir, _ = os.path.splitext(filename)

if os.path.isdir(test_dir):
dir_util.copy_tree(test_dir, str(tmpdir))
shutil.copytree(test_dir, str(tmpdir), dirs_exist_ok=True)

return tmpdir

Expand Down
36 changes: 33 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
[tox]
envlist = {py3.9.17, py3.10.12, py3.11.4}-chainladder{0.8.14}
envlist = py3.{9-13}-chainladder0.8.{24, 23, 22, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}

[testenv]
# install pytest in the virtualenv where commands will be executed
deps =
pytest
chainladder0.8.14: chainladder==0.8.14
sparse<0.16
commands =
# NOTE: you can run any command line tool here - not just tests
pytest
pytest {posargs:tests}

[testenv:chainladder]
description = run tests with multiple versions
deps =
0.8.24: chainladder==0.8.24
0.8.23: chainladder==0.8.23
0.8.22: chainladder==0.8.22
0.8.20: chainladder==0.8.20
0.8.19: chainladder==0.8.19
0.8.18: chainladder==0.8.18
0.8.17: chainladder==0.8.17
0.8.16: chainladder==0.8.16
0.8.15: chainladder==0.8.15
0.8.14: chainladder==0.8.14
0.8.13: chainladder==0.8.13
0.8.12: chainladder==0.8.12
0.8.11: chainladder==0.8.11
0.8.10: chainladder==0.8.10
0.8.9: chainladder==0.8.9
0.8.8: chainladder==0.8.8
0.8.7: chainladder==0.8.7
0.8.6: chainladder==0.8.6
0.8.5: chainladder==0.8.5
0.8.4: chainladder==0.8.4
0.8.3: chainladder==0.8.3
0.8.2: chainladder==0.8.2
0.8.1: chainladder==0.8.1
0.8.0: chainladder==0.8.0
commands =
pytest {posargs:tests}