diff --git a/src/core/components/notebook.coffee b/src/core/components/notebook.coffee index ec551161a..53f186f40 100644 --- a/src/core/components/notebook.coffee +++ b/src/core/components/notebook.coffee @@ -628,7 +628,7 @@ Flow.Notebook = (_, _renderers) -> , createMenu 'Score', [ createMenuItem 'Predict...', executeCommand 'predict' - createMenuItem 'Partial Dependence Plots...', executeCommand 'partialDependence' + createMenuItem 'Partial Dependence Plots...', executeCommand 'getPartialDependence' menuDivider createMenuItem 'List All Predictions', executeCommand 'getPredictions' #TODO Confusion Matrix diff --git a/src/ext/components/partial-dependence-input.coffee b/src/ext/components/partial-dependence-input.coffee index 9fe981581..952875e78 100644 --- a/src/ext/components/partial-dependence-input.coffee +++ b/src/ext/components/partial-dependence-input.coffee @@ -6,44 +6,50 @@ H2O.PartialDependenceInput = (_, _go) -> _models = signals [] _selectedModel = signals null _selectedFrame = signal null - _nbins = signal null - - _leftColumns = signals [] - _selectedLeftColumn = signal null - _includeAllLeftRows = signal false - - _selectedRightFrame = signal null - _rightColumns = signals [] - _selectedRightColumn = signal null - _includeAllRightRows = signal false - - _canCompute = lift _selectedFrame, _selectedLeftColumn, _selectedRightFrame, _selectedRightColumn, (lf, lc, rf, rc) -> - lf and lc and rf and rc - - react _selectedFrame, (frameKey) -> - if frameKey - _.requestFrameSummaryWithoutData frameKey, (error, frame) -> - _leftColumns map frame.columns, (column, i) -> - label: column.label - index: i - else - _selectedLeftColumn null - _leftColumns [] - - react _selectedRightFrame, (frameKey) -> - if frameKey - _.requestFrameSummaryWithoutData frameKey, (error, frame) -> - _rightColumns map frame.columns, (column, i) -> - label: column.label - index: i - else - _selectedRightColumn null - _rightColumns [] - - _computer = -> - return unless _canMerge() - - cs = "mergeFrames #{stringify _destinationKey()}, #{stringify _selectedFrame()}, #{_selectedLeftColumn().index}, #{_includeAllLeftRows()}, #{stringify _selectedRightFrame()}, #{_selectedRightColumn().index}, #{_includeAllRightRows()}" + _nbins = signal 20 + + # _leftColumns = signals [] + # _selectedLeftColumn = signal null + # _includeAllLeftRows = signal false + + # _selectedRightFrame = signal null + # _rightColumns = signals [] + # _selectedRightColumn = signal null + # _includeAllRightRows = signal false + + _canCompute = lift _destinationKey, _selectedFrame, _selectedModel, _nbins, (dk, sf, sm, nb) -> + dk and sf and sm and nb + + # react _selectedFrame, (frameKey) -> + # if frameKey + # _.requestFrameSummaryWithoutData frameKey, (error, frame) -> + # _leftColumns map frame.columns, (column, i) -> + # label: column.label + # index: i + # else + # _selectedLeftColumn null + # _leftColumns [] + + # react _selectedRightFrame, (frameKey) -> + # if frameKey + # _.requestFrameSummaryWithoutData frameKey, (error, frame) -> + # _rightColumns map frame.columns, (column, i) -> + # label: column.label + # index: i + # else + # _selectedRightColumn null + # _rightColumns [] + + _compute = -> + return unless _canCompute() + + opts = + destination_key: _destinationKey() + model_id: _selectedModel() + frame_id: _selectedFrame() + nbins: _nbins() + + cs = "getPartialDependence #{stringify opts}" _.insertAndExecuteCell 'cs', cs @@ -68,16 +74,15 @@ H2O.PartialDependenceInput = (_, _go) -> selectedModel: _selectedModel selectedFrame: _selectedFrame nbins: _nbins - - leftColumns: _leftColumns - selectedLeftColumn: _selectedLeftColumn - includeAllLeftRows: _includeAllLeftRows - selectedRightFrame: _selectedRightFrame - rightColumns: _rightColumns - selectedRightColumn: _selectedRightColumn - includeAllRightRows: _includeAllRightRows - merge: _merge - canMerge: _canMerge + # leftColumns: _leftColumns + # selectedLeftColumn: _selectedLeftColumn + # includeAllLeftRows: _includeAllLeftRows + # selectedRightFrame: _selectedRightFrame + # rightColumns: _rightColumns + # selectedRightColumn: _selectedRightColumn + # includeAllRightRows: _includeAllRightRows + compute: _compute + canCompute: _canCompute template: 'flow-partial-dependence-input' diff --git a/src/ext/components/partial-dependence-input.jade b/src/ext/components/partial-dependence-input.jade index 2677ad3c0..6a284db05 100644 --- a/src/ext/components/partial-dependence-input.jade +++ b/src/ext/components/partial-dependence-input.jade @@ -5,7 +5,7 @@ tbody tr th(width='150') - label Save PDP frame as: + label Save Destination PDP as: td input(data-bind="value:destinationKey" style='width:250px') tr diff --git a/src/ext/components/partial-dependence-output.coffee b/src/ext/components/partial-dependence-output.coffee index af07369e2..3cf45005a 100644 --- a/src/ext/components/partial-dependence-output.coffee +++ b/src/ext/components/partial-dependence-output.coffee @@ -1,13 +1,13 @@ -H2O.PartialDependenceOutput = (_, _go, _mergeFramesResult) -> +H2O.PartialDependenceOutput = (_, _go, _partialDependenceResult) -> - _frameKey = _mergeFramesResult.key + _destinationKey = _partialDependenceResult.dest.name _viewFrame = -> - _.insertAndExecuteCell 'cs', "getFrameSummary #{stringify _frameKey}" + _.insertAndExecuteCell 'cs', "requestPartialDependenceData #{stringify _destinationKey}" defer _go - frameKey: _frameKey + _destinationKey: _destinationKey viewFrame: _viewFrame template: 'flow-partial-dependence-output' diff --git a/src/ext/modules/application-context.coffee b/src/ext/modules/application-context.coffee index dfac47fae..c395554e3 100644 --- a/src/ext/modules/application-context.coffee +++ b/src/ext/modules/application-context.coffee @@ -26,6 +26,7 @@ H2O.ApplicationContext = (_) -> _.requestPredict = do slot _.requestPrediction = do slot _.requestPredictions = do slot + _.requestPartialDependence = do slot _.requestGrids = do slot _.requestModels = do slot _.requestGrid = do slot diff --git a/src/ext/modules/proxy.coffee b/src/ext/modules/proxy.coffee index b264e6df5..93b687c0b 100644 --- a/src/ext/modules/proxy.coffee +++ b/src/ext/modules/proxy.coffee @@ -260,6 +260,15 @@ H2O.Proxy = (_) -> chunk_size: chunkSize doPost '/3/Parse', opts, go + requestPartialDependence = (opts, go) -> + doPost '/3/PartialDependence/', opts, go + + # requestPartialDependenceData = (key, go) -> + # doGet "/3/PartialDependence/#{encodeURIComponent key}", (error, result) -> + # if error + # go error, result + # else go error, result.data + requestGrids = (go, opts) -> doGet "/99/Grids", (error, result) -> if error @@ -575,6 +584,8 @@ H2O.Proxy = (_) -> link _.requestParseSetup, requestParseSetup link _.requestParseSetupPreview, requestParseSetupPreview link _.requestParseFiles, requestParseFiles + link _.requestPartialDependence, requestPartialDependence + # link _.requestPartialDependenceData, requestPartialDependenceData link _.requestGrids, requestGrids link _.requestModels, requestModels link _.requestGrid, requestGrid diff --git a/src/ext/modules/routines.coffee b/src/ext/modules/routines.coffee index 0fb972cfc..09db47d9d 100644 --- a/src/ext/modules/routines.coffee +++ b/src/ext/modules/routines.coffee @@ -429,7 +429,7 @@ H2O.Routines = (_) -> result extendPartialDependence = (result) -> - render_ result, H2O.partialDependenceOutput, result + render_ result, H2O.PartialDependenceOutput, result result # inspectOutputsAcrossModels = (modelCategory, models) -> -> @@ -1027,6 +1027,17 @@ H2O.Routines = (_) -> else go null, extendJob job + requestPartialDependence = (opts, go) -> + _.requestPartialDependence opts, (error, result) -> + if error + go error + else + _.requestJob result.key.name, (error, job) -> + if error + go error + else + go null, extendJob job + computeSplits = (ratios, keys) -> parts = [] sum = 0 @@ -1108,16 +1119,6 @@ H2O.Routines = (_) -> go null, extendMergeFramesResult key: destinationKey - requestPartialDependence = (destinationKey, modelKey, frameKey, nbins, go) -> - - statement = "(assign #{destinationKey} (merge #{leftFrameKey} #{rightFrameKey} #{lr} #{rr} #{leftColumnIndex} #{rightColumnIndex} \"radix\"))" - _.requestExec statement, (error, result) -> - if error - go error - else - go null, extendPartialDependence - key: destinationKey - createFrame = (opts) -> if opts _fork requestCreateFrame, opts @@ -1136,11 +1137,11 @@ H2O.Routines = (_) -> else assist mergeFrames - partialDependence = (destinationKey, leftFrameKey, leftColumnIndex, includeAllLeftRows, rightFrameKey, rightColumnIndex, includeAllRightRows) -> - if destinationKey and leftFrameKey and rightFrameKey - _fork requestPartialDependence, destinationKey, leftFrameKey, leftColumnIndex, includeAllLeftRows, rightFrameKey, rightColumnIndex, includeAllRightRows + getPartialDependence = (opts) -> + if opts + _fork requestPartialDependence, opts else - assist partialDependence + assist getPartialDependence getFrames = -> _fork requestFrames @@ -1836,7 +1837,7 @@ H2O.Routines = (_) -> _fork proceed, H2O.SplitFrameInput, args when mergeFrames _fork proceed, H2O.MergeFramesInput, args - when partialDependence + when getPartialDependence _fork proceed, H2O.PartialDependenceInput, args when exportFrame _fork proceed, H2O.ExportFrameInput, args @@ -1921,7 +1922,7 @@ H2O.Routines = (_) -> createFrame: createFrame splitFrame: splitFrame mergeFrames: mergeFrames - partialDependence: partialDependence + getPartialDependence: getPartialDependence getFrames: getFrames getFrame: getFrame bindFrames: bindFrames