Skip to content

Commit

Permalink
refactor of training view #120
Browse files Browse the repository at this point in the history
  • Loading branch information
Zukkari committed Feb 3, 2018
1 parent 1f112bc commit 07a735f
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/cs/ut/logging/NirdLogger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.servlet.http.HttpServletRequest

class NirdLogger(private val id: String = "GLOBAL", caller: Class<Any>) {

val log = Logger.getLogger(caller)!!
val log = Logger.getLogger(caller::class.java)!!

fun debug(msg: Any?) {
log.debug("[${this.id}] $msg")
Expand Down
49 changes: 23 additions & 26 deletions src/main/kotlin/cs/ut/ui/controllers/TrainingController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,25 @@ class TrainingController : SelectorComposer<Component>(), Redirectable {
private lateinit var gridContainer: Vlayout

@Wire
private lateinit var thresholdContainer: Hbox
private lateinit var genDataSetParam: A

@Wire
private lateinit var genDataSetParam: A
private lateinit var radioGroup: Radiogroup

@Wire
private lateinit var trainingGrid: Grid
private lateinit var avgRadio: Radio

private lateinit var radioGroup: Radiogroup
@Wire
private lateinit var customRadio: Radio

@Wire
private lateinit var customBox: Doublebox

private lateinit var gridController: ModeController

override fun doAfterCompose(comp: Component?) {
super.doAfterCompose(comp)

radioGroup = Radiogroup()

initClientLogs()
if (initPredictions()) {
genDataSetParam.isDisabled = false
Expand All @@ -85,9 +87,9 @@ class TrainingController : SelectorComposer<Component>(), Redirectable {
private fun getLogFileName(): String = (clientLogs.selectedItem.getValue() as File).nameWithoutExtension

private fun initPredictions(): Boolean {
radioGroup.getChildren<Component>().clear()
thresholdContainer.getChildren<Component>().clear()
thresholdContainer.isVisible = false
customBox.isDisabled = true
avgRadio.isDisabled = true
customRadio.isDisabled = true

predictionType.items.clear()
log.debug("Cleared prediction type items")
Expand Down Expand Up @@ -126,11 +128,15 @@ class TrainingController : SelectorComposer<Component>(), Redirectable {
val param = (e.selectedItems.first() as Comboitem).getValue() as ModelParameter
log.debug("Prediction type model changed to $param")
if (param.id == OUTCOME) {
thresholdContainer.isVisible = true
customBox.isDisabled = false
avgRadio.isDisabled = false
customRadio.isDisabled = false
log.debug("Prediciton type is $OUTCOME generating radio buttons")
} else {
log.debug("Clearing thresholdContainer")
thresholdContainer.isVisible = false
customBox.isDisabled = true
avgRadio.isDisabled = true
customRadio.isDisabled = true
}
})

Expand All @@ -140,33 +146,24 @@ class TrainingController : SelectorComposer<Component>(), Redirectable {
}

private fun ModelParameter.setUpRadioButtons() {
val avg = radioGroup.appendItem(NirdizatiUtil.localizeText("threshold.avg"), this.parameter)
avg.setValue(this.parameter.toDouble())
radioGroup.selectedItem = avg

val custom = radioGroup.appendItem(NirdizatiUtil.localizeText("threshold.custom"), this.parameter)
custom.setValue(DEFAULT)
val customBox = Doublebox()
customBox.width = "60px"
avgRadio.setValue(this.parameter.toDouble())
customRadio.setValue(DEFAULT)
customBox.setValue(DEFAULT)
customBox.style = "padding-top: 10px"
customBox.vflex = "1"

customBox.addEventListener(Events.ON_CHANGE, { _ ->
log.debug("New value for custom threshold ${customBox.value}")
val res: Double? = customBox.value

if (res == null || res <= 0) {
custom.setValue(DEFAULT)
customRadio.setValue(DEFAULT)
customBox.setValue(DEFAULT)
customBox.errorMessage = NirdizatiUtil.localizeText("threshold.custom_error", 0)
} else {
customBox.clearErrorMessage()
custom.setValue(res)
customBox.setValue(res)
customRadio.setValue(res)
}
})

thresholdContainer.appendChild(radioGroup)
thresholdContainer.appendChild(customBox)
}

private fun initClientLogs() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/cs/ut/util/Const.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const val PAGE_TRAINING = "training"
const val PAGE_VALIDATION = "validation"

const val LAST_STATE = "last_state"
const val PREFIX = "prefix_lenght_based"
const val PREFIX = "prefix_length_based"
const val FREQUENCY = "frequency"
const val COMBINED = "combined"
const val INDEX = "index_based"
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
</properties>
</modelparam>
<modelparam>
<id>prefix_lenght_based</id>
<id>prefix_length_based</id>
<parameter>prefix</parameter>
<type>bucketing</type>
<enabled>true</enabled>
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/zk-label.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ header.validation=Validation
header.admin=Admin view
training.selected_log=Currently selected log:
training.prediction_type=What do you want to predict?
training.advanced=Multiple models
training.advanced=Multiple models:
training.start_training=Train model
training.file_not_found=File with such name could not be found
training.empty_prediction=Prediction type cannot be empty
Expand All @@ -35,7 +35,7 @@ encoding.index_based=Index based
bucketing.zero=Zero
bucketing.state_based=State based
bucketing.clustering=Clustering
bucketing.prefix_lenght_based=Prefix lenght based
bucketing.prefix_length_based=Prefix length based
learner.random_forest=Random forest
learner.gradient_boosting=Gradient boosting
learner.decision_tree=Decision tree
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/css/main.sass
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
.no-hor-overflow
overflow-x: hidden

.no-overflow
overflow: hidden

.padding-bottom-20px
padding-bottom: 20px

Expand Down
46 changes: 24 additions & 22 deletions src/main/webapp/views/training.zul
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
<vbox hflex="1" vflex="1" align="center" apply="cs.ut.ui.controllers.TrainingController"
xmlns="http://www.zkoss.org/2005/zul">
<hlayout hflex="1" vflex="1" sclass="padding-bottom-20px">
<grid id="trainingGrid" vflex="1" sclass="max-height max-width">
<columns>
<column hflex="min" align="center"/>
<column hflex="min" align="center"/>
</columns>
<rows vflex="1">
<row>
<label hflex="1" value="${labels.training.selected_log}" sclass="label-combo"/>
<vbox align="center" vflex="1" hflex="1" apply="cs.ut.ui.controllers.TrainingController">
<hlayout hflex="1" vflex="1">
<grid id="trainingGrid" vflex="min" hflex="min" sclass="max-height max-width">
<rows>
<row align="center">
<label value="${labels.training.selected_log}" sclass="label-combo"/>
<combobox id="clientLogs"/>
</row>
<row>
<label value="${labels.training.prediction_type}" hflex="1"/>
<row align="center">
<label value="${labels.training.prediction_type}"/>
<combobox id="predictionType"/>
</row>
<row vflex="1">
<hlayout>
<hlayout>
<label value="${labels.training.advanced}" hflex="1"/>
<checkbox id="advancedMode" zclass="toggle" sclass="switch toggle-round-flat" hflex="1"/>
</hlayout>
<hbox align="center" vflex="1" id="thresholdContainer" visible="false"/>
</hlayout>
<row align="center">
<label value="${labels.threshold.threshold_msg}"/>
<hbox align="center">
<radiogroup id="radioGroup">
<radio id="avgRadio" label="${labels.threshold.avg}" selected="true" radiogroup="radioGroup"/>
<radio id="customRadio" label="${labels.threshold.custom}" radiogroup="radioGroup"/>
</radiogroup>
<doublebox id="customBox" width="60px" disabled="true"/>
</hbox>
</row>
<row align="center">
<hbox hflex="1" vflex="1" align="center" pack="center">
<label value="${labels.training.advanced}"/>
<checkbox id="advancedMode" zclass="toggle" sclass="switch toggle-round-flat"/>
</hbox>
<a id="genDataSetParam" label="${labels.training.gen_dataset_para}"
onClick="generateNewDatasetParams"
hflex="1"/>
Expand All @@ -35,7 +37,7 @@

<hlayout id="hyperParamGridContainer" vflex="1" hflex="1"/>

<hbox hflex="min" vflex="1" align="center" pack="center">
<hbox hflex="1" vflex="1" align="center" pack="center">
<vlayout hflex="min" vflex="min">
<button id="startTraining" sclass="n-btn" label="${labels.training.start_training}"/>
</vlayout>
Expand Down

0 comments on commit 07a735f

Please sign in to comment.