This repository has been archived by the owner on Jun 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy paththreshold_graph.jsx
76 lines (71 loc) · 1.6 KB
/
threshold_graph.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import React, { Component } from 'react';
import Chart from 'chart.js';
class ThresholdGraph extends Component {
componentDidMount() {
let chartCanvas = this.refs.chart,
data = {
datasets: [
{
label: 'Precision',
data: this.props.thresholds.map( level => {
return { x: level.threshold, y: level.precision };
} ),
borderColor: 'rgba( 0, 204, 255, 1 )',
pointRadius: 0
},
{
label: 'Recall',
data: this.props.thresholds.map( level => {
return { x: level.threshold, y: level.recall };
} ),
borderColor: 'rgba( 134, 153, 77, 1 )',
pointRadius: 0
},
{
label: 'Filter rate',
data: this.props.thresholds.map( level => {
return { x: level.threshold, y: level.filter_rate };
} ),
borderColor: 'rgba( 0, 0, 0, 1 )',
pointRadius: 0
}
]
};
/* eslint-disable no-new */
new Chart( chartCanvas, {
type: 'line',
data: data,
options: {
title: {
display: true,
text: 'Precision-recall for ' + this.props.wiki + ' ' + this.props.model + ' "' + this.props.target + '" prediction'
},
elements: {
line: {
tension: 0, // disables bezier curves
fill: false
}
},
scales: {
xAxes: [ {
scaleLabel: {
display: true,
labelString: 'Cutoff threshold'
},
type: 'linear',
position: 'bottom'
} ]
}
}
} );
}
render() {
if ( !this.props.thresholds ) {
return null;
}
return (
<canvas ref={ 'chart' } height="400" width="600"></canvas>
);
}
}
export default ThresholdGraph;