0
$\begingroup$

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()

 rsme plot

rsme and r2score

what changes are needed to improve my model

dataset: enter image description here enter image description here

colab link of code

$\endgroup$
3
  • $\begingroup$ Contrary to metrics like classification accuracy which are expressed in percentages, no value of RMSE can be considered as "low" or "high" in itself; it critically depends on the scale of the dependent variable. If, say, you have a y that ranges between 0-500, an RMSE of 298 would indeed seem rather high; but the same RMSE of 298 for a y that is in the range of, say, 10,000 - 20,000 would count as rather great! $\endgroup$
    – desertnaut
    Commented Sep 29, 2020 at 22:48
  • $\begingroup$ So you are saying my is doing a great job and I can conclude my work $\endgroup$ Commented Sep 30, 2020 at 3:10
  • $\begingroup$ I'm saying to check the RMSE in relation to your outouts y and their scale before deciding so. $\endgroup$
    – desertnaut
    Commented Sep 30, 2020 at 9:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.