Skip to content

Commit

Permalink
Patch up variable importance handling.
Browse files Browse the repository at this point in the history
Refer to .variables in variable_importances when available instead of the model's column names.
Don't rely on max_var: variable list is not truncated, so truncate after sorting.
PP-103
  • Loading branch information
lo5 committed Jun 18, 2014
1 parent 96e528c commit a6dedd3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions client/src/scripts/model-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,19 @@ computeCumulativeScaledValues = (varImp) ->
return

createVariableImportanceModel = (inputColumnNames, variableImportances) ->
data = times (Math.min variableImportances.max_var, variableImportances.varimp.length), (index) ->
columnName: inputColumnNames[index]
#TODO always refer to .variables when variables are available in variable_importances.
variables = variableImportances.variables or inputColumnNames

data = times variableImportances.varimp.length, (index) ->
columnName: variables[index] or '' #TODO remove or... when variables are available in variable_importances
value: variableImportances.varimp[index]
cumulativeScaledValue: 0
hasCumulativeScaledValues: no

sortedData = sortBy data, (datum) -> -datum.value

method: variableImportances.method
data: sortBy data, (datum) -> -datum.value
data: if sortedData.length < variableImportances.max_var then sortedData else sortedData.slice 0, variableImportances.max_var

Steam.ModelView = (_, _model) ->
stringify = (value) ->
Expand Down

0 comments on commit a6dedd3

Please sign in to comment.