ACCURACY
Download Flojoy Studio to try this app
  
 Take two dataframes with the true and predicted labels from a classification task, and indicates whether the prediction was correct or not. These dataframes should both be single columns.  Params:    true_label : optional str  true label users can select from original data   predicted_label : optional str  resulting predicted label users can select     Returns:    out : DataFrame  The input predictions dataframe, with an extra boolean column "prediction_correct".    
Python Code
from typing import Optional
from flojoy import DataFrame, flojoy
@flojoy
def ACCURACY(
    true_data: DataFrame,
    predicted_data: DataFrame,
    true_label: Optional[str] = None,
    predicted_label: Optional[str] = None,
) -> DataFrame:
    """Take two dataframes with the true and predicted labels from a classification task, and indicates whether the prediction was correct or not.
    These dataframes should both be single columns.
    Parameters
    ----------
    true_label : optional str
        true label users can select from original data
    predicted_label : optional str
        resulting predicted label users can select
    Returns
    -------
    DataFrame
        The input predictions dataframe, with an extra boolean column "prediction_correct".
    """
    true_df = true_data.m
    predicted_df = predicted_data.m
    # if users prov
    if true_label:
        true_label = true_df[true_label]
    else:
        true_label = true_df.iloc[:, 0]
    if predicted_label:
        predicted_label = predicted_df[predicted_label]
    else:
        predicted_label = predicted_df.iloc[:, 0]
    predicted_df["prediction_correct"] = true_label == predicted_label
    return DataFrame(df=predicted_df)
Example App
Having problems with this example app? Join our Discord community and we will help you out!
In this example, the iris dataset is split into two parts, one for training and the other for testing. The labels from the test data are stripped using an EXTRACT_COLUMNS node, taking only the features of the data.
The true labels are also extracted with another EXTRACT_COLUMNS to be passed to the the ACCURACY node, along with the SUPPORT_VECTOR_MACHINE predictions.
In the output, we see that the SUPPORT_VECTOR_MACHINE has made correct predictions for all of the test data.