Giter Site home page Giter Site logo

fastauc's Introduction

fastauc

Three fast AUC calculation implementations for python:

python-based is approximately 8X faster than the default sklearn.metrics.roc_auc_score()

Python numba based is approximately 26X faster than the default sklearn.metrics.roc_auc_score()

C++/ctypes based is approximately 37X faster than the default sklearn.metrics.roc_auc_score()

10 000 AUC calculations total time:

times

NB: run cd fastauc && ./compile.sh to create a binary before you use a C++ version.

See demo.py for speed benchmark and usage examples.

fastauc's People

Contributors

agade09 avatar diditforlulz273 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

Watchers

 avatar

fastauc's Issues

Moving np.argsort out of numba-compiled func.

Hi, please consider moving np.argsort out of numba-compiled func, as njitting argsort is known for slowing it down twice (still as of 2023, unfortunately). That makes Numba version faster than C version :-)

smth like

def optimized_auc(y_true: np.array, y_score: np.array) -> float:
    desc_score_indices = np.argsort(y_score,)[::-1]
    return fast_numba_auc_nonw(y_true=y_true, y_score=y_score, desc_score_indices=desc_score_indices)

My tests on 8M float32 array:

%timeit fast_auc.fast_auc(y_true=Y_val.values, y_score=probs[:, 1])
392 ms ± 2.79 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

%timeit fast_auc.fast_numba_auc(y_true=Y_val.values, y_score=probs[:, 1])
672 ms ± 2.28 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

%timeit optimized_auc(y_true=Y_val.values, y_score=probs[:, 1])
338 ms ± 3.07 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

No need to hardcode mergesort, as well.

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.