A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
Picking the right architecture = Picking the right battles + Managing trade-offs
| """ Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """ | |
| import numpy as np | |
| import cPickle as pickle | |
| import gym | |
| # hyperparameters | |
| H = 200 # number of hidden layer neurons | |
| batch_size = 10 # every how many episodes to do a param update? | |
| learning_rate = 1e-4 | |
| gamma = 0.99 # discount factor for reward |
| import numpy as np | |
| from keras.models import Sequential | |
| from keras.layers.core import Activation, Dense | |
| training_data = np.array([[0,0],[0,1],[1,0],[1,1]], "float32") | |
| target_data = np.array([[0],[1],[1],[0]], "float32") | |
| model = Sequential() | |
| model.add(Dense(32, input_dim=2, activation='relu')) | |
| model.add(Dense(1, activation='sigmoid')) |
| """ | |
| A DAG definition file in Airflow, written in Python. | |
| """ | |
| from datetime import datetime, timedelta | |
| from airflow.models import DAG # Import the DAG class | |
| from airflow.operators.bash_operator import BashOperator | |
| from airflow.operators.sensors import TimeDeltaSensor | |
| default_args = { | |
| 'owner': 'you', |