hi all, I Cant see cards in Metaflow UI I want to...
# ask-metaflow
w
hi all, I Cant see cards in Metaflow UI I want to be able to see all artifacts stores in
self
in the Metaflow UI Card visualization. Right now i’m using the sandbox:
ob-metaflow               2.11.15.3
Some artifacts I’d want are related to model registry, model performance, metrics and data. Same thing happen with this example: https://docs.metaflow.org/metaflow/visualizing-results/easy-custom-reports-with-card-components#comparing-data-across-runs
class OptunaDemo(FlowSpec):
n_trials = Parameter('n_trials', default=25, help='Number of trials for HPO')
@step
def start(self):
self.next(self.train)
@card(id='best_model')
@card(id='hpo')
@conda(
python='3.12',
packages={'numpy': '1.26.4', 'optuna': '3.6.0', 'scikit-learn': '1.4.2', 'pandas': '2.2.2'}
)
@step
def train(self):
import optuna
study = optuna.create_study(direction='maximize')
study.optimize(self.objective, n_trials=self.n_trials)
self.results = study.trials_dataframe()
self.best_params = study.best_params
current.card['best_model'].append(Markdown(f"### Best model parameters: {self.best_params}"))
current.card['hpo'].append(Table.from_dataframe(self.results.sort_values('value', ascending=False)))
self.next(self.evaluate)
@conda(
python='3.12',
packages={'numpy': '1.26.4', 'scikit-learn': '1.4.2'}
)
@step
def evaluate(self):
from sklearn.datasets import load_iris
from sklearn.tree import ExtraTreeClassifier
# fit on same data.
data = load_iris()
X, y = data['data'], data['target']
model = ExtraTreeClassifier(**self.best_params)
model.fit(X, y)
# this is just a demo
# in real life, evaluate on a test set.
y_hat = model.predict(X)
self.accuracy = (y_hat == y).mean()
print(f"Accuracy: {self.accuracy}")
self.next(self.end)
@step
def end(self):
print("Flow completed")
def objective(self, trial):
from sklearn.datasets import load_iris
from sklearn.tree import ExtraTreeClassifier
from sklearn.model_selection import cross_val_score
import numpy as np
data = load_iris()
X, y = data['data'], data['target']
max_depth = trial.suggest_int('max_depth', 2, 16)
criterion = trial.suggest_categorical(
'criterion',
["gini", "entropy"]
)
model = ExtraTreeClassifier(max_depth=max_depth,
criterion=criterion)
return np.mean(cross_val_score(model, X, y, cv=5))
if __name__ == '__main__':
OptunaDemo()
I cannot download the html as well:
Copy code
(ob-full-stack-ml) metaflow-sandbox$ python optuna_demo.py --environment=conda card get start demo.html
Metaflow 2.11.15.3+ob(v1) executing OptunaDemo for user:sandbox
Resolving card: OptunaDemo/19/start/81
    Card not found in datastore:
    Card not found for pathspec OptunaDemo/19/start/81
1