Skip to content

Commit

Permalink
Handle non-binomial predictions for getPredictions
Browse files Browse the repository at this point in the history
  • Loading branch information
lo5 committed Jan 14, 2015
1 parent 6bd9a5c commit 63168e0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
29 changes: 18 additions & 11 deletions src/ext/components/predicts-output.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ H2O.PredictsOutput = (_, opts, _predictions) ->
_canComparePredictions = signal no
_rocCurve = signal null

arePredictionsComparable = (views) ->
return no if views.length is 0
every views, (view) -> view.modelCategory is 'Binomial'

_isCheckingAll = no
react _checkAllPredictions, (checkAll) ->
_isCheckingAll = yes
for view in _predictionViews()
view.isChecked checkAll
_canComparePredictions checkAll
_canComparePredictions checkAll and arePredictionsComparable _predictionViews()
_isCheckingAll = no
return

Expand All @@ -22,7 +26,7 @@ H2O.PredictsOutput = (_, opts, _predictions) ->
react _isChecked, ->
return if _isCheckingAll
checkedViews = (view for view in _predictionViews() when view.isChecked())
_canComparePredictions checkedViews.length > 1
_canComparePredictions arePredictionsComparable checkedViews

view = ->
_.insertAndExecuteCell 'cs', "getPrediction #{stringify _modelKey}, #{stringify _frameKey}"
Expand All @@ -32,6 +36,7 @@ H2O.PredictsOutput = (_, opts, _predictions) ->

modelKey: _modelKey
frameKey: _frameKey
modelCategory: prediction.model_category
isChecked: _isChecked
view: view
inspect: inspect
Expand Down Expand Up @@ -61,15 +66,17 @@ H2O.PredictsOutput = (_, opts, _predictions) ->

initialize = (predictions) ->
_predictionViews map predictions, createPredictionView
rocCurveConfig =
data: _.inspect 'scores', _predictions
type: 'line'
x: 'FPR'
y: 'TPR'
color: 'key'
_.plot rocCurveConfig, (error, el) ->
unless error
_rocCurve el

# TODO handle non-binomial models
# rocCurveConfig =
# data: _.inspect 'scores', _predictions
# type: 'line'
# x: 'FPR'
# y: 'TPR'
# color: 'key'
# _.plot rocCurveConfig, (error, el) ->
# unless error
# _rocCurve el

initialize _predictions

Expand Down
11 changes: 6 additions & 5 deletions src/ext/components/predicts-output.jade
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@
td(data-bind='text:frameKey')
td.flow-right
+button('View', 'bolt', 'view')
+button('Inspect', 'list', 'inspect')
//- +button('Inspect', 'list', 'inspect')
// /ko
.flow-panel
+button('Compare selected predictions…', 'area-chart', 'comparePredictions', 'canComparePredictions')
+button('Plot predictions', 'bar-chart', 'plotPredictions')
+button('Plot scores', 'bar-chart', 'plotScores')
+button('Plot metrics', 'bar-chart', 'plotMetrics')
//- TODO handle non-binomial models
//- +button('Plot scores', 'bar-chart', 'plotScores')
//- +button('Plot metrics', 'bar-chart', 'plotMetrics')
+button('Inspect', 'list', 'inspect')

h4 ROC Curve
.flow-plot(data-bind='raw:rocCurve')
//- h4 ROC Curve
//- .flow-plot(data-bind='raw:rocCurve')
// /ko
16 changes: 8 additions & 8 deletions src/ext/modules/routines.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,9 @@ H2O.Routines = (_) ->
Flow.Data.Variable 'model_category', TString
Flow.Data.Variable 'duration_in_ms', TNumber
Flow.Data.Variable 'scoring_time', TNumber
Flow.Data.Variable 'AUC', TNumber
Flow.Data.Variable 'Gini', TNumber
Flow.Data.Variable 'threshold_criterion', TString
#Flow.Data.Variable 'AUC', TNumber
#Flow.Data.Variable 'Gini', TNumber
#Flow.Data.Variable 'threshold_criterion', TString
]

Record = Flow.Data.Record variables
Expand All @@ -537,9 +537,9 @@ H2O.Routines = (_) ->
prediction.model_category
prediction.duration_in_ms
prediction.scoring_time
auc.AUC
auc.Gini
auc.threshold_criterion
#auc.AUC
#auc.Gini
#auc.threshold_criterion
)

Flow.Data.Table
Expand All @@ -558,8 +558,8 @@ H2O.Routines = (_) ->
render_ predictions, -> H2O.PredictsOutput _, opts, predictions
inspect_ predictions,
predictions: inspectBinomialPredictions opts, predictions
metrics: inspectBinomialMetrics opts, predictions
scores: inspectBinomialScores opts, predictions
#metrics: inspectBinomialMetrics opts, predictions
#scores: inspectBinomialScores opts, predictions

inspectBinomialScores = (opts, predictions) -> ->

Expand Down

0 comments on commit 63168e0

Please sign in to comment.