Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. '''
  2. Transfer Learning
  3.  
  4. Test Train Split (Data Splitting half for traing and half for testing)
  5.  
  6. Training = 80%
  7. Testing = 20%
  8.  
  9.  
  10. IF (Training Accuracy > Testing Accuracy):
  11. THEN ==>There's Overfitting Problem
  12.  
  13.  
  14. '''
  15. import numpy as np
  16. import pandas as pd
  17. import matplotlib.pyplot as plt
  18.  
  19. from keras.models import Sequential
  20. from keras.layers import Dense
  21. from keras.optimizers import Adam
  22.  
  23.  
  24. data = pd.read_csv('wh.csv')
  25.  
  26. x = data['Height']
  27. y = data['Weight']
  28.  
  29. m = Sequential()
  30. m.add(Dense(1, input_shape=(1, )))
  31. m.compile(Adam(lr=0.8), 'mean_squared_error')
  32.  
  33.  
  34.  
  35. '''
  36. m.fit(x,y,epochs=45)
  37. yp = m.predict(x)
  38. print(yp)
  39.  
  40. h = float(input("enter height in cm "))
  41. hcm = h * 0.3937007874
  42.  
  43. w,b = m.get_weights()
  44.  
  45. yw = b+w*hcm
  46. print(yw)
  47. '''
  48.  
  49. from sklearn.model_selection import train_test_split
  50.  
  51. xtr,xts, ytr, yts = train_test_split(x,y,test_size=0.2)
  52.  
  53. m.fit(xtr,ytr,epochs=45)
  54.  
  55. ytrp = m.predict(xtr)
  56. ytsp = m.predict(xts)
  57.  
  58. from sklearn.metrics import r2_score
  59.  
  60. print("{:0.3f}".format(r2_score(ytr,ytrp))) #Smaller
  61. print("{:0.3f}".format(r2_score(yts,ytsp))) #Bigger
  62.  
  63. ===================================================================
  64.  
  65.  
  66. '''
  67. Transfer Learning
  68.  
  69. Test Train Split (Data Splitting half for traing and half for testing)
  70.  
  71. Training = 80%
  72. Testing = 20%
  73.  
  74.  
  75. IF (Training Accuracy > Testing Accuracy):
  76. THEN ==>There's Overfitting Problem
  77.  
  78. pip install sklearn
  79.  
  80. Classification = Single or Multiple
  81. Sigmoid Softmax
  82.  
  83.  
  84. '''
  85. import numpy as np
  86. import pandas as pd
  87. import matplotlib.pyplot as plt
  88. from keras.models import Sequential
  89. from keras.layers import Dense
  90. from keras.optimizers import Adam
  91.  
  92.  
  93. data = pd.read_csv("visit.csv")
  94.  
  95. x = data['Time']
  96. y = data['Buy']
  97.  
  98. m = Sequential()
  99. m.add(Dense(1, input_shape=(1, ), activation='sigmoid'))
  100. m.compile(Adam(lr=0.5), 'binary_crossentropy')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement