I have a data set on predicting solar power generation, I am getting root mean squared loos of 0.3196 on training set on scaled values, but when I inverse transform them my loss rises to 298 on training and 488 on test set. but my r2scores are .883 and .69 on tests and training sets. R2 scores seems acceptable but why i am getting large value of error.
Here is my code:
data_path = r'drive/My Drive/Proj/S.P.F./solarpowergeneration.csv'
dts = pd.read_csv('solarpowergeneration.csv')
dts.head()
X = dts.iloc[:, :-1].values
y = dts.iloc[:, -1].values
print(X.shape, y.shape)
y = np.reshape(y, (-1,1))
y.shape
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)
from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
X_train = sc_X.fit_transform(X_train)
X_test = sc_X.transform(X_test)
# outcome scaling:
sc_y = StandardScaler()
y_train = sc_y.fit_transform(y_train)
y_test = sc_y.transform(y_test)
def get_spfnet():
ann = tf.keras.models.Sequential()
ann.add(Dense(X_train.shape[1], activation='relu'))
ann.add(BatchNormalization())
ann.add(Dense(32, activation='relu', kernel_regularizer=regularizers.l2(0.01)))
ann.add(BatchNormalization())
ann.add(Dense(64, activation='relu', kernel_regularizer=regularizers.l2(0.01)))
ann.add(BatchNormalization())
ann.add(Dense(1))
ann.compile(loss='mse',
optimizer='adam',
metrics=[tf.keras.metrics.RootMeanSquaredError()])
return ann
spfnet = get_spfnet()
#spfnet.summary()
hist = spfnet.fit(X_train, y_train, batch_size=32, validation_data=(X_test, y_test),epochs=250, verbose=2)
the accuracy and loss graphs are
plt.plot(hist.history['root_mean_squared_error'])
plt.plot(hist.history['val_root_mean_squared_error'])
plt.title('Model error')
plt.xlabel('Epochs')
plt.ylabel('error')
plt.show()
what changes are needed to improve my model
y
that ranges between 0-500, an RMSE of 298 would indeed seem rather high; but the same RMSE of 298 for ay
that is in the range of, say, 10,000 - 20,000 would count as rather great! $\endgroup$y
and their scale before deciding so. $\endgroup$