Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Added a ranking example #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions examples/ranking_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
================
Ranking example
================
"""

import numpy as np

from sklearn.datasets import load_diabetes
from sklearn.utils.testing import assert_almost_equal

from lightning.ranking import PRank
from lightning.ranking import KernelPRank

# TODO: Add more datasets.
bunch = load_diabetes()
X, y = bunch.data, bunch.target
y = np.round(y, decimals=-2)

# TODO: Add more rankers.
rankers = (PRank(n_iter=10, shuffle=False, random_state=0),
KernelPRank(kernel="linear",
n_iter=10,
shuffle=True,
random_state=0))

for ranker in rankers:
print ranker.__class__.__name__
ranker.fit(X, y)
print ranker.score(X, y)