AI4Finance-Foundation / FinRL

FinRL: Financial Reinforcement Learning. 🔥
https://ai4finance.org
MIT License
9.37k stars 2.28k forks source link

Error #1191

Open wahidur0547 opened 3 months ago

wahidur0547 commented 3 months ago

WhatsApp Image 2024-03-28 at 18 31 22

I am getting AttributeError: 'Series' object has no attribute 'iteritems' i tried but not able to fix it, can someone help me with this error??

zhumingpassional commented 3 months ago

the plot function should be revised. now that the result has been obtained, plotting fig is easy.

VishnuRaghavan commented 1 month ago

""" Script for comparing results with DJIA.

This script reads data from df_result_ensemble and df_dji, merges them, and visualizes the comparison. """

import necessary packages

import pandas as pd import os import matplotlib.pyplot as plt from finrl.config import DATA_SAVE_DIR

Load df_result_ensemble data from the CSV file

df_result_ensemble = pd.read_csv( os.path.join(DATA_SAVE_DIR, "df_result_ensemble.csv"), index_col="date" )

load df_dji data from csv

df_dji = pd.read_csv(os.path.join(DATA_SAVE_DIR, "df_dji.csv"), index_col="date")

Merge DataFrames on index

result = pd.merge(df_result_ensemble, df_dji, left_index=True, right_index=True)

Save to CSV

result.to_csv(os.path.join(DATA_SAVE_DIR, "result.csv"))

Rename columns for clarity

result.columns = ["ensemble", "djia"]

Plotting the result

Set the backend to a suitable interactive backend

plt.switch_backend("TkAgg") # Use 'TkAgg' backend for Tkinter-based interactive display plt.rcParams["figure.figsize"] = (15, 5) plt.figure() result.plot() plt.title("Ensemble and DJIA Comparison") plt.xlabel("Date") plt.ylabel("Values")

Display the plot interactively

plt.show()

zhumingpassional commented 1 month ago

@VishnuRaghavan can your code successfully plot the figure? if yes, pls submit a PR

VishnuRaghavan commented 1 month ago

@zhumingpassional I'm running on my local machine I have split the colab file into multiple files the above code is for comparison with DJIA. Also I'm training it on my CUDA NVIDIA GPU. Making a PR would not be the best solution as the file architectures are now different.

And yes for me plotting is working fine with this setup.