Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
b82bad0f
Unverified
Commit
b82bad0f
authored
Jun 29, 2020
by
Lijiaoa
Committed by
GitHub
Jun 29, 2020
Browse files
Show final result keys in hyper-parameter graph (#2586)
parent
b91aba39
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
34 deletions
+87
-34
src/webui/src/components/trial-detail/Para.tsx
src/webui/src/components/trial-detail/Para.tsx
+65
-11
src/webui/src/components/trial-detail/TableList.tsx
src/webui/src/components/trial-detail/TableList.tsx
+3
-22
src/webui/src/static/model/trial.ts
src/webui/src/static/model/trial.ts
+5
-0
src/webui/src/static/model/trialmanager.ts
src/webui/src/static/model/trialmanager.ts
+10
-1
src/webui/src/static/style/para.scss
src/webui/src/static/style/para.scss
+4
-0
No files found.
src/webui/src/components/trial-detail/Para.tsx
View file @
b82bad0f
import
*
as
React
from
'
react
'
;
import
*
as
React
from
'
react
'
;
import
ReactEcharts
from
'
echarts-for-react
'
;
import
ReactEcharts
from
'
echarts-for-react
'
;
import
{
filterByStatus
}
from
'
../../static/function
'
;
import
{
filterByStatus
}
from
'
../../static/function
'
;
import
{
EXPERIMENT
}
from
'
../../static/datamodel
'
;
import
{
EXPERIMENT
,
TRIALS
}
from
'
../../static/datamodel
'
;
import
{
Stack
,
PrimaryButton
,
Dropdown
,
IDropdownOption
}
from
'
office-ui-fabric-react
'
;
import
{
Stack
,
PrimaryButton
,
Dropdown
,
IDropdownOption
}
from
'
office-ui-fabric-react
'
;
import
{
ParaObj
,
Dimobj
,
TableObj
}
from
'
../../static/interface
'
;
import
{
ParaObj
,
Dimobj
,
TableObj
}
from
'
../../static/interface
'
;
import
'
echarts/lib/chart/parallel
'
;
import
'
echarts/lib/chart/parallel
'
;
...
@@ -30,6 +30,8 @@ interface ParaState {
...
@@ -30,6 +30,8 @@ interface ParaState {
swapyAxis
?:
string
[];
// yAxis Selector
swapyAxis
?:
string
[];
// yAxis Selector
paraYdataNested
:
number
[][];
paraYdataNested
:
number
[][];
isNested
:
false
;
isNested
:
false
;
showFinalMetricKey
:
string
;
metricType
:
string
;
}
}
interface
ParaProps
{
interface
ParaProps
{
...
@@ -72,7 +74,9 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -72,7 +74,9 @@ class Para extends React.Component<ParaProps, ParaState> {
isLoadConfirm
:
false
,
isLoadConfirm
:
false
,
swapyAxis
:
[],
swapyAxis
:
[],
paraYdataNested
:
[],
paraYdataNested
:
[],
isNested
:
false
isNested
:
false
,
showFinalMetricKey
:
"
default
"
,
metricType
:
'
numberType
'
};
};
}
}
...
@@ -101,7 +105,7 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -101,7 +105,7 @@ class Para extends React.Component<ParaProps, ParaState> {
}
else
{
}
else
{
paraYdata
=
this
.
state
.
paraYdataNested
;
paraYdata
=
this
.
state
.
paraYdataNested
;
}
}
// add
acc
// add
metric value
Object
.
keys
(
paraYdata
).
map
(
item
=>
{
Object
.
keys
(
paraYdata
).
map
(
item
=>
{
paraYdata
[
item
].
push
(
accPara
[
item
]);
paraYdata
[
item
].
push
(
accPara
[
item
]);
});
});
...
@@ -305,9 +309,11 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -305,9 +309,11 @@ class Para extends React.Component<ParaProps, ParaState> {
}
}
this
.
setState
({
dimName
:
dimName
});
this
.
setState
({
dimName
:
dimName
});
}
}
// metric yAxis
const
{
showFinalMetricKey
}
=
this
.
state
;
parallelAxis
.
push
({
parallelAxis
.
push
({
dim
:
i
,
dim
:
i
,
name
:
'
default m
etric
'
,
name
:
showFinalM
etric
Key
,
scale
:
true
,
scale
:
true
,
nameTextStyle
:
{
nameTextStyle
:
{
fontWeight
:
700
fontWeight
:
700
...
@@ -364,9 +370,20 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -364,9 +370,20 @@ class Para extends React.Component<ParaProps, ParaState> {
eachTrialParams
.
push
(
trial
.
description
.
parameters
);
eachTrialParams
.
push
(
trial
.
description
.
parameters
);
// may be a succeed trial hasn't final result
// may be a succeed trial hasn't final result
// all detail page may be break down if havn't if
// all detail page may be break down if havn't if
// metric yAxis data
if
(
trial
.
acc
!==
undefined
)
{
if
(
trial
.
acc
!==
undefined
)
{
if
(
trial
.
acc
.
default
!==
undefined
)
{
const
val
=
trial
.
acc
[
showFinalMetricKey
];
accPara
.
push
(
JSON
.
parse
(
trial
.
acc
.
default
));
if
(
val
!==
undefined
)
{
const
typeOfVal
=
typeof
val
;
if
(
typeOfVal
===
'
number
'
){
this
.
setState
(()
=>
({
metricType
:
'
numberType
'
}));
}
else
{
// string type
parallelAxis
[
parallelAxis
.
length
-
1
].
type
=
'
category
'
;
parallelAxis
[
parallelAxis
.
length
-
1
].
data
=
[
val
];
this
.
setState
(()
=>
({
metricType
:
'
stringType
'
}));
}
accPara
.
push
(
val
);
}
}
}
}
});
});
...
@@ -400,7 +417,7 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -400,7 +417,7 @@ class Para extends React.Component<ParaProps, ParaState> {
}
}
this
.
setState
({
paraYdataNested
:
renderDataSource
});
this
.
setState
({
paraYdataNested
:
renderDataSource
});
}
}
// if not return final result
const
maxVal
=
accPara
.
length
===
0
?
1
:
Math
.
max
(...
accPara
);
const
maxVal
=
accPara
.
length
===
0
?
1
:
Math
.
max
(...
accPara
);
const
minVal
=
accPara
.
length
===
0
?
1
:
Math
.
min
(...
accPara
);
const
minVal
=
accPara
.
length
===
0
?
1
:
Math
.
min
(...
accPara
);
this
.
setState
({
max
:
maxVal
,
min
:
minVal
},
()
=>
{
this
.
setState
({
max
:
maxVal
,
min
:
minVal
},
()
=>
{
...
@@ -424,7 +441,7 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -424,7 +441,7 @@ class Para extends React.Component<ParaProps, ParaState> {
// deal with response data into pic data
// deal with response data into pic data
getOption
=
(
dataObj
:
ParaObj
,
lengthofTrials
:
number
):
void
=>
{
getOption
=
(
dataObj
:
ParaObj
,
lengthofTrials
:
number
):
void
=>
{
// dataObj [[y1], [y2]... [default metric]]
// dataObj [[y1], [y2]... [default metric]]
const
{
max
,
min
}
=
this
.
state
;
const
{
max
,
min
,
metricType
}
=
this
.
state
;
const
parallelAxis
=
dataObj
.
parallelAxis
;
const
parallelAxis
=
dataObj
.
parallelAxis
;
const
paralleData
=
dataObj
.
data
;
const
paralleData
=
dataObj
.
data
;
let
visualMapObj
=
{};
let
visualMapObj
=
{};
...
@@ -472,7 +489,7 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -472,7 +489,7 @@ class Para extends React.Component<ParaProps, ParaState> {
},
},
}
}
},
},
visualMap
:
visualMapObj
,
visualMap
:
metricType
===
'
numberType
'
?
visualMapObj
:
null
,
series
:
{
series
:
{
type
:
'
parallel
'
,
type
:
'
parallel
'
,
smooth
:
true
,
smooth
:
true
,
...
@@ -629,6 +646,13 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -629,6 +646,13 @@ class Para extends React.Component<ParaProps, ParaState> {
});
});
}
}
// select all final keys
updateEntries
=
(
event
:
React
.
FormEvent
<
HTMLDivElement
>
,
item
:
any
):
void
=>
{
if
(
item
!==
undefined
)
{
this
.
setState
({
showFinalMetricKey
:
item
.
key
},
()
=>
{
this
.
reInit
()
});
}
}
componentDidMount
():
void
{
componentDidMount
():
void
{
this
.
reInit
();
this
.
reInit
();
}
}
...
@@ -644,6 +668,7 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -644,6 +668,7 @@ class Para extends React.Component<ParaProps, ParaState> {
render
():
React
.
ReactNode
{
render
():
React
.
ReactNode
{
const
{
option
,
paraNodata
,
dimName
,
isLoadConfirm
,
selectedItem
,
swapyAxis
}
=
this
.
state
;
const
{
option
,
paraNodata
,
dimName
,
isLoadConfirm
,
selectedItem
,
swapyAxis
}
=
this
.
state
;
return
(
return
(
<
div
className
=
"parameter"
>
<
div
className
=
"parameter"
>
<
Stack
horizontal
className
=
"para-filter"
horizontalAlign
=
"end"
>
<
Stack
horizontal
className
=
"para-filter"
horizontalAlign
=
"end"
>
...
@@ -659,9 +684,10 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -659,9 +684,10 @@ class Para extends React.Component<ParaProps, ParaState> {
{
key
:
'
0.8
'
,
text
:
'
80%
'
},
{
key
:
'
0.8
'
,
text
:
'
80%
'
},
{
key
:
'
1
'
,
text
:
'
100%
'
},
{
key
:
'
1
'
,
text
:
'
100%
'
},
]
}
]
}
styles
=
{
{
dropdown
:
{
width
:
30
0
}
}
}
styles
=
{
{
dropdown
:
{
width
:
12
0
}
}
}
className
=
"para-filter-percent"
className
=
"para-filter-percent"
/>
/>
{
this
.
finalKeysDropdown
()
}
<
Dropdown
<
Dropdown
placeholder
=
"Select options"
placeholder
=
"Select options"
selectedKeys
=
{
swapyAxis
}
selectedKeys
=
{
swapyAxis
}
...
@@ -674,7 +700,7 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -674,7 +700,7 @@ class Para extends React.Component<ParaProps, ParaState> {
};
};
})
})
}
}
styles
=
{
{
dropdown
:
{
width
:
30
0
}
}
}
styles
=
{
{
dropdown
:
{
width
:
24
0
}
}
}
/>
/>
<
PrimaryButton
<
PrimaryButton
text
=
"Confirm"
text
=
"Confirm"
...
@@ -694,6 +720,34 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -694,6 +720,34 @@ class Para extends React.Component<ParaProps, ParaState> {
</
div
>
</
div
>
);
);
}
}
private
finalKeysDropdown
=
():
any
=>
{
const
{
showFinalMetricKey
}
=
this
.
state
;
if
(
TRIALS
.
finalKeys
().
length
===
1
)
{
return
null
;
}
else
{
const
finalKeysDropdown
:
any
=
[];
TRIALS
.
finalKeys
().
forEach
(
item
=>
{
finalKeysDropdown
.
push
({
key
:
item
,
text
:
item
});
});
return
(
<
div
>
<
span
className
=
"para-filter-text para-filter-middle"
>
Metrics
</
span
>
<
Dropdown
selectedKey
=
{
showFinalMetricKey
}
options
=
{
finalKeysDropdown
}
onChange
=
{
this
.
updateEntries
}
styles
=
{
{
root
:
{
width
:
150
,
display
:
'
inline-block
'
}
}
}
className
=
"para-filter-percent"
/>
</
div
>
);
}
};
}
}
export
default
Para
;
export
default
Para
;
src/webui/src/components/trial-detail/TableList.tsx
View file @
b82bad0f
...
@@ -422,28 +422,9 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -422,28 +422,9 @@ class TableList extends React.Component<TableListProps, TableListState> {
parameterStr
.
push
(
`
${
value
}
(search space)`
);
parameterStr
.
push
(
`
${
value
}
(search space)`
);
});
});
}
}
let
allColumnList
=
COLUMNPro
.
concat
(
parameterStr
);
// concat trial all final keys and remove dup "default" val, return list
return
(
COLUMNPro
.
concat
(
parameterStr
)).
concat
(
Array
.
from
(
new
Set
(
TRIALS
.
finalKeys
())));
// only succeed trials have final keys
if
(
tableSource
.
filter
(
record
=>
record
.
status
===
'
SUCCEEDED
'
).
length
>=
1
)
{
const
temp
=
tableSource
.
filter
(
record
=>
record
.
status
===
'
SUCCEEDED
'
)[
0
].
accDictionary
;
if
(
temp
!==
undefined
&&
typeof
temp
===
'
object
'
)
{
// concat default column and finalkeys
const
item
=
Object
.
keys
(
temp
);
// item: ['default', 'other-keys', 'maybe loss']
if
(
item
.
length
>
1
)
{
const
want
:
string
[]
=
[];
item
.
forEach
(
value
=>
{
if
(
value
!==
'
default
'
)
{
want
.
push
(
value
);
}
});
allColumnList
=
allColumnList
.
concat
(
want
);
}
}
}
return
allColumnList
;
}
}
// get IColumn[]
// get IColumn[]
...
...
src/webui/src/static/model/trial.ts
View file @
b82bad0f
...
@@ -160,6 +160,11 @@ class Trial implements TableObj {
...
@@ -160,6 +160,11 @@ class Trial implements TableObj {
return
undefined
;
return
undefined
;
}
}
public
finalKeys
():
string
[]
{
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return
Object
.
keys
(
this
.
acc
!
);
}
/* table obj end */
/* table obj end */
public
initialized
():
boolean
{
public
initialized
():
boolean
{
...
...
src/webui/src/static/model/trialmanager.ts
View file @
b82bad0f
...
@@ -91,6 +91,15 @@ class TrialManager {
...
@@ -91,6 +91,15 @@ class TrialManager {
return
this
.
filter
(
trial
=>
trial
.
status
===
'
SUCCEEDED
'
);
return
this
.
filter
(
trial
=>
trial
.
status
===
'
SUCCEEDED
'
);
}
}
public
finalKeys
():
string
[]
{
const
succeedTrialsList
=
this
.
filter
(
trial
=>
trial
.
status
===
'
SUCCEEDED
'
);
if
(
succeedTrialsList
!==
undefined
&&
succeedTrialsList
[
0
]
!==
undefined
)
{
return
succeedTrialsList
[
0
].
finalKeys
();
}
else
{
return
[
"
default
"
];
}
}
public
sort
():
Trial
[]
{
public
sort
():
Trial
[]
{
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return
this
.
filter
(
trial
=>
trial
.
sortable
).
sort
((
trial1
,
trial2
)
=>
trial1
.
compareAccuracy
(
trial2
)
!
);
return
this
.
filter
(
trial
=>
trial
.
sortable
).
sort
((
trial1
,
trial2
)
=>
trial1
.
compareAccuracy
(
trial2
)
!
);
...
@@ -230,7 +239,7 @@ class TrialManager {
...
@@ -230,7 +239,7 @@ class TrialManager {
updated
=
true
;
updated
=
true
;
});
});
return
updated
;
return
updated
;
}
}
private
async
updateMetrics
(
lastTime
?:
boolean
):
Promise
<
boolean
>
{
private
async
updateMetrics
(
lastTime
?:
boolean
):
Promise
<
boolean
>
{
...
...
src/webui/src/static/style/para.scss
View file @
b82bad0f
...
@@ -14,6 +14,10 @@
...
@@ -14,6 +14,10 @@
&
-percent
{
&
-percent
{
margin-right
:
10px
;
margin-right
:
10px
;
}
}
&
-middle
{
vertical-align
:
top
;
}
}
}
.meline
{
.meline
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment