Amr Al-Omari
Amr Al-Omari

Reputation: 25

ML Model giving me Zero accuracy

I'm testing an ML model on a small dataset

data = pd.read_csv("house.csv")
x=data.iloc[:,0:3]
y=data["price"]
sd=preprocessing.scale(x)
#print(sd)
#print(data.head())

from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import Adam

model = Sequential()
model.add(Dense(1, input_shape=(3,)))
model.compile(Adam(lr=0.8), "mean_squared_error", metrics=["accuracy"])
model.fit(sd,y,epochs=100)
yp=model.predict(sd)
data ["pred"] = yp

but when the model starts training it gave me accuracy Zero and the loss is unbelievable !!

Epoch 100/100 32/47 [===================>..........] - ETA: 0s - loss: 125331226624.0000 - accuracy: 0.0000e+00 47/47 [==============================] - 0s 85us/step - loss: 131038484959.3192 - accuracy: 0.0000e+00

here is the dataset https://uinedu-my.sharepoint.com/:x:/g/personal/26636_myoffice_site/EWXspQfJBUVErTuYUuupaUoBO7kY8n1T5j-8I7k_V2zzMQ?e=lJvwaI

Upvotes: 1

Views: 679

Answers (1)

hzitoun
hzitoun

Reputation: 5832

As said in the comment, accuracy is not a regression metric.

To evaluate a regression model, here is some of the metrics you can use:

  • Mean Squared Error (MSE)
  • Root Mean Squared Error (RMSE)
  • Mean Absolute Error (MAE)
  • R Squared (R²)
  • Adjusted R Squared (R²)
  • Mean Square Percentage Error (MSPE)
  • Mean Absolute Percentage Error (MAPE)
  • Root Mean Squared Logarithmic Error (RMSLE)

This great story on medium explains all of these metrics https://medium.com/@george.drakos62/how-to-select-the-right-evaluation-metric-for-machine-learning-models-part-1-regrression-metrics-3606e25beae0

A shorter explanation can be found here https://stats.stackexchange.com/questions/142873/how-to-determine-the-accuracy-of-regression-which-measure-should-be-used

In keras

model.compile(optimizer=Adam(lr=0.8), loss='mean_squared_error', metrics=['mean_squared_error'])

Upvotes: 3

Related Questions