Git Product home page Git Product logo

Comments (11)

yjhjstz avatar yjhjstz commented on August 12, 2024 2

decision values are always the same, I need to know every predict data probability result .

from libsvm.

abhikr360 avatar abhikr360 commented on August 12, 2024 1

Hi,
I also need probabilities in one class SVM for my project. Previous request request was made 2 years ago but the feature wasn't implemented.

Please consider, Thanks

from libsvm.

mattsliv avatar mattsliv commented on August 12, 2024 1

@Al-Murphy If the probabilities values are very close to 0 or 1, it could mean that the variance of error of your classification is very low. With reference to the image in your StackOverflow post, this might be the case since your actual data is easily separable. Maybe try it on data that has some higher error variance?

I would like to note though, the project I was using this for changed and is not needed so I have not been using this on various amounts of data.

@mattsliv, sorry to dig this thread up but did you implement that approach you have written above? I tried to take a similar approach in R but it would appear the cross-validated logistic regression model applied to the results of the one-class svm separates the data perfectly so I get probabilities extremely close to 0 or 1. I have a stackoverflow post showing a nice visual of my issue.

from libsvm.

cjlin1 avatar cjlin1 commented on August 12, 2024 1

One-class svm prob outputs were introduced in version 3.3 in August 2022. Sorry for the delay.

from libsvm.

cjlin1 avatar cjlin1 commented on August 12, 2024

We don't have that yet.. You can use decision values to get
prob outputs but it's unclear yet if the result is good..
Jianghua.yjh writes:

I need to probability of one-class svm, thanks.

please consider.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the
thread.*

from libsvm.

lbraga avatar lbraga commented on August 12, 2024

Hi,
with one-class you can use 'svm_predict_values' function and get 'x' decision value. It's not probability, but maybe it could be useful.

See

libsvm/svm.cpp

Line 2577 in 3648ef3

double svm_predict(const svm_model *model, const svm_node *x)

from libsvm.

RockLeeStudio avatar RockLeeStudio commented on August 12, 2024

Any new methods?

from libsvm.

mattsliv avatar mattsliv commented on August 12, 2024

You can use Platt Scalling to create a probability distribution from the outputs of your one-class SVM.

Essentially, it fits a logistic regression model with cross-validation on your one-class SVM predictions to get the probability values you would normally get with the predict_proba(X) function.

Let oc_svm be your one-class SVM and X be the data you fitted oc_svm on. To get the probability estimates you are looking for, you can do something like this.

# Imports
from sklearn.linear_model import LogisticRegressionCV as LRCV
from sklearn.model_selection import train_test_split

def platt_scale(oc_svm, X, train_size, cv_size):
	# Get SVM predictions
	y_pred = oc_svm_.predict(X)
		
	# Split the data and SVM labels
	X_train, _, y_train, _ = train_test_split(X, y_pred, train_size=train_size)

	# Train using logistic regression with cross-validation 
	lr = LRCV(cv=cv_size)
	lr.fit(X_train, y_train)

	return lr.predict_proba(X)

from libsvm.

Al-Murphy avatar Al-Murphy commented on August 12, 2024

@mattsliv, sorry to dig this thread up but did you implement that approach you have written above? I tried to take a similar approach in R but it would appear the cross-validated logistic regression model applied to the results of the one-class svm separates the data perfectly so I get probabilities extremely close to 0 or 1. I have a stackoverflow post showing a nice visual of my issue.

from libsvm.

aminadibi avatar aminadibi commented on August 12, 2024

Sad to see this useful feature is still not implemented 7 years after the initial request.

from libsvm.

aminadibi avatar aminadibi commented on August 12, 2024

Fantastic! Thanks!

from libsvm.

Related Issues (20)

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.