Skip to content

Instantly share code, notes, and snippets.

View Muhammad-Yunus's full-sized avatar
:octocat:
Working from home

Muhammad Yunus Muhammad-Yunus

:octocat:
Working from home
View GitHub Profile
#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')
# fit model
model.fit(x_train, y_train, epochs=TRAIN_ITER, verbose=1)
# test model
y_prediction = model.predict(x_test, verbose=0)
y_prediction = np.reshape(y_prediction, (y_prediction.shape[0]))
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'])
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
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,
dag = DAG(
'simple_pipeline',
default_args=default_args,
schedule_interval=timedelta(days=1),
)
def my_func():
print('Hello from my_func')
bashtask = BashOperator(
task_id='print_date',
bash_command='date',
dag=dag)
dummy_task = DummyOperator(
#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)
#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