Skip to content

Commit ac07f5f

Browse files
committed
0.5.0 Release (Extended API, BCI examples and tests)
1 parent 0d8c24e commit ac07f5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+13116
-12271
lines changed

CHANGELOG.rst

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
ConcentrationMetrics Change Log
1+
Change Log
22
================================
33

4-
v0.5.0 (16-10-2019)
5-
===================
6-
* Added first set of spatial concentration indexes
7-
* Added first set of network concentration indexes
8-
* Added methods for semantic self-documentation of models
9-
* Adding functionality to calculate metrics on graph data
4+
PLEASE NOTE THAT THE API IS STILL UNSTABLE AS MORE USE CASES / FEATURES ARE ADDED REGULARLY
5+
6+
v0.5.0 (05-04-2020)
7+
-------------------
8+
* Added script that produces cross-check calculations from corresponding R packages
9+
* Expanded functionality to process dataframes
10+
* PiPy installation
1011

1112
v0.4.2 (08-03-2019)
12-
===================
13+
-------------------
1314

1415
* Renamed library to concentrationMetrics to emphasize the nature of the library and follow the naming conventions of other Open Risk projects (transitionMatrix, correlationMatrix etc)
1516
* Added readthedocs documentation
1617

1718
v0.4.1 (18-02-2019)
18-
===================
19+
-------------------
1920

2021
* Provide confidence intervals via bootstraping
2122
* Improved test documentation
2223
* Fixed documentation links
2324

2425
v0.4 (17-08-2018)
25-
===================
26+
-------------------
2627
* Added new one-dimensional indexes: Hoover
2728
* New multi-dimensional index family: Ellison-Glaeser
2829
* Added normalized version flag (ranging in 0,1) for HHI, Shannon
@@ -32,13 +33,13 @@ v0.4 (17-08-2018)
3233
* More formal testing framework, added tests for the EG index
3334

3435
v0.3.1 (09-05-2018)
35-
===================
36+
-------------------
3637

3738
* Code documentation via sphinx
3839
* Improved alignment with Open Risk Manual pages
3940

4041
v0.3.0 (27-12-2017)
41-
===================
42+
-------------------
4243

4344
* Exhaustive collection of indexes
4445
* Direct documentation using Open Risk Manual URL's
@@ -47,6 +48,6 @@ v0.3.0 (27-12-2017)
4748
* Examples directory
4849

4950
v0.2.0 (23-11-2016)
50-
===================
51+
-------------------
5152

5253
* First public release of the package

DESCRIPTION.rst

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
====================
2-
ConcentrationMetrics
3-
====================
1+
The concentrationMetrics Library
2+
================================
43

5-
ConcentrationMetrics is an MIT-licensed `Python <http://www.python.org>`_
6-
package aimed at becoming a reference implementation of indicators used in the analysis of concentration,
7-
inequality and diversity measures.
4+
ConcentrationMetrics is an MIT-licensed `Python <http://www.python.org>`_ package aimed at becoming a reference implementation
5+
of indexes used in the analysis of concentration, inequality and diversity measures.
86

97
Overview of Main Features
108
=========================
119

1210
* exhaustive collection of concentration and inequality indexes and metrics
1311
* supports file input/output in both json and csv formats
12+
* detailed mathematical documentation
1413
* computation of confidence intervals via bootstraping
1514
* visualization using matplotlib
1615

@@ -30,22 +29,28 @@ on randomly generated portfolio data:
3029
a = 1.7
3130
portfolio = np.random.zipf(a, 100)
3231
33-
# Calculate some indexes
32+
# Calculate the desired indexes
3433
indices = Index()
3534
hhi = indices.hhi(portfolio)
3635
gini = indices.gini(portfolio)
3736
38-
# Compute the confidence interval
37+
# Compute the confidence interval around the HHI index value
3938
lower_bound, val, upper_bound = indices.compute(portfolio, index='hhi', ci=0.95, samples=10000)
4039
40+
# Calculate indexes on a dataframe
41+
BCI = pd.read_json(dataset_path + "BCI.json")
42+
y = BCI.values
43+
myGroupIndex = cm.Index(data=y, index='simpson')
44+
myGroupIndex.print(6)
4145
42-
Many more examples in the examples directory.
46+
47+
Many more examples and tests are available in the examples and test directories.
4348

4449

4550
File structure
4651
==============
4752

48-
* `concentrationMetrics.py` The library module
53+
* `concentrationMetrics/model.py` The library module
4954
* `datasets/` Contains a variety of datasets useful for getting started with the ConcentrationMetrics
5055
* `examples/` Variety of usage examples
5156
* `docs/` Sphinx generated documentation
@@ -55,27 +60,27 @@ All indexes are currently implemented in concentrationMetrics.py as methods of t
5560

5661
Dependencies
5762
============
63+
The main dependencies are the standard python datascience stack and networkx. The full list is in requirements.txt
5864

59-
- matplotlib
60-
- networkx
61-
- numpy
62-
- pandas
63-
- scipy
65+
- matplotlib
66+
- numpy
67+
- pandas
68+
- scipy
69+
- networkx
6470

6571
Datasets
6672
========
73+
Version 0.5.0 includes datasets used primarily for testing and comparison with R implementations:
6774

68-
Version 0.3.1 includes two real datasets currently used primarily for testing and comparison with R implementations:
69-
70-
- hhbudget.csv
71-
- Ilocos.csv
75+
- hhbudget.csv
76+
- Ilocos.csv
77+
- BCI.json
7278

7379
Testing
7480
=======
7581

7682
Run python test.py
7783

78-
Comparison with R implementations
84+
Comparison with R packages
7985
=================================
80-
8186
- atkinson\_test.py compares the Atkinson function with the IC2/Atk function

LICENSE renamed to LICENSE.txt

File renamed without changes.

README.md

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ concentrationMetrics is a python library for the computation of various concentr
77

88
You can use concentrationMetrics to
99

10-
- access an exhaustive collection of concentration and inequality indexes and metrics
10+
- access an exhaustive collection of concentration, inequality and diversity indexes and metrics
1111
- perform file input/output in both json and csv formats
12-
- computate indices with confidence intervals via bootstraping
12+
- compute indexes with confidence intervals via bootstraping
1313
- visualize using matplotlib
1414

15-
1615
Key Information
1716
================
1817

@@ -24,22 +23,15 @@ Key Information
2423
* General Discussions: [Gitter Lobby](https://gitter.im/open-risk/Lobby)
2524
* Package Specific Chat: [Gitter Project](https://gitter.im/open-risk/concentrationMetrics)
2625

26+
**NB: concentrationMetrics is still in active development. If you encounter issues please raise them in our github repository**
2727

28-
**NB: concentrationMetrics is still in active development. If you encounter issues please raise them in our
29-
github repository**
30-
31-
Support and Training
32-
=========================
33-
34-
The Open Risk Academy has free courses demonstrating the use of the library: [Open Risk Academy](https://www.openriskacademy.com)
35-
28+
[Full Description](DESCRIPTION.rst)
3629

3730
List of Implemented Indexes
3831
===============================
32+
An overview of the implemented metrics (indexes) and their relationships is available at the [Open Risk Manual](https://www.openriskmanual.org/wiki/Concentration_Index)
3933

40-
An overview of the implemented metrics is available at the [Open Risk Manual](https://www.openriskmanual.org/wiki/Concentration_Index)
41-
42-
The below list provides specific documentation URL's for each one of the implement indexes
34+
The below list provides more specific documentation URL's for each one of the implement indexes:
4335

4436
* [Atkinson Index](https://www.openriskmanual.org/wiki/Atkinson_Index)
4537
* [Berger-Parker Index](https://www.openriskmanual.org/wiki/Berger-Parker_Index)
@@ -49,17 +41,18 @@ The below list provides specific documentation URL's for each one of the impleme
4941
* [Theil Index](https://www.openriskmanual.org/wiki/Theil_Index)
5042
* [Hannah-Kay Index](https://www.openriskmanual.org/wiki/Hannah_Kay_Index)
5143
* [Hoover Index](https://www.openriskmanual.org/wiki/Hoover_Index)
52-
* [Herfindahl-Hirschman Index](https://www.openriskmanual.org/wiki/Herfindahl-Hirschman_Index)
44+
* [Herfindahl-Hirschman Index](https://www.openriskmanual.org/wiki/Herfindahl-Hirschman_Index) and related indexes such as Simpson and Inverse Simpson
5345
* [Shannon Index](https://www.openriskmanual.org/wiki/Shannon_Index)
5446
* [Generalized Entropy Index (Renyi)](https://www.openriskmanual.org/wiki/Generalized_Entropy_Index)
5547
* [Kolm Index](https://www.openriskmanual.org/wiki/Kolm_Index)
5648

49+
Support and Training
50+
=========================
51+
The Open Risk Academy has free courses demonstrating the use of the library: [Open Risk Academy](https://www.openriskacademy.com)
5752

58-
[Full Description](DESCRIPTION.rst)
5953

6054
Examples
6155
========
62-
6356
Comparing two indexes across a range of input portfolio data
6457

6558
![image](examples/hhi_vs_gini.png)
@@ -71,5 +64,5 @@ Calculating industrial and geographic concentrations
7164

7265
Contributions
7366
=============
74-
75-
Check the [TODO list](TODO.rst) for ideas of where to take this library next
67+
* Check the [TODO list](docs/source/todo.rst) for immediate TODO items
68+
* Check the [Roadmap](docs/source/roadmap.rst) for the bigger picture

concentrationMetrics/__init__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# encoding: utf-8
2+
3+
# (c) 2020 Open Risk (https://www.openriskmanagement.com)
4+
#
5+
# ConcentrationMetrics is licensed under the MIT license a copy of which is included
6+
# in the source distribution of TransitionMatrix. This is notwithstanding any licenses of
7+
# third-party software included in this distribution. You may not use this file except in
8+
# compliance with the License.
9+
#
10+
# Unless required by applicable law or agreed to in writing, software distributed under
11+
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
12+
# either express or implied. See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
""" concentrationMetrics - Python package aimed at becoming a reference implementation of indicators used in the
17+
analysis of concentration, inequality and diversity measures. """
18+
19+
from .model import *
20+
21+
__version__ = '0.5.0'
22+
23+
package_name = 'concentrationMetrics'
24+
module_path = os.path.dirname(__file__)
25+
source_path = module_path[:-len(package_name)]
26+
dataset_path = os.path.join(source_path, 'datasets/')

0 commit comments

Comments
 (0)