hello every one

i want to practice deep learning as descibed for a home price prediction problem

i use code as following

# IMPORTING PACKAGES

import pandas as pd # data processing

import numpy as np # working with arrays

import matplotlib.pyplot as plt # visualization

import seaborn as sb # visualization

from termcolor import colored as cl # text customization

from sklearn.model_selection import train_test_split # data split

from sklearn.linear_model import LinearRegression # OLS algorithm

from sklearn.linear_model import Ridge # Ridge algorithm

from sklearn.linear_model import Lasso # Lasso algorithm

from sklearn.linear_model import BayesianRidge # Bayesian algorithm

from sklearn.linear_model import ElasticNet # ElasticNet algorithm

from sklearn.preprocessing import MinMaxScaler

from sklearn.metrics import explained_variance_score as evs # evaluation metric

from sklearn.metrics import r2_score as r2 # evaluation metric

from keras.models import Sequential

from keras.layers import Dense

from sklearn.model_selection import train_test_split

from sklearn.preprocessing import MinMaxScaler

import matplotlib.pyplot as plt

import pandas as pd

from keras.callbacks import LearningRateScheduler

sb.set_style('whitegrid') # plot style

plt.rcParams['figure.figsize'] = (20, 10) # plot size

# IMPORTING DATA

from google.colab import files

uploaded = files.upload()

df = pd.read_csv('kc_house_data.csv')

df.set_index('id', inplace = True)

df.head(5)

df.dropna(inplace = True)

print(cl(df.isnull().sum(), attrs = ['bold']))

df.describe()

print(cl(df.dtypes, attrs = ['bold']))

df['price'] = pd.to_numeric(df['price'], errors = 'coerce')

df['price'] = df['price'].astype('int32')

#

df['bathrooms'] = pd.to_numeric(df['bathrooms'], errors = 'coerce')

df['bathrooms'] = df['bathrooms'].astype('int32')

#

df['floors'] = pd.to_numeric(df['floors'], errors = 'coerce')

df['floors'] = df['floors'].astype('int32')

#

df['lat'] = pd.to_numeric(df['lat'], errors = 'coerce')

df['lat'] = df['lat'].astype('int32')

#

df['long'] = pd.to_numeric(df['long'], errors = 'coerce')

df['long'] = df['long'].astype('int32')

#

print(cl(df.dtypes, attrs = ['bold']))

dataset=df.values

dataset

X=dataset[:,1:19]

Y=dataset[:,1]

print(Y)

min_max_scaler=MinMaxScaler()

X_scale = min_max_scaler.fit_transform(X)

X_scale

X_train,X_val_and_test,Y_train,Y_val_and_test = train_test_split(X_scale,Y, test_size=0.2)

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)

model=Sequential()

model.add(Dense(units=32, activation = 'relu', input_dim=18))

model.add(Dense(units=32,activation='relu'))

model.add(Dense(units=32,activation='relu'))

model.add(Dense(units=1,activation='sigmoid'))

model.compile(optimizer='sgd',

loss='binary_crossentropy',

metrics=['accuracy'])

X_train = np.asarray(X_train).astype('float32')

Y_train = np.asarray(Y_train).astype('float32')

X_val = np.asarray(X_val).astype('float32')

Y_val = np.asarray(Y_val).astype('float32')

X_test = np.asarray(X_test).astype('float32')

Y_test = np.asarray(Y_test).astype('float32')

hist = model.fit(

X_train, Y_train,

batch_size=32, epochs=5,

validation_data=(X_val, Y_val)

)

but in last model.hit stage i get zero accuracy and nan loss values from the fırst epoch

what is the problem and how i could fix that

here is the dataset and screen shot of last results

More Solmaz Babakan's questions See All
Similar questions and discussions