Skip to content

Commit 64d0cf7

Browse files
author
cezary.maszczyk
committed
add some cool badges to README
1 parent 21139b0 commit 64d0cf7

19 files changed

+288
-205
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,7 @@ doc/build/html/.buildinfo
292292
RELEASE_INSTRUCTION.md
293293

294294
notebooks/
295-
classification_tabular_datasets/
295+
classification_tabular_datasets/
296+
.coverage
297+
junit.xml
298+
reports/

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
[![Coverage Status](./badges/coverage-badge.svg?dummy=8484744)](./reports/coverage/index.html)
2+
[![Tests Status](./badges/test-badge.svg?dummy=8484744)](./reports/junit/report.html)
3+
[![Flake8 Status](./badges/flake8-badge.svg?dummy=8484744)](./reports/flake8/index.html)
4+
![PyPI](https://img.shields.io/pypi/v/rulekit?label=pypi%20package)
5+
![PyPI - Downloads](https://img.shields.io/pypi/dm/rulekit)
6+
17
# Rulekit
2-
8+
9+
310
This package is python wrapper for [RuleKit](https://github.com/adaa-polsl/RuleKit) library - a versatile tool for rule learning.
411

512
Based on a sequential covering induction algorithm, it is suitable for classification, regression, and survival problems.

badges/coverage-badge.svg

+1
Loading

badges/flake8-badge.svg

+1
Loading

badges/test-badge.svg

+1
Loading

doc/HOW_TO_DEPLOY.md

+28
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,31 @@ make.bat`
4646
>
4747
</li>
4848
```
49+
50+
### 3. Update badges
51+
52+
In repo root directory:
53+
54+
1. Update coverage badge
55+
```bash
56+
python -m coverage run -m unittest discover ./tests
57+
python -m coverage xml -o ./reports/coverage/coverage.xml
58+
python -m coverage html -d ./reports/coverage/
59+
genbadge coverage -i ./reports/coverage/coverage.xml -o ./badges/coverage-badge.svg
60+
```
61+
62+
2. Update test badge
63+
64+
```bash
65+
mkdir ./reports/junit
66+
python -m junitxml.main --o ./reports/junit/junit.xml
67+
68+
genbadge tests -o ./badges/test-badge.svg
69+
```
70+
71+
3. Update flake8 badge
72+
73+
```bash
74+
flake8 ./rulekit --exit-zero --format=html --htmldir ./reports/flake8 --statistics --tee --output-file ./reports/flake8/flake8stats.txt
75+
genbadge flake -o ./badges/flake8-badge.svg
76+
```

requirements-dev.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
pre-commit
2-
autopep8
2+
autopep8
3+
genbadge[all]
4+
coverage
5+
junitxml

rulekit/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# pylint: disable=missing-module-docstring
2-
from .main import RuleKit
2+
from .main import RuleKit # pylint: disable=unused-import
3+
4+
RuleKit

rulekit/_experiment.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
"""Module containing class for running experiments using legacy Java RuleKit CLI. For more
2-
details see `documentation \
1+
"""Module containing class for running experiments using legacy
2+
Java RuleKit CLI. For more details see `documentation \
33
<https://github.com/adaa-polsl/RuleKit/wiki/7-Library-API#71-running-an-experiment
44
"""
55
from jpype import JClass

rulekit/_helpers.py

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
"""Contains helper functions and classes
22
"""
33
import io
4-
from typing import Any, Union
4+
from typing import Any
5+
from typing import Union
56

67
import numpy as np
78
import pandas as pd
8-
from jpype import JArray, JClass, JObject, java
9-
from jpype.pickle import JPickler, JUnpickler
9+
from jpype import JArray
10+
from jpype import java
11+
from jpype import JClass
12+
from jpype import JObject
13+
from jpype.pickle import JPickler
14+
from jpype.pickle import JUnpickler
1015

1116
from .main import RuleKit
1217
from .params import Measures
@@ -17,7 +22,8 @@ def get_rule_generator(expert: bool = False) -> Any:
1722
"""Factory for Java RuleGenerator class object
1823
1924
Args:
20-
expert (bool, optional): Whether expert induction is enables. Defaults to False.
25+
expert (bool, optional): Whether expert induction is enables.
26+
Defaults to False.
2127
2228
Returns:
2329
Any: RuleGenerator instance
@@ -124,8 +130,8 @@ def make(
124130
Args:
125131
X (Union[pd.DataFrame, np.ndarray]): Data
126132
y (Union[pd.Series, np.ndarray], optional): Labels. Defaults to None.
127-
survival_time_attribute (str, optional): Name of survival time attribute.
128-
Defaults to None.
133+
survival_time_attribute (str, optional): Name of survival time attribute.
134+
Defaults to None.
129135
contrast_attribute (str, optional): Name of contrast attribute. Defaults to None.
130136
131137
Returns:
@@ -327,7 +333,7 @@ def map_to_numerical(predicted_example_set: JObject, remap: bool = True) -> np.n
327333
for i in range(predicted_example_set.size())
328334
])
329335

330-
@ staticmethod
336+
@staticmethod
331337
def map_survival(predicted_example_set) -> np.ndarray:
332338
"""Maps survival models predictions to numpy array. Used as alternative to `map` method
333339
used in survival analysis
@@ -359,7 +365,7 @@ def map_survival(predicted_example_set) -> np.ndarray:
359365
estimators.append(estimator)
360366
return np.array(estimators)
361367

362-
@ staticmethod
368+
@staticmethod
363369
def _get_column_by_role(predicted_example_set: JObject, role: str) -> JObject:
364370
return predicted_example_set.getAttributes().getColumnByRole(role)
365371

@@ -368,7 +374,7 @@ class ModelSerializer:
368374
"""Class for serializing models
369375
"""
370376

371-
@ staticmethod
377+
@staticmethod
372378
def serialize(real_model: object) -> bytes:
373379
"""Serialize Java ruleset object.
374380
@@ -381,7 +387,7 @@ def serialize(real_model: object) -> bytes:
381387
in_memory_file.close()
382388
return serialized_bytes
383389

384-
@ staticmethod
390+
@staticmethod
385391
def deserialize(serialized_bytes: bytes) -> object:
386392
"""Deserialize Java ruleset object from bytes.
387393

rulekit/_operator.py

+16-10
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22
"""
33
from __future__ import annotations
44

5-
from typing import Any, Optional, Union
5+
from typing import Any
6+
from typing import Optional
7+
from typing import Union
68

79
import numpy as np
810
import pandas as pd
911
from pydantic import BaseModel
1012

11-
from ._helpers import (ExampleSetFactory, ModelSerializer,
12-
PredictionResultMapper, RuleGeneratorConfigurator,
13-
get_rule_generator)
14-
from .events import RuleInductionProgressListener, command_listener_factory
13+
from ._helpers import ExampleSetFactory
14+
from ._helpers import get_rule_generator
15+
from ._helpers import ModelSerializer
16+
from ._helpers import PredictionResultMapper
17+
from ._helpers import RuleGeneratorConfigurator
18+
from .events import command_listener_factory
19+
from .events import RuleInductionProgressListener
1520
from .main import RuleKit
16-
from .rules import Rule, RuleSet
21+
from .rules import Rule
22+
from .rules import RuleSet
1723

1824
Data = Union[np.ndarray, pd.DataFrame, list]
1925

@@ -136,8 +142,8 @@ def get_coverage_matrix(self, values: Data) -> np.ndarray:
136142
-------
137143
coverage_matrix : np.ndarray
138144
Each row of the matrix represent single example from dataset and every column represent
139-
on rule from rule set. Value 1 in the matrix cell means that rule covered certain
140-
example, value 0 means that it doesn't.
145+
on rule from rule set. Value 1 in the matrix cell means that rule covered certain
146+
example, value 0 means that it doesn't.
141147
"""
142148
if self.model is None:
143149
raise ValueError(
@@ -156,8 +162,8 @@ def get_coverage_matrix(self, values: Data) -> np.ndarray:
156162
return np.array(result)
157163

158164
def add_event_listener(self, listener: RuleInductionProgressListener):
159-
"""Add event listener object to the operator which allows to monitor
160-
rule induction progress.
165+
"""Add event listener object to the operator which allows to monitor
166+
rule induction progress.
161167
162168
Example:
163169
>>> from rulekit.events import RuleInductionProgressListener

0 commit comments

Comments
 (0)