Skip to main content
# cdl2r
Combination Dependent Learning to Rank (組合せ依存型ランキング学習).

## requirements
- Python 3.6.x ~, 3.7.x ~

## dependencies
- NumPy
- Pandas

## installation
```shell
$ pip install cdl2r
```

## usage
### 1. prepare your dataset
The dataset format is like SVM-rank one.
The difference is `eid` must be specified in a line.
Here is a definition of a line.
`|` symbol means `OR` (so `<str>|<int>` means the value must have either str or int type).

```txt
<line> .=. <label> qid:<qid> eid:<eid> <features>#<comments>

<label> .=. <float>|<str as a class>
<qid> .=. <str>|<int>
<eid> .=. <str>|<int>
<features> .=. <dim>:<value>
<dim> .=. <0 or Natural Number>
<value> .=. <float>
<comments> .=. <Any text will do>
```

Let me show you an example.

```txt
0.5 qid:1 eid:x 1:0.1 2:-0.2 3:0.3#comment A
0.0 qid:1 eid:y 1:-0.1 2:0.2 4:0.4
-0.5 qid:1 eid:z 2:-0.2 3:0.3 4:-0.4#comment C
0.5 qid:2 eid:y 1:0.1 2:-0.2 3:0.3
0.0 qid:2 eid:z 1:-0.1 2:0.2 4:0.4
-0.5 qid:2 eid:w 2:-0.2 3:0.3 4:-0.4#comment E
```

### 2. loading your dataset
```python
from cdl2r.dataset import load_data

# loading dataset as a DataFrame object
data_path = '/path/to/dataset'
n_dimensions = 10
train = load_data(data_path, n_dimensions)
# train.columns
# >>> Index(['label', 'qid', 'eid', 'features'], dtype='object')
```

### 3. fitting the model
```python
from cdl2r.models import CDFMRegressor

# define your model
model = CDFMRegressor(n_factors=8, n_iterations=300, init_eta=1e-2)
# fitting, printing out epoch losses if verbose is True
model.fit(train, verbose=True)
```

### 4. save the model
```python
import pickle

with open('/path/to/file.pkl', mode='wb') as fp:
pickle.dump(model, fp)
```

### 5. make prediction
```python
# loading test dataset
test = load_data(test_path, n_dimensions)
pred = model.predict(test)
# pred.columns
# >>> Index(['pred_label', 'qid', 'eid', 'features'], dtype='object')
```

## development
### build Cython modules
```shell
$ python setup.py build_ext --inplace
```

### profiling
```shell
# decorate a method with `@profile` in a script where you want to profile.
$ kernprof -l -v <script>.py
```

### pylint
- max-line-length: 130
- disable snake-case

### release
```shell
# build
$ python setup.py bdist_whell

# testing upload
$ twine upload --repository testpypi dist/<cdl2r-version-pkg>
$ pip install --index-url https://test.pypi.org/simple/<cdl2r-version-pkg>

# upload
$ twine upload --repository pypi dist<cdl2r-version-pkg>
```


Metadata

Release files for cdl2r 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for cdl2r 0.1.2
File Interpreter ABI Platform
cdl2r-0.1.2-cp36-cp36m-macosx_10_14_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.14+ x86-64 Details

Release files / cdl2r-0.1.2-cp36-cp36m-macosx_10_14_x86_64.whl

Download URL cdl2r-0.1.2-cp36-cp36m-macosx_10_14_x86_64.whl
Size 35.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
54ca7c0cab90838bb89a5344de16a41f3c6d760b591d07a1cc0ff51a2ce7e391
BLAKE2b-256 checksum
How to use checksums
96be9c399c83d3667bd618d6f814911d2be229ca56f69ae7d77ea5ff9466d535
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

Security for cdl2r 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file No provenance

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