Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Transfer Learning
- Test Train Split (Data Splitting half for traing and half for testing)
- Training = 80%
- Testing = 20%
- IF (Training Accuracy > Testing Accuracy):
- THEN ==>There's Overfitting Problem
- '''
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- from keras.models import Sequential
- from keras.layers import Dense
- from keras.optimizers import Adam
- data = pd.read_csv('wh.csv')
- x = data['Height']
- y = data['Weight']
- m = Sequential()
- m.add(Dense(1, input_shape=(1, )))
- m.compile(Adam(lr=0.8), 'mean_squared_error')
- '''
- m.fit(x,y,epochs=45)
- yp = m.predict(x)
- print(yp)
- h = float(input("enter height in cm "))
- hcm = h * 0.3937007874
- w,b = m.get_weights()
- yw = b+w*hcm
- print(yw)
- '''
- from sklearn.model_selection import train_test_split
- xtr,xts, ytr, yts = train_test_split(x,y,test_size=0.2)
- m.fit(xtr,ytr,epochs=45)
- ytrp = m.predict(xtr)
- ytsp = m.predict(xts)
- from sklearn.metrics import r2_score
- print("{:0.3f}".format(r2_score(ytr,ytrp))) #Smaller
- print("{:0.3f}".format(r2_score(yts,ytsp))) #Bigger
- ===================================================================
- '''
- Transfer Learning
- Test Train Split (Data Splitting half for traing and half for testing)
- Training = 80%
- Testing = 20%
- IF (Training Accuracy > Testing Accuracy):
- THEN ==>There's Overfitting Problem
- pip install sklearn
- Classification = Single or Multiple
- Sigmoid Softmax
- '''
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- from keras.models import Sequential
- from keras.layers import Dense
- from keras.optimizers import Adam
- data = pd.read_csv("visit.csv")
- x = data['Time']
- y = data['Buy']
- m = Sequential()
- m.add(Dense(1, input_shape=(1, ), activation='sigmoid'))
- m.compile(Adam(lr=0.5), 'binary_crossentropy')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement