-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
271 additions
and
1,408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* override table width restrictions */ | ||
@media screen and (min-width: 767px) { | ||
|
||
.wy-table-responsive table td { | ||
/* !important prevents the common CSS stylesheets from | ||
overriding this as on RTD they are loaded after this stylesheet */ | ||
white-space: normal !important; | ||
} | ||
|
||
.wy-table-responsive { | ||
overflow: visible !important; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
concentrationMetrics module | ||
concentrationMetrics Package | ||
============================= | ||
|
||
.. automodule:: concentrationMetrics.model | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,81 @@ | ||
.. include:: ../../DESCRIPTION.rst | ||
The concentrationMetrics Library | ||
================================ | ||
|
||
concentrationMetrics is an MIT-licensed `Python <http://www.python.org>`_ package aimed at becoming a reference implementation of indexes used in the analysis of concentration, inequality and diversity measures. | ||
|
||
Overview of Main Features | ||
========================= | ||
|
||
* exhaustive collection of concentration and inequality indexes and metrics | ||
* supports file input/output in both json and csv formats | ||
* detailed mathematical documentation | ||
* computation of confidence intervals via bootstraping | ||
* visualization using matplotlib | ||
|
||
|
||
Usage | ||
=============================== | ||
|
||
Using the library is quite straightforward. For example calculating the Gini and the HHI indexes | ||
on randomly generated portfolio data: | ||
|
||
.. code:: python | ||
import numpy as np | ||
from concentrationMetrics import Index | ||
# Create some data | ||
a = 1.7 | ||
portfolio = np.random.zipf(a, 100) | ||
# Calculate the desired indexes | ||
indices = Index() | ||
hhi = indices.hhi(portfolio) | ||
gini = indices.gini(portfolio) | ||
# Compute the confidence interval around the HHI index value | ||
lower_bound, val, upper_bound = indices.compute(portfolio, index='hhi', ci=0.95, samples=10000) | ||
# Calculate indexes on a dataframe | ||
BCI = pd.read_json(dataset_path + "BCI.json") | ||
y = BCI.values | ||
myGroupIndex = cm.Index(data=y, index='simpson') | ||
myGroupIndex.print(6) | ||
Many more examples and tests are available in the examples and test directories. | ||
|
||
|
||
File structure | ||
============== | ||
|
||
* `concentrationMetrics/model.py` The library module | ||
* `datasets/` Contains a variety of datasets useful for getting started with the ConcentrationMetrics | ||
* `examples/` Variety of usage examples | ||
* `docs/` Sphinx generated documentation | ||
* `tests/` testing the implementation | ||
|
||
All indexes are currently implemented in concentrationMetrics/model.py as methods of the Index object. | ||
|
||
Dependencies | ||
============ | ||
The main dependencies are the standard python datascience stack (numpy, pandas etc) and networkx. The full list is in requirements.txt | ||
|
||
- matplotlib | ||
- numpy | ||
- pandas | ||
- scipy | ||
- networkx | ||
|
||
Datasets | ||
======== | ||
Version 0.5.0 includes datasets used primarily for testing and comparison with R implementations: | ||
|
||
- hhbudget.csv | ||
- Ilocos.csv | ||
- BCI.json | ||
|
||
|
||
Comparison with R packages | ||
================================= | ||
- atkinson\_test.py compares the Atkinson function with the IC2/Atk function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Usage Examples | ||
====================== | ||
|
||
The examples directory includes both **standalone python scripts** and **jupyter notebooks** to help you get started. (NB: Currently there are only scripts and no notebooks TODO). | ||
|
||
|
||
Python Scripts | ||
------------------------------------------- | ||
|
||
The scripts are located in examples/python. For testing purposes all examples can be run using the run_examples.py script located in the root directory. Some scripts have an example flag that selects alternative input data or estimators. | ||
|
||
|
||
Jupyter Notebooks | ||
------------------------------------------- | ||
|
||
|
||
|
||
Open Risk Academy Scripts | ||
------------------------------------------- | ||
|
||
Further examples available in an Open Risk Academy CrashProgram in the use of python for risk modelling purposes, in particular credit concentration measurement: `Concentration Measurement Using Python <https://www.openriskacademy.com/course/management.php?categoryid=26&courseid=13>`_ | ||
|
||
|
Oops, something went wrong.