Online Panel App Compiler

Code, compile, and run Panel App programs online. Write your code in this editor and click the "Run" button to execute it.

import panel as pn

from sklearn.datasets import load_iris
from sklearn.metrics import accuracy_score
from xgboost import XGBClassifier

iris_df = load_iris(as_frame=True)
trees = pn.widgets.IntSlider(start=2, end=30, name="Number of trees")

def pipeline(trees):
    model = XGBClassifier(max_depth=2, n_estimators=trees),
    accuracy = round(accuracy_score(, model.predict( * 100, 1)
    return pn.indicators.Number(
        name="Test score",
        colors=[(97.5, "red"), (99.0, "orange"), (100, "green")],

    "Simple example of training an XGBoost classification model on the small Iris dataset.",,
    "Move the slider below to change the number of training rounds for the XGBoost classifier. The training accuracy score will adjust accordingly.",
    pn.bind(pipeline, trees),