11import GPLVM from '../../lib/model/gplvm.js'
22import Controller from '../controller.js'
33
4- var dispGPLVM = function ( elm , platform ) {
4+ export default function ( platform ) {
5+ platform . setting . ml . usage = 'Click and add data point. Next, click "Fit" button.'
56 const controller = new Controller ( platform )
67 let model = null
78 const fitModel = ( ) => {
89 if ( ! model ) {
910 const dim = platform . dimension
10- const alpha = + elm . select ( '[name=alpha]' ) . property ( 'value' )
11- const sigma = + elm . select ( '[name=sigma]' ) . property ( 'value' )
12- const ez = + elm . select ( '[name=ez]' ) . property ( 'value' )
13- const ea = + elm . select ( '[name=ea]' ) . property ( 'value' )
14- const ep = + elm . select ( '[name=ep]' ) . property ( 'value' )
15- model = new GPLVM ( dim , alpha , ez , ea , ep , 'gaussian' , [ 1.0 , sigma ] )
11+ model = new GPLVM ( dim , alpha . value , ez . value , ea . value , ep . value , {
12+ name : kernel . value ,
13+ a : 1.0 ,
14+ b : gauss_sigma . avlue ,
15+ } )
1616 model . init ( platform . trainInput )
1717 }
1818 model . fit ( )
1919 const y = model . predict ( platform . trainInput )
2020 platform . trainResult = y
2121 }
2222
23- const kernelElm = elm . append ( 'span' )
24- kernelElm
25- . append ( 'select' )
26- . attr ( 'name' , 'kernel' )
27- . selectAll ( 'option' )
28- . data ( [ 'gaussian' ] )
29- . enter ( )
30- . append ( 'option' )
31- . attr ( 'value' , d => d )
32- . text ( d => d )
33- const gauss_sigma = kernelElm . append ( 'span' )
34- gauss_sigma
35- . append ( 'span' )
36- . text ( ' sigma = ' )
37- . append ( 'input' )
38- . attr ( 'type' , 'number' )
39- . attr ( 'name' , 'sigma' )
40- . attr ( 'value' , 1 )
41- . attr ( 'min' , 0 )
42- . attr ( 'max' , 10 )
43- . attr ( 'step' , 0.1 )
44- elm . append ( 'span' )
45- . text ( ' alpha = ' )
46- . append ( 'input' )
47- . attr ( 'type' , 'number' )
48- . attr ( 'name' , 'alpha' )
49- . attr ( 'value' , 0.05 )
50- . attr ( 'min' , 0 )
51- . attr ( 'max' , 10 )
52- . attr ( 'step' , 0.01 )
53- elm . append ( 'span' )
54- . text ( ' ez = ' )
55- . append ( 'input' )
56- . attr ( 'type' , 'number' )
57- . attr ( 'name' , 'ez' )
58- . attr ( 'value' , 1 )
59- . attr ( 'min' , 0 )
60- . attr ( 'max' , 10 )
61- . attr ( 'step' , 0.1 )
62- elm . append ( 'span' )
63- . text ( ' ea = ' )
64- . append ( 'input' )
65- . attr ( 'type' , 'number' )
66- . attr ( 'name' , 'ea' )
67- . attr ( 'value' , 0.005 )
68- . attr ( 'min' , 0 )
69- . attr ( 'max' , 10 )
70- . attr ( 'step' , 0.001 )
71- elm . append ( 'span' )
72- . text ( ' ep = ' )
73- . append ( 'input' )
74- . attr ( 'type' , 'number' )
75- . attr ( 'name' , 'ep' )
76- . attr ( 'value' , 0.02 )
77- . attr ( 'min' , 0 )
78- . attr ( 'max' , 10 )
79- . attr ( 'step' , 0.001 )
23+ const kernelElm = controller . span ( )
24+ const kernel = kernelElm . select ( [ 'gaussian' ] )
25+ const gauss_sigma = kernelElm . input . number ( { label : ' sigma = ' , min : 0 , max : 10 , step : 0.1 , value : 1 } )
26+ const alpha = controller . input . number ( { label : ' alpha = ' , min : 0 , max : 10 , step : 0.01 , value : 0.05 } )
27+ const ez = controller . input . number ( { label : ' ez = ' , min : 0 , max : 10 , step : 0.1 , value : 1 } )
28+ const ea = controller . input . number ( { label : ' ea = ' , min : 0 , max : 10 , step : 0.001 , value : 0.005 } )
29+ const ep = controller . input . number ( { label : ' ep = ' , min : 0 , max : 10 , step : 0.001 , value : 0.02 } )
8030 controller
8131 . stepLoopButtons ( )
8232 . init ( ( ) => {
@@ -86,8 +36,3 @@ var dispGPLVM = function (elm, platform) {
8636 . step ( fitModel )
8737 . epoch ( )
8838}
89-
90- export default function ( platform ) {
91- platform . setting . ml . usage = 'Click and add data point. Next, click "Fit" button.'
92- dispGPLVM ( platform . setting . ml . configElement , platform )
93- }
0 commit comments