Documentation
Classes
NuSVC

NuSVC

Nu-Support Vector Classification.

Similar to SVC but uses a parameter to control the number of support vectors.

The implementation is based on libsvm.

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new NuSVC(opts?: object): NuSVC;

Parameters

NameTypeDescription
opts?object-
opts.break_ties?booleanIf true, decision\_function\_shape='ovr', and number of classes > 2, predict will break ties according to the confidence values of decision_function; otherwise the first class among the tied classes is returned. Please note that breaking ties comes at a relatively high computational cost compared to a simple predict. Default Value false
opts.cache_size?numberSpecify the size of the kernel cache (in MB). Default Value 200
opts.class_weight?anySet the parameter C of class i to class_weight[i]*C for SVC. If not given, all classes are supposed to have weight one. The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies as n\_samples / (n\_classes \* np.bincount(y)).
opts.coef0?numberIndependent term in kernel function. It is only significant in ‘poly’ and ‘sigmoid’. Default Value 0
opts.decision_function_shape?"ovr" | "ovo"Whether to return a one-vs-rest (‘ovr’) decision function of shape (n_samples, n_classes) as all other classifiers, or the original one-vs-one (‘ovo’) decision function of libsvm which has shape (n_samples, n_classes * (n_classes - 1) / 2). However, one-vs-one (‘ovo’) is always used as multi-class strategy. The parameter is ignored for binary classification. Default Value 'ovr'
opts.degree?numberDegree of the polynomial kernel function (‘poly’). Must be non-negative. Ignored by all other kernels. Default Value 3
opts.gamma?number | "auto" | "scale"Kernel coefficient for ‘rbf’, ‘poly’ and ‘sigmoid’. Default Value 'scale'
opts.kernel?"sigmoid" | "precomputed" | "linear" | "poly" | "rbf"Specifies the kernel type to be used in the algorithm. If none is given, ‘rbf’ will be used. If a callable is given it is used to precompute the kernel matrix. Default Value 'rbf'
opts.max_iter?numberHard limit on iterations within solver, or -1 for no limit. Default Value -1
opts.nu?numberAn upper bound on the fraction of margin errors (see User Guide) and a lower bound of the fraction of support vectors. Should be in the interval (0, 1]. Default Value 0.5
opts.probability?booleanWhether to enable probability estimates. This must be enabled prior to calling fit, will slow down that method as it internally uses 5-fold cross-validation, and predict\_proba may be inconsistent with predict. Read more in the User Guide. Default Value false
opts.random_state?numberControls the pseudo random number generation for shuffling the data for probability estimates. Ignored when probability is false. Pass an int for reproducible output across multiple function calls. See Glossary.
opts.shrinking?booleanWhether to use the shrinking heuristic. See the User Guide. Default Value true
opts.tol?numberTolerance for stopping criterion. Default Value 0.001
opts.verbose?booleanEnable verbose output. Note that this setting takes advantage of a per-process runtime setting in libsvm that, if enabled, may not work properly in a multithreaded context. Default Value false

Returns

NuSVC

Defined in: generated/svm/NuSVC.ts:27 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/svm/NuSVC.ts:25 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/svm/NuSVC.ts:24 (opens in a new tab)

_py

PythonBridge

Defined in: generated/svm/NuSVC.ts:23 (opens in a new tab)

id

string

Defined in: generated/svm/NuSVC.ts:20 (opens in a new tab)

opts

any

Defined in: generated/svm/NuSVC.ts:21 (opens in a new tab)

Accessors

class_weight_

Multipliers of parameter C of each class. Computed based on the class\_weight parameter.

Signature

class_weight_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/svm/NuSVC.ts:452 (opens in a new tab)

classes_

The unique classes labels.

Signature

classes_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/svm/NuSVC.ts:475 (opens in a new tab)

dual_coef_

Dual coefficients of the support vector in the decision function (see Mathematical formulation), multiplied by their targets. For multiclass, coefficient for all 1-vs-1 classifiers. The layout of the coefficients in the multiclass case is somewhat non-trivial. See the multi-class section of the User Guide for details.

Signature

dual_coef_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/svm/NuSVC.ts:497 (opens in a new tab)

feature_names_in_

Names of features seen during fit. Defined only when X has feature names that are all strings.

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/svm/NuSVC.ts:589 (opens in a new tab)

fit_status_

0 if correctly fitted, 1 if the algorithm did not converge.

Signature

fit_status_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/svm/NuSVC.ts:520 (opens in a new tab)

intercept_

Constants in decision function.

Signature

intercept_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/svm/NuSVC.ts:543 (opens in a new tab)

n_features_in_

Number of features seen during fit.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/svm/NuSVC.ts:566 (opens in a new tab)

n_iter_

Number of iterations run by the optimization routine to fit the model. The shape of this attribute depends on the number of models optimized which in turn depends on the number of classes.

Signature

n_iter_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/svm/NuSVC.ts:614 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/svm/NuSVC.ts:133 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/svm/NuSVC.ts:137 (opens in a new tab)

shape_fit_

Array dimensions of training vector X.

Signature

shape_fit_(): Promise<any[]>;

Returns

Promise<any[]>

Defined in: generated/svm/NuSVC.ts:683 (opens in a new tab)

support_

Indices of support vectors.

Signature

support_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/svm/NuSVC.ts:636 (opens in a new tab)

support_vectors_

Support vectors.

Signature

support_vectors_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/svm/NuSVC.ts:658 (opens in a new tab)

Methods

decision_function()

Evaluate the decision function for the samples in X.

Signature

decision_function(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]The input samples.

Returns

Promise<ArrayLike[]>

Defined in: generated/svm/NuSVC.ts:218 (opens in a new tab)

dispose()

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/svm/NuSVC.ts:201 (opens in a new tab)

fit()

Fit the SVM model according to the given training data.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeTraining vectors, where n\_samples is the number of samples and n\_features is the number of features. For kernel=”precomputed”, the expected shape of X is (n_samples, n_samples).
opts.sample_weight?ArrayLikePer-sample weights. Rescale C per sample. Higher weights force the classifier to put more emphasis on these points.
opts.y?ArrayLikeTarget values (class labels in classification, real numbers in regression).

Returns

Promise<any>

Defined in: generated/svm/NuSVC.ts:251 (opens in a new tab)

init()

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/svm/NuSVC.ts:146 (opens in a new tab)

predict()

Perform classification on samples in X.

For an one-class model, +1 or -1 is returned.

Signature

predict(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeFor kernel=”precomputed”, the expected shape of X is (n_samples_test, n_samples_train).

Returns

Promise<ArrayLike>

Defined in: generated/svm/NuSVC.ts:300 (opens in a new tab)

predict_log_proba()

Compute log probabilities of possible outcomes for samples in X.

The model need to have probability information computed at training time: fit with attribute probability set to true.

Signature

predict_log_proba(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]For kernel=”precomputed”, the expected shape of X is (n_samples_test, n_samples_train).

Returns

Promise<ArrayLike[]>

Defined in: generated/svm/NuSVC.ts:335 (opens in a new tab)

predict_proba()

Compute probabilities of possible outcomes for samples in X.

The model need to have probability information computed at training time: fit with attribute probability set to true.

Signature

predict_proba(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]For kernel=”precomputed”, the expected shape of X is (n_samples_test, n_samples_train).

Returns

Promise<ArrayLike[]>

Defined in: generated/svm/NuSVC.ts:370 (opens in a new tab)

score()

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Signature

score(opts: object): Promise<number>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Test samples.
opts.sample_weight?ArrayLikeSample weights.
opts.y?ArrayLikeTrue labels for X.

Returns

Promise<number>

Defined in: generated/svm/NuSVC.ts:405 (opens in a new tab)