I am trying to use a neural network to predict the price of houses. Here is what the top of the dataset looks like:
Price Beds SqFt Built Garage FullBaths HalfBaths LotSqFt
485000 3 2336 2004 2 2.0 1.0 2178.0
430000 4 2106 2005 2 2.0 1.0 2178.0
445000 3 1410 1999 1 2.0 0.0 3049.0
...
I am using the ReLU activation function. When I try to evaluate my model on my test data, I get this TypeError: unsupported operand type(s) for +=: 'Dense' and 'str'.
I looked at the types of the columns from my original dataframe, and everything looks fine.
print(df.dtypes)
## Output
#Price int64
#Beds int64
#SqFt int64
#Built int64
#Garage int64
#FullBaths float64
#HalfBaths float64
#LotSqFt float64
#dtype: object
I'm not sure if I am messing something up in my neural network to cause this error. Any help is appreciated! Here is my code for reference.
- Prepare Data for Network
dataset = df.values
X = dataset[:, 1:8]
Y = dataset[:,0]
## Normalize X-Values
from sklearn import preprocessing
min_max_scaler = preprocessing.MinMaxScaler()
X_scale = min_max_scaler.fit_transform(X)
X_scale
##Partition Data
from sklearn.model_selection import train_test_split
X_train, X_val_and_test, Y_train, Y_val_and_test = train_test_split(X_scale, Y, test_size=0.3)
X_val, X_test, Y_val, Y_test = train_test_split(X_val_and_test, Y_val_and_test, test_size=0.5)
print(X_train.shape, X_val.shape, X_test.shape, Y_train.shape, Y_val.shape, Y_test.shape)
- Begin Model Building
from keras.models import Sequential
from keras.layers import Dense
model = Sequential(
Dense(32, activation='relu', input_shape=(7,)),
Dense(1, activation='linear'))
model.compile(optimizer='sgd',
loss='mse',
metrics=['mean_squared_error'])
model.evaluate(X_test, Y_test)[1] ##Type Error is here!