Skip to content

CodeBoxOutput is not completed #17

Open

Description

@xiaomao23zhi

Let's say python code as fllowing:

import pandas as pd
import matplotlib.pyplot as plt
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score

data = pd.read_csv('/mnt/data/train_data.csv')


data['label'].value_counts().plot(kind='bar')
plt.show()


X = data.drop('label', axis=1)
y = data['label']


X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)


dt_model = DecisionTreeClassifier()
dt_model.fit(X_train, y_train)


y_pred = dt_model.predict(X_test)


print("accuracy: ", accuracy_score(y_test, y_pred))

This code snippet will generate 2 outputs: plt.show() and print(). According to this code,codebox-api will return on first output (plt.show()),and it seems the remaining code will not be executed.

So how can I get codebox-api to return both outputs(image/png and text)?

#edit1 typo

Activity

  1. shroominic commented on Mar 1, 2024

    @shroominic
    Owner

    good point currently it is checking for an image output and directly returning the image:
    https://github.com/shroominic/codebox-api/blob/78d5ac65d007d501400f9868f9a75fda1cbcb5ac/src/codeboxapi/box/local.py#L168C1-L173C23
    (code from current work in progress v0.2 but its the same issue)

    I think we can maybe cache the image and not directly return all. But also the CodeBoxOutput needs to get improved then to allow text and image output at the same time.

  2. Repository owner deleted a comment from Agony23 on May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions