GithubHelp home page GithubHelp logo

Comments (3)

dennisbader avatar dennisbader commented on June 1, 2024

Hi @SyedKumailHussainNaqvi, this looks like there are some missing values either in your target or predicted series.

from darts.

SyedKumailHussainNaqvi avatar SyedKumailHussainNaqvi commented on June 1, 2024

Thank for your kind guidance, I fix this but i have another query about TransformerModel.
I have these train, validation and test series after scaling now i just predict the trained Transformer model on test series for forecasting without n – The number of time steps after the end of the training time series, how its possible?

scaler = MinMaxScaler(feature_range=(-1, 1))
scaler_target = Scaler(scaler)
scaler_input = Scaler(scaler)
Train_Target_Active_Power_scaled = scaler_target.fit_transform(Target_train_series)
Train_Input_Features_scaled = scaler_input.fit_transform(Input_train_series)

val_Target_Active_Power_scaled = scaler_target.transform(Target_val_series)
val_Input_Features_scaled = scaler_input.transform(Input_val_series)

Test_Target_Active_Power_scaled = scaler_target.transform(Target_test_series)
Test_Input_Features_scaled = scaler_input.transform(Input_test_series)

my_model = TransformerModel(
    input_chunk_length=32,
    output_chunk_length=288,
    batch_size=128,
    n_epochs=1,
    #model_name="air_transformer",
    nr_epochs_val_period=100,
    d_model=32,
    nhead=16,
    num_encoder_layers=8,
    num_decoder_layers=8,
    dim_feedforward=256,
    dropout=0.1,
    activation="relu",
    #random_state=42,
    #save_checkpoints=True,
    force_reset=True,
    pl_trainer_kwargs={
      "accelerator": "gpu",
       "devices": 1
    },
)
my_model.fit(
    series=Train_Target_Active_Power_scaled,past_covariates=Train_Input_Features_scaled, val_series=val_Target_Active_Power_scaled,val_past_covariates=val_Input_Features_scaled,
    verbose=True,
);
pred_series = my_model.predict(n=len(Test_Target_Active_Power_scaled), series=Test_Target_Active_Power_scaled, past_covariates=Test_Input_Features_scaled)

Actual_Pred= scaler_target.inverse_transform(pred_series)
Actual_val_Target_Active_Power= scaler_target.inverse_transform(Test_Target_Active_Power_scaled)

mape_score = mape(Actual_Pred,Actual_val_Target_Active_Power)
mse_score = mse(Actual_Pred,Actual_val_Target_Active_Power)
mae_score = mae(Actual_Pred, Actual_val_Target_Active_Power)
print(f'MAPE: {mape_score:.4f}')
print(f'RMSE: {mse_score:.4f}')
print(f'MAE: {mae_score:.4f}')

from darts.

madtoinou avatar madtoinou commented on June 1, 2024

Hi @SyedKumailHussainNaqvi,

I have these train, validation and test series after scaling now i just predict the trained Transformer model on test series for forecasting without n – The number of time steps after the end of the training time series, how its possible?

I don't understand what you mean by this, your code snippet is clearly relying on n to indicate the length of the forecasts. This argument is mandatory.

If you want to forecast the series with the same index as your test series in order to compute metrics, you need to use my_model.predict(n=len(test_series), series=validation_series, covariates=...) as the prediction time index will start where the input series finishes.

from darts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.