Skip to content

Instantly share code, notes, and snippets.

@frogermcs
Created May 28, 2019 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frogermcs/0e95c0bfc572eb78af7a24523bf237c1 to your computer and use it in GitHub Desktop.
Save frogermcs/0e95c0bfc572eb78af7a24523bf237c1 to your computer and use it in GitHub Desktop.
# Concatenation of argmax and max value for each row
def max_values_only(data):
argmax_col = np.argmax(data, axis=1).reshape(-1, 1)
max_col = np.max(data, axis=1).reshape(-1, 1)
return np.concatenate([argmax_col, max_col], axis=1)
# Build simplified prediction tables
tf_model_pred_simplified = max_values_only(tf_model_predictions)
tflite_model_pred_simplified = max_values_only(tflite_model_predictions)
tflite_q_model_pred_simplified = max_values_only(tflite_q_model_predictions)
# Build DataFrames and present example
columns_names = ["Label_id", "Confidence"]
tf_model_simple_dataframe = pd.DataFrame(tf_model_pred_simplified)
tf_model_simple_dataframe.columns = columns_names
tflite_model_simple_dataframe = pd.DataFrame(tflite_model_pred_simplified)
tflite_model_simple_dataframe.columns = columns_names
tflite_q_model_simple_dataframe = pd.DataFrame(tflite_q_model_pred_simplified)
tflite_q_model_simple_dataframe.columns = columns_names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment