GithubHelp home page GithubHelp logo

astrazeneca / rexmex Goto Github PK

View Code? Open in Web Editor NEW
275.0 8.0 25.0 2.75 MB

A general purpose recommender metrics library for fair evaluation.

Home Page: https://rexmex.readthedocs.io/

Python 99.91% Shell 0.09%
deep-learning machine-learning coverage personalization mrr ranking rank recall precision rsquared

rexmex's Introduction

Version License repo size build badge codecov


reXmeX is recommender system evaluation metric library.

Please look at the Documentation and External Resources.

reXmeX consists of utilities for recommender system evaluation. First, it provides a comprehensive collection of metrics for the evaluation of recommender systems. Second, it includes a variety of methods for reporting and plotting the performance results. Implemented metrics cover a range of well-known metrics and newly proposed metrics from data mining (ICDM, CIKM, KDD) conferences and prominent journals.

Citing

If you find RexMex useful in your research, please consider adding the following citation:

@inproceedings{rexmex,
       title = {{rexmex: A General Purpose Recommender Metrics Library for Fair Evaluation.}},
       author = {Benedek Rozemberczki and Sebastian Nilsson and Piotr Grabowski and Charles Tapley Hoyt and Gavin Edwards},
       year = {2021},
}

An introductory example

The following example loads a synthetic dataset which has the mandatory y_true and y_score keys. The dataset has binary labels and predictied probability scores. We read the dataset and define a defult ClassificationMetric instance for the evaluation of the predictions. Using this metric set we create a score card and get the predictive performance metrics.

from rexmex import ClassificationMetricSet, DatasetReader, ScoreCard

reader = DatasetReader()
scores = reader.read_dataset()

metric_set = ClassificationMetricSet()

score_card = ScoreCard(metric_set)

report = score_card.get_performance_metrics(scores["y_true"], scores["y_score"])

An advanced example

The following more advanced example loads the same synthetic dataset which has the source_id, target_id, source_group and target group keys besides the mandatory y_true and y_score. Using the source_group key we group the predictions and return a performance metric report.

from rexmex import ClassificationMetricSet, DatasetReader, ScoreCard

reader = DatasetReader()
scores = reader.read_dataset()

metric_set = ClassificationMetricSet()

score_card = ScoreCard(metric_set)

report = score_card.generate_report(scores, grouping=["source_group"])

Scorecard

A rexmex score card allows the reporting of recommender system performance metrics, plotting the performance metrics and saving those. Our framework provides 7 rating, 38 classification, 18 ranking, and 2 coverage metrics.

Metric Sets

Metric sets allow the users to calculate a range of evaluation metrics for a label - predicted label vector pair. We provide a general MetricSet class and specialized metric sets with pre-set metrics have the following general categories:

  • Ranking
  • Rating
  • Classification
  • Coverage

Ranking Metric Set

Expand to see all ranking metrics in the metric set.

Rating Metric Set

These metrics assume that items are scored explicitly and ratings are predicted by a regression model.

Expand to see all rating metrics in the metric set.

Classification Metric Set

These metrics assume that the items are scored with raw probabilities (these can be binarized).

Expand to see all classification metrics in the metric set.

Coverage Metric Set

These metrics measure how well the recommender system covers the available items in the catalog and possible users. In other words measure the diversity of predictions.


Documentation and Reporting Issues

Head over to our documentation to find out more about installation and data handling, a full list of implemented methods, and datasets.

If you notice anything unexpected, please open an issue and let us know. If you are missing a specific method, feel free to open a feature request. We are motivated to constantly make RexMex even better.


Installation via the command line

RexMex can be installed with the following command after the repo is cloned.

$ pip install .

Use -e/--editable when developing.

Installation via pip

RexMex can be installed with the following pip command.

$ pip install rexmex

As we create new releases frequently, upgrading the package casually might be beneficial.

$ pip install rexmex --upgrade

Running tests

Tests can be run with tox with the following:

$ pip install tox
$ tox -e py

Citation

If you use RexMex in a scientific publication, we would appreciate citations. Please see GitHub's built-in citation tool.


License

rexmex's People

Contributors

benedekrozemberczki avatar cthoyt avatar dobraczka avatar gavedwards avatar kajocina avatar mughetto avatar sbonner0 avatar sebastiandro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rexmex's Issues

Add structured data about metrics

It would be great to include some structured data for each metric to enable other libraries to more easily generally consume implementations provided by rexmex. It would be useful to annotate at a minimum:

  1. human-readable name
  2. range of values (e.g., [0,1])
  3. whether higher is better
  4. citation, if available

For example, I've annotated citation information on to all models in PyKEEN using the docdata package (which I wrote for just this purpose): Check how it looks for the CrossE model here. In the accompanying PR, I made a slightly simpler solution that just uses Python decorators and doesn't introduce another dependency to rexmex.

An example downstream consumer of the results from solving this issue can be demonstrated this pull request to PyKEEN, where I would like to ultimately consume metric functions directly from rexmex and not have to annotate this information inside PyKEEN itself.

Pandas versioning issue

Hey rexmex team,

I wanted to ask you if there is a specific reason why your installation requires pandas to be of this version?

Since this package gets installed with the latest version of PyKEEN, I am facing some versioning issues due to the Pandas version restriction of your package.

The related line of code:

install_requires = ["numpy", "sklearn", "pandas<=1.3.5", "scipy", "scikit-learn"]

Apologies if it's a silly question but: is it indeed a strict requirement for rexmex to have Pandas<1.3.5 or is this something we can modify in rexmex setup.py? ( if so I can open a related PR for it )

Thank you in advance!
Best,
Dimitris

API Suggestions

Right now it's a bit round-about to get a scorecard for a given dataset since it expect a pandas format. I'd suggest exposing ScoreCard._get_performance_metrics as a public user interface and also encourage people to use that directly in case they're generating their own y_true and y_score and don't want to write their own code to generate a pandas dataframe from it, just for rexmex to need to unpack it.

My example is in PyKEEN, where we do just that: https://github.com/pykeen/pykeen/blob/799e224e772176703d796a9247bfcc179d343c6c/src/pykeen/evaluation/sklearn.py#L129-L142

I'd also say it would be worth adding a second introductory example based on this in the README.

Pandas versioning

Hey AstraZeneca,

The related line of code:

install_requires = ["numpy", "sklearn", "pandas<=1.3.5", "scipy", "scikit-learn"]

Is it a strict requirement for rexmex to have Pandas<1.3.5 or is this something we can modify in rexmex or setup.py? (if so I can open a related PR for it, much like the other question but formatted a bit better and notation to make it clear.)

Thanks,
Montana Mendy

Examples link is broken

Hey, great work. I was looking to try out this repo but the examples link in the readme is broken. Please look into it. Thanks!

Add the DeepCCI model

The original paper:
The reference implementation:

  • Write auxiliary layers.
  • Write a model architecture layer.
  • Write smoke tests with the test data.
  • Write an example for the ./examples/ folder.

Improve binning in `binarize()`

The current binarize function uses a cutoff of 0.5 for binarization:

rexmex/rexmex/utils.py

Lines 28 to 34 in 3e26652

def metric_wrapper(*args, **kwargs):
# TODO: Move to optimal binning. Youden’s J statistic.
y_score = args[1]
y_score[y_score < 0.5] = 0
y_score[y_score >= 0.5] = 1
score = metric(*args, **kwargs)
return score

This is an issue for PyKEEN, where the scores that come from a model could all be on the range of [-5,-2]. The current TODO text says to use https://en.wikipedia.org/wiki/Youden%27s_J_statistic, but it's not clear how that would be used.

As an alternative, the NetMF package implements the following code for constructing an indicator that might be more applicable (though I don't personally recognize what method this is, and unfortunately it's not documented):

def construct_indicator(y_score, y):
    # rank the labels by the scores directly
    num_label = np.sum(y, axis=1, dtype=np.int)
    y_sort = np.fliplr(np.argsort(y_score, axis=1))
    y_pred = np.zeros_like(y, dtype=np.int)
    for i in range(y.shape[0]):
        for j in range(num_label[i]):
            y_pred[i, y_sort[i, j]] = 1
    return y_pred

Running ./dev_setup.sh fails

There is no setup.py file inside the rexmex folder, hence the dev_setup.sh script fails with error message:

ERROR: File "setup.py" or "setup.cfg" not found. Directory cannot be installed in editable mode

A solution could be to update the dev_setup.sh to install the package from the root directory:

pip install -e .

Why are there duplicate functions?

I noticed that there are duplicate functions such as miss_rate()/false_negative_rate() and fall_out()/false_positive_rate(). What's the reason for the duplication?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.