import pandas as pd from sklearn.linear_model import LinearRegression @asset def iris_dataset() -> pd.DataFrame: return pd.read_csv( "https://docs.dagster.io/assets/iris.csv", names=["sepal_length_cm","sepal_width_cm","petal_length_cm","petal_width_cm","species"] ) @asset def logistic_regression_model(iris_dataset: pd.DataFrame) -> LinearRegression: x = iris_dataset[["sepal_length_cm", "sepal_width_cm", "petal_length_cm", "petal_width_cm"]] y = iris_dataset["species"].map({"Iris-setosa": 0, "Iris-versicolor": 1, "Iris-virginica": 2}) return LinearRegression().fit(x, y) @asset def accuracy(logistic_regression_model: LinearRegression) -> Dict: return { "intercept": logistic_regression_model.intercept_, "coef": logistic_regression_model.coef_, } @assetデコレータでAssetを 作成 関数引数がAssetの依存関係 を表す