Skip to main content
<p align="center">
<img src="media/box2.png" />
</p>

---

| License | Build Status | Codecov |
| --- | --- | --- |
| [![][license img]][license] | [![Build Status](https://travis-ci.org/batflyer/boostsrl-python-package.svg?branch=master)](https://travis-ci.org/batflyer/boostsrl-python-package) | [![][codecov img]][codecov link] |

---

# boostsrl_java

> **BoostSRL** (Boosting for Statistical Relational Learning) is a gradient-boosting based approach to learning statistical relational models.
> Sriraam Natarajan, Tushar Khot, Kristian Kersting and Jude Shavlik, Boosted Statistical Relational Learners: From Benchmarks to Data-Driven Medicine. SpringerBriefs in Computer Science, ISBN: 978-3-319-13643-1, 2015

*boostsrl_java* is a Python package with wrappers for creating background knowledge and performing learning and inference.

## Getting Started

### Prerequisites

* Java 1.8
* Python (2.6, 2.7, 3.3, 3.4, 3.5, 3.6)
* subprocess32 (if using Python 2.7: `pip install subprocess32`)

### Installation

* The latest stable build can be installed with pip:

```bash
$ pip install boostsrl_java
```

* For versions in development, use the most recent available on GitHub

```bash
# Clone the repository
$ git clone https://github.com/batflyer/boostsrl-python-package.git
# Test the build
$ python tests/test.py
```

### Basic Usage

```python
>>> from boostsrl import boostsrl

'''Step 1: Background Knowledge'''

# Sample data is built in from the 'Toy Cancer' Dataset, retrieve it with sample_data
>>> bk = boostsrl.example_data('background')

# Create the background knowledge or 'Modes,' where 'cancer' is the target we want to predict.
>>> background = boostsrl.modes(bk, ['cancer'], useStdLogicVariables=True, treeDepth=4, nodeSize=2, numOfClauses=8)

'''Step 2: Training a Model'''

# Retrieve the positives, negatives, and facts.
>>> train_pos = boostsrl.example_data('train_pos')
>>> train_neg = boostsrl.example_data('train_neg')
>>> train_facts = boostsrl.example_data('train_facts')

# Train a model using this data:
>>> model = boostsrl.train(background, train_pos, train_neg, train_facts)

# How many seconds did training take?
>>> model.traintime()
0.705

'''Step 3: Test Model on New Data'''

# Retrieve the positives, negatives, and facts.
>>> test_pos = boostsrl.example_data('test_pos')
>>> test_neg = boostsrl.example_data('test_neg')
>>> test_facts = boostsrl.example_data('test_facts')

# Test the data
>>> results = boostsrl.test(model, test_pos, test_neg, test_facts)

'''Step 4: Observe Performance'''

# To see the overall performance of the model on test data:
>>> results.summarize_results()
{'CLL': '-0.223184', 'F1': '1.000000', 'Recall': '1.000000', 'Precision': '1.000000,0.500', 'AUC ROC': '1.000000', 'AUC PR': '1.000000'}

# To see probabilities for individual test examples:
>>> results.inference_results('cancer')
{'!cancer(Watson)': 0.6924179024024251, 'cancer(Xena)': 0.8807961917687174, '!cancer(Voldemort)': 0.6924179024024251, 'cancer(Yoda)': 0.8807961917687174, 'cancer(Zod)': 0.8807961917687174}

```

## Contributing

Please refer to [CONTRIBUTING.md](.github/CONTRIBUTING.md) for documentation on submitting issues and pull requests.

## Versioning

We use [SemVer](http://semver.org/) for versioning. See [Releases](https://github.com/batflyer/boostsrl-python-package/releases) for all stable versions that are available.

## Acknowledgements

* Professor Sriraam Natarajan
* Members of STARAI Lab

---

### Planned Features:

* saving/loading a model

```python
>>> from boostsrl import boostsrl
>>> boostsrl.save_model('toy_cancer')
```

[license]:license.txt
[license img]:https://img.shields.io/aur/license/yaourt.svg

[codecov img]:https://codecov.io/gh/batflyer/boostsrl-python-package/branch/master/graphs/badge.svg?branch=master
[codecov link]:https://codecov.io/github/batflyer/boostsrl-python-package?branch=master

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

boostsrl-0.1.tar.gz (7.3 kB view details)

Uploaded Source

File details

Details for the file boostsrl-0.1.tar.gz.

File metadata

  • Download URL: boostsrl-0.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for boostsrl-0.1.tar.gz
Algorithm Hash digest
SHA256 a73509863798b0ad1c0b5a3401f1f6bbe0ae76b0841f52452cc9c32c684310b8
MD5 ee0fd1cf4482a58b9ad849f29e0f6f0b
BLAKE2b-256 f0df66a9c0ab4b008a44c1c3d1aaa68b16f96a54c37529673716fb7ed76e334c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.3

2 files

0.4.2

2 files

0.4.1

1 file

0.4.0

3 files

0.3

1 file

0.2

1 file

This release

0.1 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page