2023-05-17 10:21:39 +09:00
|
|
|
import datahub.metadata.schema_classes as models
|
2025-06-12 14:00:26 +09:00
|
|
|
from datahub.metadata.urns import MlFeatureUrn, MlModelGroupUrn
|
|
|
|
from datahub.sdk import DataHubClient
|
|
|
|
from datahub.sdk.mlmodel import MLModel
|
2023-05-17 10:21:39 +09:00
|
|
|
|
2025-06-12 14:00:26 +09:00
|
|
|
client = DataHubClient.from_env()
|
2023-05-17 10:21:39 +09:00
|
|
|
|
2025-06-12 14:00:26 +09:00
|
|
|
mlmodel = MLModel(
|
|
|
|
id="my-recommendations-model",
|
|
|
|
name="My Recommendations Model",
|
|
|
|
platform="mlflow",
|
|
|
|
model_group=MlModelGroupUrn(
|
|
|
|
platform="mlflow", name="my-recommendations-model-group"
|
2023-05-17 10:21:39 +09:00
|
|
|
),
|
2025-06-12 14:00:26 +09:00
|
|
|
custom_properties={
|
|
|
|
"framework": "pytorch",
|
|
|
|
},
|
|
|
|
extra_aspects=[
|
|
|
|
models.MLModelPropertiesClass(
|
|
|
|
mlFeatures=[
|
|
|
|
str(
|
|
|
|
MlFeatureUrn(
|
|
|
|
feature_namespace="users_feature_table", name="user_signup_date"
|
|
|
|
)
|
|
|
|
),
|
|
|
|
str(
|
|
|
|
MlFeatureUrn(
|
|
|
|
feature_namespace="users_feature_table",
|
|
|
|
name="user_last_active_date",
|
|
|
|
)
|
|
|
|
),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
],
|
|
|
|
training_metrics={
|
|
|
|
"accuracy": "1.0",
|
|
|
|
"precision": "0.95",
|
|
|
|
"recall": "0.90",
|
|
|
|
"f1_score": "0.92",
|
|
|
|
},
|
|
|
|
hyper_params={
|
|
|
|
"learning_rate": "0.01",
|
|
|
|
"num_epochs": "100",
|
|
|
|
"batch_size": "32",
|
|
|
|
},
|
2023-05-17 10:21:39 +09:00
|
|
|
)
|
|
|
|
|
2025-06-12 14:00:26 +09:00
|
|
|
client.entities.update(mlmodel)
|