Python Neural Network Basics

From https://iamtrask.github.io/2015/07/12/basic-python-network/ import numpy as np sigmoid function def nonlin(x,deriv=False): if(deriv==True): return x*(1-x) return 1/(1+np.exp(-x)) input dataset X = np.array([ [0,0,1], [0,1,1], [1,0,1], [1,1,1] ]) output dataset y = np.array([[0,0,1,1]]).T seed random numbers to make calculation deterministic (just a good practice) np.random.seed(1) initialize weights randomly with mean 0 syn0 = 2*np.random.random((3,1)) - 1 print(syn0) ## [[-0.16595599] ## [ 0.44064899] ## [-0.99977125]] variables l0 is input layer l1 is hidden layer l1_error is the loss function l1_delta is the gradient descent function for calculating the back-propagation syn0 are synapses, weights between l0 and l1, and also how the weights are updated are shown. [Read More]
Python 

Codecademy - Pandas Lesson

You’re getting ready to staff the clinic for March this year. You want to know how many visits took place in March last year, to help you prepare. Write a command that will produce a Series made up of the March data from df from all four clinic sites and save it to the variable march. #import /;../,codecademylib3 import pandas as pd df = pd.DataFrame([ ['January', 100, 100, 23, 100], ['February', 51, 45, 145, 45], ['March', 81, 96, 65, 96], ['April', 80, 80, 54, 180], ['May', 51, 54, 54, 154], ['June', 112, 109, 79, 129]], columns=['month', 'clinic_east', 'clinic_north', 'clinic_south', 'clinic_west']) print(df) ## month clinic_east clinic_north clinic_south clinic_west ## 0 January 100 100 23 100 ## 1 February 51 45 145 45 ## 2 March 81 96 65 96 ## 3 April 80 80 54 180 ## 4 May 51 54 54 154 ## 5 June 112 109 79 129 # integer location within dataframe # locations are zero indexed and doesn't include the ending integer march = df. [Read More]
Python 

Ideas from programming

  • Version Control and GitHub + Main/Branches, Push/Pull/Merge
  • Functions/Modules
    • Methods should be deep.
    • Write the interface first
  • Try to minimize exceptions
    • define them away
  • Be strategic + Invest in building the future/don’t introduce bad code today
  • Write the unit test before the useful code
  • Make sure you do input validation