Skip to content

Commit

Permalink
Merge pull request #316 from EpistasisLab/regression_ui
Browse files Browse the repository at this point in the history
Regression UI
  • Loading branch information
hjwilli authored Mar 5, 2021
2 parents 711d482 + 90712f6 commit 56a5c60
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 27 deletions.
7 changes: 5 additions & 2 deletions lab/api/userdatasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,21 @@ var annotate_dataset = function(dataset) {
var running = 0;
var finished = 0;
var failed = 0;
var best_score = 0;
var best_score; // R^2 scores can be negative
var best_experiment_id;
var best_experiment_name;
var prediction_type;
if (dataset['experiments']) {
experiments = dataset['experiments']
prediction_type = experiments[0]['_prediction_type']

for (var j = 0; j < experiments.length; j++) {
var experiment = experiments[j];
var _status = experiment['_status'];
var _scores = experiment['_scores'];
if (_scores !== undefined && _scores['exp_table_score'] >= best_score) {

if (_scores !== undefined &&
( best_score == undefined || _scores['exp_table_score'] >= best_score) ) {
best_score = _scores['exp_table_score']
best_experiment_id = experiment['_id']
if (experiment['algorithm'] && experiment['algorithm']['name']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import React from 'react';
import { Segment, Header, Progress } from 'semantic-ui-react';
import { formatAlgorithm } from '../../../../../../utils/formatter';



function BestResult({ result, hasMetadata }) {
const getNoResultMessage = () => {
if(!hasMetadata) {
Expand All @@ -41,6 +43,44 @@ function BestResult({ result, hasMetadata }) {
const getResultLink = () => `/#/results/${result._id}`;

const getPercent = () => (result.score * 100).toFixed(2);

const getValue = () => (result.score).toFixed(2);

/*
const getValue = () => {
if (result.score <=0 ) return '≤ 0';
return (result.score).toFixed(2);
}
*/

const renderProgressBar = (result) => {
switch(result.prediction_type) {
case 'classification':
return (
<Progress
inverted
progress
percent={getPercent()}
className="accuracy-score"
label="Balanced Accuracy"
/>
);
case 'regression':
return (
<Progress
inverted
progress='value'
value={getValue()}
total='1.0'
className="accuracy-score"
label="Coefficient of Determination"
/>
);
default:
return;
}
}


if(!result) {
return (
Expand All @@ -50,13 +90,6 @@ function BestResult({ result, hasMetadata }) {
);
}

// add label for best results
var label = "";
if (result.prediction_type == "classification") {
label = "Balanced Accuracy";
} else if (result.prediction_type == "regression") {
label = "R2";
}

return (
<Segment
Expand All @@ -72,15 +105,9 @@ function BestResult({ result, hasMetadata }) {
<span>{`#${result._id}`}</span>
</Header.Subheader>
</Header>
<Progress
inverted
progress
percent={getPercent()}
className="accuracy-score"
label={label}
/>
{ renderProgressBar(result) }
</Segment>
);
}

export default BestResult;
export default BestResult;
Original file line number Diff line number Diff line change
Expand Up @@ -81,32 +81,32 @@ function MSEMAEDetails({scores}) {
<Header
inverted
as='h4'
content="Train/Test"
content='Train/&thinsp;Test'
/>
</Grid.Column>
<Grid.Column>
<Header
inverted
as='h5'
as='h5' sub
content="MSE"
/>
</Grid.Column>
<Grid.Column textAlign="center">
<Header
inverted
as='h5'
as='h5' sub
content={scores['train_neg_mean_squared_error_score'].toFixed(2)}
/>
</Grid.Column>
<Grid.Column textAlign="center">
<Header
inverted
as='h5'
as='h5' sub
content={scores['neg_mean_squared_error_score'].toFixed(2)}
/>
</Grid.Column>
<Grid.Column>
<Header inverted as='h5'>
<Header inverted as='h5' sub>
{msefold.toFixed(2)}
<Popup content={mseicons[2]}
trigger={
Expand All @@ -123,26 +123,26 @@ function MSEMAEDetails({scores}) {
<Grid.Column>
<Header
inverted
as='h5'
as='h5' sub
content="MAE"
/>
</Grid.Column>
<Grid.Column textAlign="center">
<Header
inverted
as='h5'
as='h5' sub
content={scores['train_neg_mean_absolute_error_score'].toFixed(2)}
/>
</Grid.Column>
<Grid.Column textAlign="center">
<Header
inverted
as='h5'
as='h5' sub
content={scores['neg_mean_absolute_error_score'].toFixed(2)}
/>
</Grid.Column>
<Grid.Column>
<Header inverted as='h5'>
<Header inverted as='h5' sub>
{maefold.toFixed(2)}
<Popup content={maeicons[2]}
trigger={
Expand Down
2 changes: 1 addition & 1 deletion lab/webapp/src/components/Results/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class Results extends Component {
scores={experiment.data.scores}
/>
<Score
scoreName="R2"
scoreName="Coefficient of Determination"
scoreValueList={R2List}
chartKey="R2"
chartColor="#55D6BE"
Expand Down

0 comments on commit 56a5c60

Please sign in to comment.