Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeBoxOutput is not completed #17

Open
xiaomao23zhi opened this issue Feb 27, 2024 · 1 comment
Open

CodeBoxOutput is not completed #17

xiaomao23zhi opened this issue Feb 27, 2024 · 1 comment

Comments

@xiaomao23zhi
Copy link

xiaomao23zhi commented Feb 27, 2024

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

@shroominic
Copy link
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.

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

No branches or pull requests

2 participants