Skip to content
Snippets Groups Projects
Prediction.js 1.42 KiB
Newer Older
Matthieu BELLUCCI's avatar
Matthieu BELLUCCI committed
import { render } from '@testing-library/react';
import './Prediction.css';
import BarChart from './BarChart';
import PredictionTab from './Tabs';

function TextExplanation(props) {
    const isConsistent = props.data.isConsistent;
    const predictedClass = props.data.predictedClass;
    const predictionColor = isConsistent ? "green" : "red";
    return (
        <div className="Label">
            <h1 style={{color:predictionColor}}>{predictedClass}</h1>
            <p>
                The model saw a {predictedClass} and it is {isConsistent ? "consistent" : "not consistent"} with the expert knowledge.
            </p>
            <p>
                ADD PROPERTIES EXPLANATIONS
            </p>
        </div>
    )
}

Matthieu BELLUCCI's avatar
Matthieu BELLUCCI committed
function Prediction(props) {
    const properties = Object.entries(props.data.prediction.properties);
    console.log(properties[0][1])
    const tabList = properties.map(function(x) {return {name: x[0], content: <BarChart data={x[1]}/>};});
Matthieu BELLUCCI's avatar
Matthieu BELLUCCI committed
    return (
Matthieu BELLUCCI's avatar
Matthieu BELLUCCI committed

Matthieu BELLUCCI's avatar
Matthieu BELLUCCI committed
    <div className="Prediction">
Matthieu BELLUCCI's avatar
Matthieu BELLUCCI committed
        <div className="UpperPrediction">
            <div className="Image">
                <img 
                src={props.img}
                alt={props.label}
                />
            </div>
            <TextExplanation data={props.data.prediction} />
Matthieu BELLUCCI's avatar
Matthieu BELLUCCI committed
        </div>
Matthieu BELLUCCI's avatar
Matthieu BELLUCCI committed
        <div className="LowerPrediction">
            <PredictionTab  tabList={tabList}/>
Matthieu BELLUCCI's avatar
Matthieu BELLUCCI committed
        </div>
    </div>
    );
}

export default Prediction;