Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
The ACCURACY node takes 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".

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from flojoy import flojoy, DataFrame
from typing import Optional


@flojoy
def ACCURACY(
true_data: DataFrame,
predicted_data: DataFrame,
true_label: Optional[str] = None,
predicted_label: Optional[str] = None,
) -> DataFrame:


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)
Loading