This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define Optimizer | |
| adam = Adam(learning_rate=learning_rate, beta_1=0.9, beta_2=0.999, amsgrad=False) | |
| # define model | |
| model = Sequential() | |
| model.add(Dense(m, activation='relu', input_dim=n)) | |
| model.add(Dense(M, activation='relu')) | |
| model.add(Dense(N, activation='linear')) | |
| model.compile(optimizer=adam, loss='mse') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # fit model | |
| model.fit(x_train, y_train, epochs=TRAIN_ITER, verbose=1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # test model | |
| y_prediction = model.predict(x_test, verbose=0) | |
| y_prediction = np.reshape(y_prediction, (y_prediction.shape[0])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| t = CO_TS[CO_TS.index.month == 12].index.to_numpy() | |
| t = t[n_sampling:] | |
| y_PD = pd.DataFrame(data={'t':t, 'y_test':y_test}, | |
| index=t, | |
| columns=['t', 'y_test']) | |
| y_prediction_PD = pd.DataFrame(data={'t':t, 'y_prediction':y_prediction}, | |
| index=t, | |
| columns=['t', 'y_prediction']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import airflow | |
| from airflow import DAG | |
| from airflow.operators.dummy_operator import DummyOperator | |
| from airflow.operators.python_operator import PythonOperator | |
| from airflow.operators.bash_operator import BashOperator | |
| from datetime import datetime | |
| from datetime import timedelta |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| default_args = { | |
| 'owner': 'default_user', | |
| 'start_date': airflow.utils.dates.days_ago(1), | |
| 'depends_on_past': True, | |
| #With this set to true, the pipeline won't run if the previous day failed | |
| 'email': ['info@example.com'], | |
| 'email_on_failure': True, | |
| #upon failure this pipeline will send an email to your email set above | |
| 'email_on_retry': False, | |
| 'retries': 5, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dag = DAG( | |
| 'simple_pipeline', | |
| default_args=default_args, | |
| schedule_interval=timedelta(days=1), | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def my_func(): | |
| print('Hello from my_func') | |
| bashtask = BashOperator( | |
| task_id='print_date', | |
| bash_command='date', | |
| dag=dag) | |
| dummy_task = DummyOperator( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #python_task dependencies ke bashtask, | |
| #python_task akan di execute jika bashtask success | |
| bashtask.set_downstream(python_task) | |
| # sama seperti diatas, dummy_task akan di execute jika bashtask success | |
| dummy_task.set_upstream(bashtask) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #python_task dependencies ke bashtask, | |
| #python_task akan di execute jika bashtask success | |
| bashtask >> python_task | |
| # sama seperti diatas, dummy_task akan di execute jika bashtask success | |
| bashtask >> dummy_task |