GithubHelp home page GithubHelp logo

david-cortes / costsensitive Goto Github PK

View Code? Open in Web Editor NEW
47.0 47.0 18.0 1.75 MB

(Python, R) Cost-sensitive multiclass classification (Weighted-All-Pairs, Filter-Tree & others)

License: BSD 2-Clause "Simplified" License

Python 57.98% C 6.67% R 34.88% Cython 0.46%
cost-sensitive-classification multi-label-classification

costsensitive's People

Contributors

david-cortes 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

Watchers

 avatar  avatar  avatar  avatar

costsensitive's Issues

problems with installing

Hello,

I have problems with the installation.
I installed Cython and Visual Buildstudio, however there are further issues:


Failed building wheel for costsensitive
Running setup.py clean for costsensitive
Failed to build costsensitive
Installing collected packages: costsensitive
Running setup.py install for costsensitive ... error
Complete output from command C:\Users\user\AppData\Local\Continuum\anaconda3\envs\chemenv\python.exe -u -c "import setuptools, tokenize;file='C:\Users\user\AppData\Local\Temp\pip-install-09n7kkgs\costsensitive\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\user\AppData\Local\Temp\pip-record-y9pf5l92\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\costsensitive
copying costsensitive_init_.py -> build\lib.win-amd64-3.6\costsensitive
running build_ext
skipping 'costsensitive\vwrapper.c' Cython extension (up-to-date)
building 'costsensitive._vwrapper' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\costsensitive
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\user\AppData\Local\Continuum\anaconda3\envs\chemenv\lib\site-packages\numpy\core\include -IC:\Users\user\AppData\Local\Continuum\anaconda3\envs\chemenv\include -IC:\Users\user\AppData\Local\Continuum\anaconda3\envs\chemenv\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tccostsensitive\vwrapper.c /Fobuild\temp.win-amd64-3.6\Release\costsensitive\vwrapper.obj -O2 -fopenmp
cl : Command line warning D9002 : ignoring unknown option '-fopenmp'
vwrapper.c
c:\users\user\appdata\local\continuum\anaconda3\envs\chemenv\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
costsensitive\vwrapper.c(595): fatal error C1083: Cannot open include file: '../src/calcv.c': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe' failed with exit status 2

----------------------------------------

Command "C:\Users\user\AppData\Local\Continuum\anaconda3\envs\chemenv\python.exe -u -c "import setuptools, tokenize;file='C:\Users\user\AppData\Local\Temp\pip-install-09n7kkgs\costsensitive\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\user\AppData\Local\Temp\pip-record-y9pf5l92\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-install-09n7kkgs\costsensitive\

any idea?

Cost-sensitive binary classification

Can cost-sensitive classifier (say WeightedAllPairs) be used for binary classification problem. We noticed assertion error for all the methods except CostProportionateClassifier. Could you please explain why other methods are not suitable for binary classification.
And can you suggest which method would be appropriate for cost-sensitive binary classifier.

Following the example and in the fit function I got the error

Hi ,

I am following the example provided in the ipython notebook and when it calls the fit:
Traceback (most recent call last):
File "multiclass.py", line 71, in
costsensitive_WAP.fit(X_train, C_train)
File "/home/fang587/.local/lib/python2.7/site-packages/costsensitive/init.py", line 83, in fit
self.classifiers[ix].fit(X_take, y_take, sample_weight=w_take)
File "/home/fang587/.local/lib/python2.7/site-packages/sklearn/linear_model/logistic.py", line 1288, in fit
accept_large_sparse=solver != 'liblinear')
File "/home/fang587/.local/lib/python2.7/site-packages/sklearn/utils/validation.py", line 756, in check_X_y
estimator=estimator)
File "/home/fang587/.local/lib/python2.7/site-packages/sklearn/utils/validation.py", line 582, in check_array
context))
ValueError: Found array with 0 sample(s) (shape=(0, 54)) while a minimum of 1 is required.

The shape of my X_train and C_train looks like this:
(522910, 54)
(522910, 7)

I have tested with different classifiers, with different inputs, I always get this error.

How do we get other evaluation metrics to run

Hi David !
I was wondering, how can we check for the evaluation metrics like precision, recall, f1-score, and AUROC using the cost sensitive library? Based on the documentation, it didn't talk about how to address these. We can only get the accuracy. I'd appreciate your feedback on this. Look forward to hearing from you.

Installation problem

Hey, hope you're doing well.

I'm trying to install your package with a 3.10 python, but I ran into an error. The first one was this one :

Collecting costsensitive
  Downloading costsensitive-0.1.2.13.post11.tar.gz (13 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy>=1.25 in c:\users\adrie\desktop\webyn_detection\.venv\lib\site-packages (from costsensitive) (1.26.4)
Requirement already satisfied: scipy in c:\users\adrie\desktop\webyn_detection\.venv\lib\site-packages (from costsensitive) (1.12.0)
Requirement already satisfied: joblib>=0.13 in c:\users\adrie\desktop\webyn_detection\.venv\lib\site-packages (from costsensitive) (1.3.2)
Collecting cython (from costsensitive)
  Obtaining dependency information for cython from https://files.pythonhosted.org/packages/83/42/9537a513d7d83196ab5973d911056eb22a639e04162fd649cf74b4dac3f1/Cython-3.0.10-cp310-cp310-win_amd64.whl.metadata
  Using cached Cython-3.0.10-cp310-cp310-win_amd64.whl.metadata (3.2 kB)
Using cached Cython-3.0.10-cp310-cp310-win_amd64.whl (2.8 MB)
Building wheels for collected packages: costsensitive
  Building wheel for costsensitive (pyproject.toml) ... error
  error: subprocess-exited-with-error
  × Building wheel for costsensitive (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      C:\Users\adrie\AppData\Local\Temp\pip-build-env-l3241rgm\overlay\Lib\site-packages\setuptools\dist.py:318: InformationOnly: Normalizing '0.1.2.13-11' to '0.1.2.13.post11'
        self.metadata.version = self._normalize_version(self.metadata.version)
      C:\Users\adrie\AppData\Local\Temp\pip-build-env-l3241rgm\overlay\Lib\site-packages\setuptools\dist.py:476: SetuptoolsDeprecationWarning: Invalid dash-separated options
      !!
              ********************************************************************************
              Usage of dash-separated 'description-file' will not be supported in future
              versions. Please use the underscore name 'description_file' instead.
              By 2024-Sep-26, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.
              See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
              ********************************************************************************
      !!
        opt = self.warn_dash_deprecation(opt, section)
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-310
      creating build\lib.win-amd64-cpython-310\costsensitive
      copying costsensitive\__init__.py -> build\lib.win-amd64-cpython-310\costsensitive
      running build_ext
      Compiling costsensitive/vwrapper.pyx because it changed.
      [1/1] Cythonizing costsensitive/vwrapper.pyx
      building 'costsensitive._vwrapper' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for costsensitive
Failed to build costsensitive
ERROR: Could not build wheels for costsensitive, which is required to install pyproject.toml-based projects

As said in the error, I installed Microsoft Visual C++ 14+ and restarted. I then ran on this error :

Collecting costsensitive
  Using cached costsensitive-0.1.2.13.post11.tar.gz (13 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: numpy>=1.25 in c:\users\adrie\desktop\webyn_detection\.venv\lib\site-packages (from costsensitive) (1.26.4)
Requirement already satisfied: scipy in c:\users\adrie\desktop\webyn_detection\.venv\lib\site-packages (from costsensitive) (1.12.0)
Requirement already satisfied: joblib>=0.13 in c:\users\adrie\desktop\webyn_detection\.venv\lib\site-packages (from costsensitive) (1.3.2)
Requirement already satisfied: cython in c:\users\adrie\desktop\webyn_detection\.venv\lib\site-packages (from costsensitive) (3.0.10)
Building wheels for collected packages: costsensitive
  Building wheel for costsensitive (pyproject.toml): started
  Building wheel for costsensitive (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error

  Building wheel for costsensitive (pyproject.toml) did not run successfully.
  exit code: 1

  [35 lines of output]
  C:\Users\adrie\AppData\Local\Temp\pip-build-env-13sd2ay4\overlay\Lib\site-packages\setuptools\dist.py:318: InformationOnly: Normalizing '0.1.2.13-11' to '0.1.2.13.post11'
    self.metadata.version = self._normalize_version(self.metadata.version)
  C:\Users\adrie\AppData\Local\Temp\pip-build-env-13sd2ay4\overlay\Lib\site-packages\setuptools\dist.py:476: SetuptoolsDeprecationWarning: Invalid dash-separated options
  !!

          ********************************************************************************
          Usage of dash-separated 'description-file' will not be supported in future
          versions. Please use the underscore name 'description_file' instead.

          By 2024-Sep-26, you need to update your project and remove deprecated calls
          or your builds will no longer be supported.

          See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
          ********************************************************************************

  !!
    opt = self.warn_dash_deprecation(opt, section)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-cpython-310
  creating build\lib.win-amd64-cpython-310\costsensitive
  copying costsensitive\__init__.py -> build\lib.win-amd64-cpython-310\costsensitive
  running build_ext
  Compiling costsensitive/vwrapper.pyx because it changed.
  [1/1] Cythonizing costsensitive/vwrapper.pyx
  building 'costsensitive._vwrapper' extension
  creating build\temp.win-amd64-cpython-310
  creating build\temp.win-amd64-cpython-310\Release
  creating build\temp.win-amd64-cpython-310\Release\costsensitive
  "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -IC:\Users\adrie\AppData\Local\Temp\pip-build-env-13sd2ay4\overlay\Lib\site-packages\numpy\core\include -IC:\Users\adrie\Desktop\webyn_detection\.venv\include -IC:\Users\adrie\AppData\Local\Programs\Python\Python310\include -IC:\Users\adrie\AppData\Local\Programs\Python\Python310\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" /Tccostsensitive/vwrapper.c /Fobuild\temp.win-amd64-cpython-310\Release\costsensitive/vwrapper.obj /O2 /openmp /GL
  vwrapper.c
  C:\Users\adrie\AppData\Local\Temp\pip-install-dpwr1qnw\costsensitive_887eee7a305648c4b40497429e1da57c\costsensitive\../src/calcv.c(112): error C3015: forme incorrecte de l'initialisation dans l'instruction 'for' OpenMP
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for costsensitive
Failed to build costsensitive
ERROR: Could not build wheels for costsensitive, which is required to install pyproject.toml-based projects

Do you have any idea of what I can do to correct this one ?
The error means that the initialization in the instruction 'for' OpenMP has an incorrect form.
Thanks !

Installation problem

Hi David, how are you? I hope you are well.

I tried to install the library but I got this error:

Collecting costsensitive
Using cached https://files.pythonhosted.org/packages/08/01/9d8a0c5c07db31ba8b17ccc0506db0d899ef342a9a57fa937b9b8b01c066/costsensitive-0.1.2.10.tar.gz
Requirement already up-to-date: cython in /home/notebooks/venv/lib/python3.6/site-packages (from costsensitive)
Requirement already up-to-date: joblib>=0.13 in /home/notebooks/venv/lib/python3.6/site-packages (from costsensitive)
Collecting numpy (from costsensitive)
Downloading https://files.pythonhosted.org/packages/19/b9/bda9781f0a74b90ebd2e046fde1196182900bd4a8e1ea503d3ffebc50e7c/numpy-1.17.0-cp36-cp36m-manylinux1_x86_64.whl (20.4MB)
100% |████████████████████████████████| 20.4MB 96kB/s s eta 0:00:01
Requirement already up-to-date: scipy in /home/notebooks/venv/lib/python3.6/site-packages (from costsensitive)
Building wheels for collected packages: costsensitive
Running setup.py bdist_wheel for costsensitive ... error
Complete output from command /home/notebooks/venv/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-652t1zkx/costsensitive/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /tmp/tmp6frkpu00pip-wheel- --python-tag cp36:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help

error: invalid command 'bdist_wheel'


Failed building wheel for costsensitive
Running setup.py clean for costsensitive
Failed to build costsensitive
Installing collected packages: numpy, costsensitive
Found existing installation: numpy 1.16.4
Uninstalling numpy-1.16.4:
Successfully uninstalled numpy-1.16.4
Running setup.py install for costsensitive ... error
Complete output from command /home/notebooks/venv/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-652t1zkx/costsensitive/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-08s1e5tx-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/notebooks/venv/include/site/python3.6/costsensitive:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/costsensitive
copying costsensitive/init.py -> build/lib.linux-x86_64-3.6/costsensitive
running build_ext
cythoning costsensitive/vwrapper.pyx to costsensitive/vwrapper.c
/home/notebooks/venv/lib/python3.6/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /tmp/pip-build-652t1zkx/costsensitive/costsensitive/vwrapper.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
building 'costsensitive._vwrapper' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/costsensitive
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/notebooks/venv/lib/python3.6/site-packages/numpy/core/include -I/home/notebooks/venv/include -I/usr/include/python3.6m -c costsensitive/vwrapper.c -o build/temp.linux-x86_64-3.6/costsensitive/vwrapper.o -O2 -march=native -std=c99 -fopenmp
costsensitive/vwrapper.c:4:10: fatal error: Python.h: No such file or directory
#include "Python.h"
^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/home/notebooks/venv/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-652t1zkx/costsensitive/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-08s1e5tx-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/notebooks/venv/include/site/python3.6/costsensitive" failed with error code 1 in /tmp/pip-build-652t1zkx/costsensitive/

Unable to install library version 0.1.2.8 in Mac OS Mojave

    ERROR: running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.7-x86_64-3.6
    creating build/lib.macosx-10.7-x86_64-3.6/costsensitive
    copying costsensitive/__init__.py -> build/lib.macosx-10.7-x86_64-3.6/costsensitive
    running build_ext
    skipping 'costsensitive/vwrapper.c' Cython extension (up-to-date)
    building 'costsensitive._vwrapper' extension
    creating build/temp.macosx-10.7-x86_64-3.6
    creating build/temp.macosx-10.7-x86_64-3.6/costsensitive
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/anujkatiyal/miniconda3/envs/scientific_py36/include -arch x86_64 -I/Users/anujkatiyal/miniconda3/envs/scientific_py36/include -arch x86_64 -I/Users/anujkatiyal/miniconda3/envs/scientific_py36/lib/python3.6/site-packages/numpy/core/include -I/Users/anujkatiyal/miniconda3/envs/scientific_py36/include/python3.6m -c costsensitive/vwrapper.c -o build/temp.macosx-10.7-x86_64-3.6/costsensitive/vwrapper.o -fopenmp -O2 -march=native -std=c99
    clang: error: unsupported option '-fopenmp'
    error: command 'gcc' failed with exit status 1```

As mentioned by another user, library version 0.1.1 installs correctly 

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.