-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
NuSVC.ts
811 lines (647 loc) · 26 KB
/
NuSVC.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
/* eslint-disable */
/* NOTE: This file is auto-generated. Do not edit it directly. */
import crypto from 'node:crypto'
import { PythonBridge, NDArray, ArrayLike, SparseMatrix } from '@/sklearn/types'
/**
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](../svm.html#svm-classification).
[Python Reference](https://scikit-learn.org/stable/modules/generated/sklearn.svm.NuSVC.html)
*/
export class NuSVC {
id: string
opts: any
_py: PythonBridge
_isInitialized: boolean = false
_isDisposed: boolean = false
constructor(opts?: {
/**
An upper bound on the fraction of margin errors (see [User Guide](../svm.html#nu-svc)) and a lower bound of the fraction of support vectors. Should be in the interval (0, 1\].
@defaultValue `0.5`
*/
nu?: number
/**
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. For an intuitive visualization of different kernel types see [Plot classification boundaries with different SVM Kernels](../../auto_examples/svm/plot_svm_kernels.html#sphx-glr-auto-examples-svm-plot-svm-kernels-py).
@defaultValue `'rbf'`
*/
kernel?: 'linear' | 'poly' | 'rbf' | 'sigmoid' | 'precomputed'
/**
Degree of the polynomial kernel function (‘poly’). Must be non-negative. Ignored by all other kernels.
@defaultValue `3`
*/
degree?: number
/**
Kernel coefficient for ‘rbf’, ‘poly’ and ‘sigmoid’.
@defaultValue `'scale'`
*/
gamma?: 'scale' | 'auto' | number
/**
Independent term in kernel function. It is only significant in ‘poly’ and ‘sigmoid’.
@defaultValue `0`
*/
coef0?: number
/**
Whether to use the shrinking heuristic. See the [User Guide](../svm.html#shrinking-svm).
@defaultValue `true`
*/
shrinking?: boolean
/**
Whether 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](../svm.html#scores-probabilities).
@defaultValue `false`
*/
probability?: boolean
/**
Tolerance for stopping criterion.
@defaultValue `0.001`
*/
tol?: number
/**
Specify the size of the kernel cache (in MB).
@defaultValue `200`
*/
cache_size?: number
/**
Set 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))`.
*/
class_weight?: any | 'balanced'
/**
Enable 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.
@defaultValue `false`
*/
verbose?: boolean
/**
Hard limit on iterations within solver, or -1 for no limit.
@defaultValue `-1`
*/
max_iter?: number
/**
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.
@defaultValue `'ovr'`
*/
decision_function_shape?: 'ovo' | 'ovr'
/**
If true, `decision\_function\_shape='ovr'`, and number of classes > 2, [predict](../../glossary.html#term-predict) will break ties according to the confidence values of [decision\_function](../../glossary.html#term-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.
@defaultValue `false`
*/
break_ties?: boolean
/**
Controls 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](../../glossary.html#term-random_state).
*/
random_state?: number
}) {
this.id = `NuSVC${crypto.randomUUID().split('-')[0]}`
this.opts = opts || {}
}
get py(): PythonBridge {
return this._py
}
set py(pythonBridge: PythonBridge) {
this._py = pythonBridge
}
/**
Initializes the underlying Python resources.
This instance is not usable until the `Promise` returned by `init()` resolves.
*/
async init(py: PythonBridge): Promise<void> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (this._isInitialized) {
return
}
if (!py) {
throw new Error('NuSVC.init requires a PythonBridge instance')
}
this._py = py
await this._py.ex`
import numpy as np
from sklearn.svm import NuSVC
try: bridgeNuSVC
except NameError: bridgeNuSVC = {}
`
// set up constructor params
await this._py.ex`ctor_NuSVC = {'nu': ${
this.opts['nu'] ?? undefined
}, 'kernel': ${this.opts['kernel'] ?? undefined}, 'degree': ${
this.opts['degree'] ?? undefined
}, 'gamma': ${this.opts['gamma'] ?? undefined}, 'coef0': ${
this.opts['coef0'] ?? undefined
}, 'shrinking': ${this.opts['shrinking'] ?? undefined}, 'probability': ${
this.opts['probability'] ?? undefined
}, 'tol': ${this.opts['tol'] ?? undefined}, 'cache_size': ${
this.opts['cache_size'] ?? undefined
}, 'class_weight': ${this.opts['class_weight'] ?? undefined}, 'verbose': ${
this.opts['verbose'] ?? undefined
}, 'max_iter': ${
this.opts['max_iter'] ?? undefined
}, 'decision_function_shape': ${
this.opts['decision_function_shape'] ?? undefined
}, 'break_ties': ${this.opts['break_ties'] ?? undefined}, 'random_state': ${
this.opts['random_state'] ?? undefined
}}
ctor_NuSVC = {k: v for k, v in ctor_NuSVC.items() if v is not None}`
await this._py.ex`bridgeNuSVC[${this.id}] = NuSVC(**ctor_NuSVC)`
this._isInitialized = true
}
/**
Disposes of the underlying Python resources.
Once `dispose()` is called, the instance is no longer usable.
*/
async dispose() {
if (this._isDisposed) {
return
}
if (!this._isInitialized) {
return
}
await this._py.ex`del bridgeNuSVC[${this.id}]`
this._isDisposed = true
}
/**
Evaluate the decision function for the samples in X.
*/
async decision_function(opts: {
/**
The input samples.
*/
X?: ArrayLike[]
}): Promise<NDArray[]> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before decision_function()')
}
// set up method params
await this._py.ex`pms_NuSVC_decision_function = {'X': np.array(${
opts['X'] ?? undefined
}) if ${opts['X'] !== undefined} else None}
pms_NuSVC_decision_function = {k: v for k, v in pms_NuSVC_decision_function.items() if v is not None}`
// invoke method
await this._py
.ex`res_NuSVC_decision_function = bridgeNuSVC[${this.id}].decision_function(**pms_NuSVC_decision_function)`
// convert the result from python to node.js
return this
._py`res_NuSVC_decision_function.tolist() if hasattr(res_NuSVC_decision_function, 'tolist') else res_NuSVC_decision_function`
}
/**
Fit the SVM model according to the given training data.
*/
async fit(opts: {
/**
Training 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).
*/
X?: ArrayLike | SparseMatrix[]
/**
Target values (class labels in classification, real numbers in regression).
*/
y?: ArrayLike
/**
Per-sample weights. Rescale C per sample. Higher weights force the classifier to put more emphasis on these points.
*/
sample_weight?: ArrayLike
}): Promise<any> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before fit()')
}
// set up method params
await this._py.ex`pms_NuSVC_fit = {'X': np.array(${
opts['X'] ?? undefined
}) if ${opts['X'] !== undefined} else None, 'y': np.array(${
opts['y'] ?? undefined
}) if ${opts['y'] !== undefined} else None, 'sample_weight': np.array(${
opts['sample_weight'] ?? undefined
}) if ${opts['sample_weight'] !== undefined} else None}
pms_NuSVC_fit = {k: v for k, v in pms_NuSVC_fit.items() if v is not None}`
// invoke method
await this._py
.ex`res_NuSVC_fit = bridgeNuSVC[${this.id}].fit(**pms_NuSVC_fit)`
// convert the result from python to node.js
return this
._py`res_NuSVC_fit.tolist() if hasattr(res_NuSVC_fit, 'tolist') else res_NuSVC_fit`
}
/**
Get metadata routing of this object.
Please check [User Guide](../../metadata_routing.html#metadata-routing) on how the routing mechanism works.
*/
async get_metadata_routing(opts: {
/**
A [`MetadataRequest`](sklearn.utils.metadata_routing.MetadataRequest.html#sklearn.utils.metadata_routing.MetadataRequest "sklearn.utils.metadata_routing.MetadataRequest") encapsulating routing information.
*/
routing?: any
}): Promise<any> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before get_metadata_routing()')
}
// set up method params
await this._py.ex`pms_NuSVC_get_metadata_routing = {'routing': ${
opts['routing'] ?? undefined
}}
pms_NuSVC_get_metadata_routing = {k: v for k, v in pms_NuSVC_get_metadata_routing.items() if v is not None}`
// invoke method
await this._py
.ex`res_NuSVC_get_metadata_routing = bridgeNuSVC[${this.id}].get_metadata_routing(**pms_NuSVC_get_metadata_routing)`
// convert the result from python to node.js
return this
._py`res_NuSVC_get_metadata_routing.tolist() if hasattr(res_NuSVC_get_metadata_routing, 'tolist') else res_NuSVC_get_metadata_routing`
}
/**
Perform classification on samples in X.
For an one-class model, +1 or -1 is returned.
*/
async predict(opts: {
/**
For kernel=”precomputed”, the expected shape of X is (n\_samples\_test, n\_samples\_train).
*/
X?: ArrayLike | SparseMatrix[]
}): Promise<NDArray> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before predict()')
}
// set up method params
await this._py.ex`pms_NuSVC_predict = {'X': np.array(${
opts['X'] ?? undefined
}) if ${opts['X'] !== undefined} else None}
pms_NuSVC_predict = {k: v for k, v in pms_NuSVC_predict.items() if v is not None}`
// invoke method
await this._py
.ex`res_NuSVC_predict = bridgeNuSVC[${this.id}].predict(**pms_NuSVC_predict)`
// convert the result from python to node.js
return this
._py`res_NuSVC_predict.tolist() if hasattr(res_NuSVC_predict, 'tolist') else res_NuSVC_predict`
}
/**
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`.
*/
async predict_log_proba(opts: {
/**
For kernel=”precomputed”, the expected shape of X is (n\_samples\_test, n\_samples\_train).
*/
X?: ArrayLike[]
}): Promise<NDArray[]> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before predict_log_proba()')
}
// set up method params
await this._py.ex`pms_NuSVC_predict_log_proba = {'X': np.array(${
opts['X'] ?? undefined
}) if ${opts['X'] !== undefined} else None}
pms_NuSVC_predict_log_proba = {k: v for k, v in pms_NuSVC_predict_log_proba.items() if v is not None}`
// invoke method
await this._py
.ex`res_NuSVC_predict_log_proba = bridgeNuSVC[${this.id}].predict_log_proba(**pms_NuSVC_predict_log_proba)`
// convert the result from python to node.js
return this
._py`res_NuSVC_predict_log_proba.tolist() if hasattr(res_NuSVC_predict_log_proba, 'tolist') else res_NuSVC_predict_log_proba`
}
/**
Compute probabilities of possible outcomes for samples in X.
The model needs to have probability information computed at training time: fit with attribute `probability` set to `true`.
*/
async predict_proba(opts: {
/**
For kernel=”precomputed”, the expected shape of X is (n\_samples\_test, n\_samples\_train).
*/
X?: ArrayLike[]
}): Promise<NDArray[]> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before predict_proba()')
}
// set up method params
await this._py.ex`pms_NuSVC_predict_proba = {'X': np.array(${
opts['X'] ?? undefined
}) if ${opts['X'] !== undefined} else None}
pms_NuSVC_predict_proba = {k: v for k, v in pms_NuSVC_predict_proba.items() if v is not None}`
// invoke method
await this._py
.ex`res_NuSVC_predict_proba = bridgeNuSVC[${this.id}].predict_proba(**pms_NuSVC_predict_proba)`
// convert the result from python to node.js
return this
._py`res_NuSVC_predict_proba.tolist() if hasattr(res_NuSVC_predict_proba, 'tolist') else res_NuSVC_predict_proba`
}
/**
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.
*/
async score(opts: {
/**
Test samples.
*/
X?: ArrayLike[]
/**
True labels for `X`.
*/
y?: ArrayLike
/**
Sample weights.
*/
sample_weight?: ArrayLike
}): Promise<number> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before score()')
}
// set up method params
await this._py.ex`pms_NuSVC_score = {'X': np.array(${
opts['X'] ?? undefined
}) if ${opts['X'] !== undefined} else None, 'y': np.array(${
opts['y'] ?? undefined
}) if ${opts['y'] !== undefined} else None, 'sample_weight': np.array(${
opts['sample_weight'] ?? undefined
}) if ${opts['sample_weight'] !== undefined} else None}
pms_NuSVC_score = {k: v for k, v in pms_NuSVC_score.items() if v is not None}`
// invoke method
await this._py
.ex`res_NuSVC_score = bridgeNuSVC[${this.id}].score(**pms_NuSVC_score)`
// convert the result from python to node.js
return this
._py`res_NuSVC_score.tolist() if hasattr(res_NuSVC_score, 'tolist') else res_NuSVC_score`
}
/**
Request metadata passed to the `fit` method.
Note that this method is only relevant if `enable\_metadata\_routing=True` (see [`sklearn.set\_config`](sklearn.set_config.html#sklearn.set_config "sklearn.set_config")). Please see [User Guide](../../metadata_routing.html#metadata-routing) on how the routing mechanism works.
The options for each parameter are:
*/
async set_fit_request(opts: {
/**
Metadata routing for `sample\_weight` parameter in `fit`.
*/
sample_weight?: string | boolean
}): Promise<any> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before set_fit_request()')
}
// set up method params
await this._py.ex`pms_NuSVC_set_fit_request = {'sample_weight': ${
opts['sample_weight'] ?? undefined
}}
pms_NuSVC_set_fit_request = {k: v for k, v in pms_NuSVC_set_fit_request.items() if v is not None}`
// invoke method
await this._py
.ex`res_NuSVC_set_fit_request = bridgeNuSVC[${this.id}].set_fit_request(**pms_NuSVC_set_fit_request)`
// convert the result from python to node.js
return this
._py`res_NuSVC_set_fit_request.tolist() if hasattr(res_NuSVC_set_fit_request, 'tolist') else res_NuSVC_set_fit_request`
}
/**
Request metadata passed to the `score` method.
Note that this method is only relevant if `enable\_metadata\_routing=True` (see [`sklearn.set\_config`](sklearn.set_config.html#sklearn.set_config "sklearn.set_config")). Please see [User Guide](../../metadata_routing.html#metadata-routing) on how the routing mechanism works.
The options for each parameter are:
*/
async set_score_request(opts: {
/**
Metadata routing for `sample\_weight` parameter in `score`.
*/
sample_weight?: string | boolean
}): Promise<any> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before set_score_request()')
}
// set up method params
await this._py.ex`pms_NuSVC_set_score_request = {'sample_weight': ${
opts['sample_weight'] ?? undefined
}}
pms_NuSVC_set_score_request = {k: v for k, v in pms_NuSVC_set_score_request.items() if v is not None}`
// invoke method
await this._py
.ex`res_NuSVC_set_score_request = bridgeNuSVC[${this.id}].set_score_request(**pms_NuSVC_set_score_request)`
// convert the result from python to node.js
return this
._py`res_NuSVC_set_score_request.tolist() if hasattr(res_NuSVC_set_score_request, 'tolist') else res_NuSVC_set_score_request`
}
/**
Multipliers of parameter C of each class. Computed based on the `class\_weight` parameter.
*/
get class_weight_(): Promise<NDArray> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before accessing class_weight_')
}
return (async () => {
// invoke accessor
await this._py
.ex`attr_NuSVC_class_weight_ = bridgeNuSVC[${this.id}].class_weight_`
// convert the result from python to node.js
return this
._py`attr_NuSVC_class_weight_.tolist() if hasattr(attr_NuSVC_class_weight_, 'tolist') else attr_NuSVC_class_weight_`
})()
}
/**
The unique classes labels.
*/
get classes_(): Promise<NDArray> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before accessing classes_')
}
return (async () => {
// invoke accessor
await this._py.ex`attr_NuSVC_classes_ = bridgeNuSVC[${this.id}].classes_`
// convert the result from python to node.js
return this
._py`attr_NuSVC_classes_.tolist() if hasattr(attr_NuSVC_classes_, 'tolist') else attr_NuSVC_classes_`
})()
}
/**
Dual coefficients of the support vector in the decision function (see [Mathematical formulation](../sgd.html#sgd-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](../svm.html#svm-multi-class) for details.
*/
get dual_coef_(): Promise<NDArray[]> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before accessing dual_coef_')
}
return (async () => {
// invoke accessor
await this._py
.ex`attr_NuSVC_dual_coef_ = bridgeNuSVC[${this.id}].dual_coef_`
// convert the result from python to node.js
return this
._py`attr_NuSVC_dual_coef_.tolist() if hasattr(attr_NuSVC_dual_coef_, 'tolist') else attr_NuSVC_dual_coef_`
})()
}
/**
0 if correctly fitted, 1 if the algorithm did not converge.
*/
get fit_status_(): Promise<number> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before accessing fit_status_')
}
return (async () => {
// invoke accessor
await this._py
.ex`attr_NuSVC_fit_status_ = bridgeNuSVC[${this.id}].fit_status_`
// convert the result from python to node.js
return this
._py`attr_NuSVC_fit_status_.tolist() if hasattr(attr_NuSVC_fit_status_, 'tolist') else attr_NuSVC_fit_status_`
})()
}
/**
Constants in decision function.
*/
get intercept_(): Promise<NDArray> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before accessing intercept_')
}
return (async () => {
// invoke accessor
await this._py
.ex`attr_NuSVC_intercept_ = bridgeNuSVC[${this.id}].intercept_`
// convert the result from python to node.js
return this
._py`attr_NuSVC_intercept_.tolist() if hasattr(attr_NuSVC_intercept_, 'tolist') else attr_NuSVC_intercept_`
})()
}
/**
Number of features seen during [fit](../../glossary.html#term-fit).
*/
get n_features_in_(): Promise<number> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before accessing n_features_in_')
}
return (async () => {
// invoke accessor
await this._py
.ex`attr_NuSVC_n_features_in_ = bridgeNuSVC[${this.id}].n_features_in_`
// convert the result from python to node.js
return this
._py`attr_NuSVC_n_features_in_.tolist() if hasattr(attr_NuSVC_n_features_in_, 'tolist') else attr_NuSVC_n_features_in_`
})()
}
/**
Names of features seen during [fit](../../glossary.html#term-fit). Defined only when `X` has feature names that are all strings.
*/
get feature_names_in_(): Promise<NDArray> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error(
'NuSVC must call init() before accessing feature_names_in_'
)
}
return (async () => {
// invoke accessor
await this._py
.ex`attr_NuSVC_feature_names_in_ = bridgeNuSVC[${this.id}].feature_names_in_`
// convert the result from python to node.js
return this
._py`attr_NuSVC_feature_names_in_.tolist() if hasattr(attr_NuSVC_feature_names_in_, 'tolist') else attr_NuSVC_feature_names_in_`
})()
}
/**
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.
*/
get n_iter_(): Promise<NDArray> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before accessing n_iter_')
}
return (async () => {
// invoke accessor
await this._py.ex`attr_NuSVC_n_iter_ = bridgeNuSVC[${this.id}].n_iter_`
// convert the result from python to node.js
return this
._py`attr_NuSVC_n_iter_.tolist() if hasattr(attr_NuSVC_n_iter_, 'tolist') else attr_NuSVC_n_iter_`
})()
}
/**
Indices of support vectors.
*/
get support_(): Promise<NDArray> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before accessing support_')
}
return (async () => {
// invoke accessor
await this._py.ex`attr_NuSVC_support_ = bridgeNuSVC[${this.id}].support_`
// convert the result from python to node.js
return this
._py`attr_NuSVC_support_.tolist() if hasattr(attr_NuSVC_support_, 'tolist') else attr_NuSVC_support_`
})()
}
/**
Support vectors.
*/
get support_vectors_(): Promise<NDArray[]> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error(
'NuSVC must call init() before accessing support_vectors_'
)
}
return (async () => {
// invoke accessor
await this._py
.ex`attr_NuSVC_support_vectors_ = bridgeNuSVC[${this.id}].support_vectors_`
// convert the result from python to node.js
return this
._py`attr_NuSVC_support_vectors_.tolist() if hasattr(attr_NuSVC_support_vectors_, 'tolist') else attr_NuSVC_support_vectors_`
})()
}
/**
Array dimensions of training vector `X`.
*/
get shape_fit_(): Promise<any[]> {
if (this._isDisposed) {
throw new Error('This NuSVC instance has already been disposed')
}
if (!this._isInitialized) {
throw new Error('NuSVC must call init() before accessing shape_fit_')
}
return (async () => {
// invoke accessor
await this._py
.ex`attr_NuSVC_shape_fit_ = bridgeNuSVC[${this.id}].shape_fit_`
// convert the result from python to node.js
return this
._py`attr_NuSVC_shape_fit_.tolist() if hasattr(attr_NuSVC_shape_fit_, 'tolist') else attr_NuSVC_shape_fit_`
})()
}
}