Coder Social home page Coder Social logo

mir-am / libtwinsvm Goto Github PK

View Code? Open in Web Editor NEW
20.0 20.0 8.0 6.72 MB

A Library for Twin Support Vector Machines

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

License: GNU General Public License v3.0

Python 95.16% C++ 2.76% Cython 2.08%
api fast gui implementation library ltsvm machinelearning optimizer tsvm twinsvm

libtwinsvm's People

Contributors

mahdirahbar avatar mir-am avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

libtwinsvm's Issues

installing the libtwinsvm from source on windows

after installing all the requirements i get this error that says that both numpy library and cython are not found. any idea to fix the issue????

PS C:\Users\Zbook> pip install LIBTwinSVM
Collecting LIBTwinSVM
Using cached LIBTwinSVM-0.3.0.tar.gz (5.2 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [31 lines of output]
Traceback (most recent call last):
File "", line 116, in get_numpy_status
ModuleNotFoundError: No module named 'numpy'
Traceback (most recent call last):
File "", line 142, in get_cython_status
ModuleNotFoundError: No module named 'cython'
Traceback (most recent call last):
File "C:\Users\Zbook\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in
main()
File "C:\Users\Zbook\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Zbook\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Zbook\AppData\Local\Temp\pip-build-env-8u8l0hbp\overlay\Lib\site-packages\setuptools\build_meta.py", line 341, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Zbook\AppData\Local\Temp\pip-build-env-8u8l0hbp\overlay\Lib\site-packages\setuptools\build_meta.py", line 323, in _get_build_requires
self.run_setup()
File "C:\Users\Zbook\AppData\Local\Temp\pip-build-env-8u8l0hbp\overlay\Lib\site-packages\setuptools\build_meta.py", line 488, in run_setup
self).run_setup(setup_script=setup_script)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Zbook\AppData\Local\Temp\pip-build-env-8u8l0hbp\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in run_setup
exec(code, locals())
File "", line 322, in
File "", line 256, in setup_package
File "", line 177, in check_install_updated
ImportError: Numerical Python (NumPy) is not installed. LIBTwinSVM requires NumPy >= 1.14.0.
Please check out the installation guide of the LIBTwinSVM:
https://libtwinsvm.readthedocs.io/en/latest/
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

Getting std::logic_error

My code:

from time import process_time
from typing import List, Tuple

import numpy as np
from sklearn.datasets import make_classification
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split

from libtsvm.estimators import TSVM
from sklearn.svm import SVC as sklearn_SVC


def get_dataset():
    # create synthetic dataset
    X, y = make_classification(n_samples=10000, n_features=100,
                               n_informative=90, n_redundant=10,
                               random_state=0)
    X_train, X_test, y_train, y_test = train_test_split(X, y,
                                                        test_size=.2,
                                                        random_state=0)
    return X_train, X_test, y_train, y_test


def test_twin_SVM(X_train: np.ndarray,
                  X_test: np.ndarray,
                  y_train: np.ndarray,
                  y_test: np.ndarray) \
        -> Tuple[List[float], List[float]]:
    clf = TSVM()
    #clf = sklearn_SVC()
    times = []
    sizes = list(range(1000, 10001, 1000))
    accuracies = []

    print("TwinSVM start")
    for size in sizes:
        print(size)
        X_train_smaller = X_train[:size, :]
        y_train_smaller = y_train[:size]

        time1 = process_time()
        clf.fit(X_train_smaller, y_train_smaller)
        time2 = process_time()
        times.append(time2 - time1)

        acc = accuracy_score(y_test, clf.predict(X_test))
        accuracies.append(acc)
    print()

    return times, accuracies

X_train, X_test, y_train, y_test = get_dataset()
twin_times, twin_accuracies = test_twin_SVM(X_train, X_test,
                                                y_train, y_test)

Output and error:

TwinSVM start
1000

error: index_max(): object has no elements
terminate called after throwing an instance of 'std::logic_error'
  what():  index_max(): object has no elements

What is happening, why am I getting this error? Sklearn SVM is working fine, I've also tried it (commented out in the code above).

Kernel Restarting The kernel appears to have died. It will restart automatically.

from libtsvm.estimators import TSVM
from tensorflow.keras import backend as K
m_temp = tf.keras.Model(inputs=model.input, outputs=model.get_layer('drop_out').output)
t = m_temp.predict(train_ids)
arr = K.eval(t)

lssvc_concat = TSVM(kernel='linear') # Class instantiation

lssvc_concat.fit(arr, train_labels.ravel()) # Fitting the mode

This is my code. I have taken the weights from some deep learning model and I am trying to add the classifier TSVM. Until class instantiation, it is working fine. But while fitting, I am getting like "The kernel appears to have died. It will restart automatically". Kindly help me in this regard.

Thanks in advance...

Error in Evaluation Step

I am trying to do the TWSVM with OVO. I saw the document and followed the instructions. I got stuck in this part:
'acc, std, full_report = eval_func(h_params)'

When I tried to run the code, I got this error:
'TypeError: Expected sequence or array-like, got <class 'NoneType'>'

I already make sure that X and y are not empty. Can you please help me?

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.