Skip to content

Commit

Permalink
Merge pull request #197 from lynxkite/darabos-roc
Browse files Browse the repository at this point in the history
Built-in box for ROC curve
  • Loading branch information
darabos committed Aug 23, 2021
2 parents f0d833c + 05ee4e9 commit 69018ae
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __pycache__
.cache/
.history/
.lib/
/.bsp
/dist/*
target/
/logs/
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Please add changes to "master", preferably ordered by their significance. (Most
- Boxes used as steps in a wizard are highlighted in the workspace view by a faint glow.
[#183](https://github.com/lynxkite/lynxkite/pull/183)
- _"Compute in Python"_ boxes can be used on tables. [#160](https://github.com/lynxkite/lynxkite/pull/160)
- Added a _"Draw ROC curve"_ built-in custom box. [#197](https://github.com/lynxkite/lynxkite/pull/197)
- Performance and compatibility improvements.
[#188](https://github.com/lynxkite/lynxkite/pull/188)
[#194](https://github.com/lynxkite/lynxkite/pull/194)
Expand Down
3 changes: 1 addition & 2 deletions app/com/lynxanalytics/biggraph/serving/JsonServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,7 @@ class ProductionJsonServer @javax.inject.Inject() (

def downloadCSV = asyncAction(parse.anyContent) { (user: User, r: mvc.Request[mvc.AnyContent]) =>
val request = parseJson[GetTableOutputRequest](user, r)
implicit val metaManager = workspaceController.metaManager
val table = workspaceController.getOutput(user, request.id).table
val table = workspaceController.metaManager.table(java.util.UUID.fromString(request.id))
sqlController.downloadCSV(table, request.sampleRows)
}

Expand Down
155 changes: 155 additions & 0 deletions built-ins/draw-ROC-curve
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
boxes:
- id: anchor
inputs: {}
operationId: Anchor
parameters:
description: |-
Draws an ROC curve and computes the AUC
for a binary classifier prediction.
The two parameters are the true label (0 or 1)
and the predicted score from the model (between 0 and 1).

To avoid an overly detailed plot,
the curve is based on a sample of vertices.
parameters: >-
[{"kind":"vertex attribute (number)","id":"true
label","defaultValue":""},{"kind":"vertex
attribute (number)","id":"predicted
score","defaultValue":""},{"kind":"text","id":"sample
size","defaultValue":"1000"}]
parametricParameters: {}
x: 0
y: 0
- id: Custom-plot_2
inputs:
table:
boxId: SQL1_5
id: table
operationId: Custom plot
parameters:
plot_code: |-
{
"layer": [{
"mark": "line",
"encoding": {
"x": {
"field": "fpr",
"title": "False positive rate",
"type": "quantitative"
},
"y": {
"field": "tpr",
"title": "True positive rate",
"type": "quantitative"
}
}
}, {
"mark": {
"type": "rule",
"color": "lightgray",
"strokeDash": [8, 8]
},
"encoding": {
"x": { "datum": 0 },
"y": { "datum": 0 },
"x2": { "datum": 1 },
"y2": { "datum": 1 }
}
}]
}
parametricParameters: {}
x: 700
y: 150
- id: SQL1_4
inputs:
input:
boxId: input-input
id: input
operationId: SQL1
parameters:
persist: 'yes'
summary: Rename and filter
parametricParameters:
sql: |-
select
${`true label`} as label,
${`predicted score`} as score
from vertices
where isnotnull(${`true label`})
and isnotnull(${`predicted score`})
limit ${`sample size`}
x: 250
y: 250
- id: input-input
inputs: {}
operationId: Input
parameters:
name: input
parametricParameters: {}
x: 50
y: 250
- id: SQL1_5
inputs:
input:
boxId: SQL1_4
id: table
operationId: SQL1
parameters:
persist: 'no'
sql: |-
select
label, score,
sum(label) over (
order by score desc rows between
unbounded preceding and current row)
/ (select sum(label) from input)
as tpr,

sum(1 - label) over (
order by score desc rows between
unbounded preceding and current row)
/ (select sum(1 - label) from input)
as fpr

from input
summary: Compute TPR / FPR
parametricParameters: {}
x: 450
y: 250
- id: SQL1_6
inputs:
input:
boxId: SQL1_5
id: table
operationId: SQL1
parameters:
persist: 'no'
sql: |
select sum(1 - fpr) / count(1) as AUC
from input where label == 1
summary: Compute AUC
parametricParameters: {}
x: 700
y: 300
- id: output-plot
inputs:
output:
boxId: Custom-plot_2
id: plot
operationId: Output
parameters:
name: plot
parametricParameters: {}
x: 900
y: 150
- id: output-table
inputs:
output:
boxId: SQL1_6
id: table
operationId: Output
parameters:
name: AUC
parametricParameters: {}
x: 900
y: 300
13 changes: 0 additions & 13 deletions dependency-licenses/scala.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ Apache | [Apache License v2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) |
Apache | [Apache License, Version 2](http://www.apache.org/licenses/LICENSE-2.0) | org.neo4j.driver # neo4j-java-driver # 4.2.5 | <notextile></notextile>
Apache | [Apache License, Version 2.0](https://aws.amazon.com/apache2.0) | com.amazonaws # aws-java-sdk # 1.7.4 | <notextile></notextile>
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.clearspring.analytics # stream # 2.9.6 | <notextile></notextile>
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.cloud.bigdataoss # gcs-connector # 1.6.1-hadoop2 | <notextile></notextile>
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.cloud.bigdataoss # gcsio # 1.6.1 | <notextile></notextile>
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.cloud.bigdataoss # util # 1.6.1 | <notextile></notextile>
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.cloud.bigdataoss # util-hadoop # 1.6.1-hadoop2 | <notextile></notextile>
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.guava # guava # 30.1-android | <notextile></notextile>
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | com.jamesmurty.utils # java-xmlbuilder # 1.1 | <notextile></notextile>
Apache | [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) | commons-codec # commons-codec # 1.15 | <notextile></notextile>
Expand Down Expand Up @@ -118,21 +114,12 @@ Apache | [The Apache Software License, Version 2.0](https://www.apache.org/licen
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.github.docker-java # docker-java-api # 3.2.7 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.github.docker-java # docker-java-transport # 3.2.7 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.github.docker-java # docker-java-transport-zerodep # 3.2.7 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.api-client # google-api-client # 1.20.0 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.api-client # google-api-client-jackson2 # 1.20.0 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.api-client # google-api-client-java6 # 1.20.0 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.apis # google-api-services-storage # v1-rev35-1.20.0 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.code.findbugs # jsr305 # 3.0.2 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.guava # failureaccess # 1.0.1 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.guava # guava-jdk5 # 13.0 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.guava # listenablefuture # 9999.0-empty-to-avoid-conflict-with-guava | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.http-client # google-http-client # 1.20.0 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.http-client # google-http-client-jackson2 # 1.20.0 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.inject # guice # 4.2.3 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.inject.extensions # guice-assistedinject # 4.2.3 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.j2objc # j2objc-annotations # 1.3 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.oauth-client # google-oauth-client # 1.20.0 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.oauth-client # google-oauth-client-java6 # 1.20.0 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | commons-logging # commons-logging # 1.2 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | commons-pool # commons-pool # 1.5.4 | <notextile></notextile>
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | javax.inject # javax.inject # 1 | <notextile></notextile>
Expand Down

0 comments on commit 69018ae

Please sign in to comment.