# Add an evaluator training_pipeline.add_evaluator( TFMAEvaluator( slices=[['has_diabetes']], metrics={'has_diabetes': ['binary_crossentropy', 'binary_accuracy']})) # Define the metadata store metadata_store = MySQLMetadataStore( host=MYSQL_HOST, port=int(MYSQL_PORT), database=MYSQL_DB, username=MYSQL_USER, password=MYSQL_PWD, ) # Define the artifact store artifact_store = ArtifactStore( os.path.join(GCP_BUCKET, 'kubernetes_orcestrated/artifact_store')) # Define the orchestrator backend orchestrator_backend = OrchestratorKubernetesBackend( kubernetes_config_path=K8S_CONFIG_PATH, image_pull_policy="Always") # Run the pipeline on a Kubernetes Cluster training_pipeline.run( backend=orchestrator_backend, metadata_store=metadata_store, artifact_store=artifact_store, )
training_pipeline.add_evaluator( TFMAEvaluator( slices=[['has_diabetes']], metrics={'has_diabetes': ['binary_crossentropy', 'binary_accuracy']})) # Important details: artifact_store_bucket = 'gs://rndm-strg/zenml-k8s-test/' mysql_host = 'cloudsql' mysql_port = 3306 mysql_db = 'zenml' mysql_user = USERNAME mysql_pw = PASSWORD # Path to your kubernetes config: k8s_config_path = os.path.join(os.environ["HOME"], '.kube/config') # Run the pipeline on a Kubernetes Cluster training_pipeline.run(backends=[ OrchestratorKubernetesBackend(kubernetes_config_path=k8s_config_path, image_pull_policy="Always") ], metadata_store=MySQLMetadataStore( host=mysql_host, port=mysql_port, database=mysql_db, username=mysql_user, password=mysql_pw, ), artifact_store=ArtifactStore(artifact_store_bucket))
features=['times_pregnant', 'pgc', 'dbp', 'tst', 'insulin', 'bmi', 'pedigree', 'age'], labels=['has_diabetes'], overwrite={'has_diabetes': { 'transform': [{'method': 'no_transform', 'parameters': {}}]}} ).with_backend(processing_backend) ) # Add a trainer training_pipeline.add_trainer(FeedForwardTrainer( loss='binary_crossentropy', last_activation='sigmoid', output_units=1, metrics=['accuracy'], epochs=20)) # Add an evaluator training_pipeline.add_evaluator( TFMAEvaluator( slices=[['has_diabetes']], metrics={'has_diabetes': ['binary_crossentropy', 'binary_accuracy']} ).with_backend(processing_backend) ) # Define the artifact store artifact_store = ArtifactStore( os.path.join(GCP_BUCKET, 'dataflow_processing/artifact_store')) # Run the pipeline training_pipeline.run(artifact_store=artifact_store)
# Add a split training_pipeline.add_split(RandomSplit(split_map={'eval': 0.3, 'train': 0.7})) # Add a preprocessing unit training_pipeline.add_preprocesser( StandardPreprocesser(features=[ 'times_pregnant', 'pgc', 'dbp', 'tst', 'insulin', 'bmi', 'pedigree', 'age' ], labels=['has_diabetes'], overwrite={ 'has_diabetes': { 'transform': [{ 'method': 'no_transform', 'parameters': {} }] } })) # Add a trainer training_pipeline.add_trainer( FeedForwardTrainer(loss='binary_crossentropy', last_activation='sigmoid', output_units=1, metrics=['accuracy'], epoch=100)) # Run the pipeline locally training_pipeline.run()