Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
John Bogaardt committed Jan 30, 2020
2 parents 3219732 + 73cc2af commit 79a86c2
Show file tree
Hide file tree
Showing 16 changed files with 13,462 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,6 @@ ENV/
# references
references/

settings.json
settings.json

*.pkl
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# chainladder (python)
[![PyPI version](https://badge.fury.io/py/chainladder.svg)](https://badge.fury.io/py/chainladder)
![Build Status](https://github.com/casact/chainladder-python/workflows/Unit%20Tests/badge.svg)
[![Documentation Status](https://readthedocs.org/projects/chainladder-python/badge/?version=master)](http://chainladder-python.readthedocs.io/en/latest/?badge=master)
[![Documentation Status](https://readthedocs.org/projects/chainladder-python/badge/?version=latest)](http://chainladder-python.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/jbogaardt/chainladder-python/branch/master/graph/badge.svg)](https://codecov.io/gh/jbogaardt/chainladder-python)

## chainladder - Property and Casualty Loss Reserving in Python
Expand All @@ -17,6 +17,13 @@ another API.
Please visit the [Documentation](https://chainladder-python.readthedocs.io/en/latest/) page for examples, how-tos, and source
code documentation.

## Tutorials
Tutorial notebooks are available for download [here](https://github.com/casact/chainladder-python/tree/master/docs/tutorials).
* [Working with Triangles](https://chainladder-python.readthedocs.io/en/latest/tutorials/triangle-tutorial.html)
* [Selecting Development Patterns](https://chainladder-python.readthedocs.io/en/latest/tutorials/development-tutorial.html)
* [Extending Development Patterns with Tails](https://chainladder-python.readthedocs.io/en/latest/tutorials/tail-tutorial.html)
* [Applying Deterministic Methods](https://chainladder-python.readthedocs.io/en/latest/tutorials/deterministic-tutorial.html)

## Have a question?
Feel free to reach out on [Gitter](https://gitter.im/chainladder-python/community).

Expand Down
2 changes: 1 addition & 1 deletion chainladder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
from chainladder.methods import * # noqa (API Import)
from chainladder.workflow import * # noqa (API Import)

__version__ = '0.4.7'
__version__ = '0.4.8'
5 changes: 5 additions & 0 deletions chainladder/core/dunders.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ def __neg__(self):
def __pos__(self):
return self

def __abs__(self):
obj = copy.deepcopy(self)
obj.values = abs(obj.values)
return obj

def __mul__(self, other):
obj, other = self._validate_arithmetic(other)
obj.values = np.nan_to_num(obj.values)*other
Expand Down
8 changes: 7 additions & 1 deletion chainladder/development/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Development(DevelopmentBase):
Sigma of the ldf regression
std_err_ : Triangle
Std_err of the ldf regression
w_ : Triangle
weight_ : pandas.DataFrame
The weight used in the ldf regression
"""
Expand All @@ -73,6 +73,12 @@ def __init__(self, n_periods=-1, average='volume',
self.drop_valuation = drop_valuation
self.drop = drop

@property
def weight_(self):
return pd.DataFrame(
self.w_[0, 0], index=self.ldf_.origin,
columns=list(self.ldf_.development.values[:,0]))

def _assign_n_periods_weight(self, X):
if type(self.n_periods) is int:
return self._assign_n_periods_weight_int(X, self.n_periods)[..., :-1]
Expand Down
1 change: 0 additions & 1 deletion chainladder/methods/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
from chainladder.methods.benktander import Benktander # noqa (API import)
from chainladder.methods.bornferg import BornhuetterFerguson # noqa (API import)
from chainladder.methods.capecod import CapeCod # noqa (API import)
from chainladder.methods.clark_capecod import ClarkCapeCod # noqa (API import)
8 changes: 0 additions & 8 deletions chainladder/methods/clark_capecod.py

This file was deleted.

13 changes: 13 additions & 0 deletions chainladder/workflow/gridsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ class Pipeline(PipelineSL, EstimatorIO):
Read-only attribute to access any step parameter by user given name.
Keys are step names and values are steps parameters."""

def fit(self, X, y=None, sample_weight=None, **fit_params):
if sample_weight:
fit_params = {} if not fit_params else fit_params
fit_params[self.steps[-1][0] + '__sample_weight'] = sample_weight
return super().fit(X, y, **fit_params)

def predict(self, X, sample_weight=None):
if sample_weight:
fit_params = {} if not fit_params else fit_params
fit_params[self.steps[-1][0] + '__sample_weight'] = sample_weight
return super().predict(X, y, **fit_params)


def to_json(self):
return json.dumps(
[{'name': item[0],
Expand Down
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ def __getattr__(cls, name):
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'templates', 'includes', 'themes']

exclude_patterns = ['_build', 'templates', 'includes', 'themes', '**.ipynb_checkpoints']
# The reST default role (used for this markup: `text`) to use for all
# documents.
default_role = 'any'
Expand Down
1 change: 1 addition & 0 deletions docs/themes/scikit-learn/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<li><a href="{{pathto('install')}}">Installation</a></li>
<li><a href="{{ pathto('modules/classes') }}">Documentation</a></li>
<li><a href="{{pathto('auto_examples/index')}}">Examples</a></li>
<li><a href="{{pathto('tutorials/index')}}">Tutorials</a></li>
</ul>
<a href="javascript:void(0);" onclick="showMenu()">
<div class="nav-icon">
Expand Down
Loading

0 comments on commit 79a86c2

Please sign in to comment.