Code Monkey home page Code Monkey logo

Comments (4)

petroniocandido avatar petroniocandido commented on May 23, 2024

Hi, thanks to get in touch!

To answer your questions I need to know which partitioner, how many partitions, which model with which model's parameters did you used on this experiment.

Can you share the code & data for reproduction?

from pyfts.

RobinloveCode avatar RobinloveCode commented on May 23, 2024

Thank you for your response.

I use the grid partitioner. the codes are shown below:

from pyFTS.partitioners import Grid, Util as pUtil

fig, ax = plt.subplots(nrows=2, ncols=3, figsize=[20,5])

partitioners = {}
partitioners_diff = {}

for count,dataset_name in enumerate(dataset_names):
dataset = get_dataset(dataset_name)

partitioner = Grid.GridPartitioner(data=dataset, npart=30)
partitioners[dataset_name] = partitioner
partitioner_diff = Grid.GridPartitioner(data=dataset, npart=30, transformation=tdiff)
partitioners_diff[dataset_name] = partitioner_diff

pUtil.plot_sets(dataset, [partitioner.sets], titles=[dataset_name], axis=ax[0][count])
pUtil.plot_sets(dataset, [partitioner_diff.sets], titles=[''], axis=ax[1][count])

Then I train the model with original data(TAIEX)
from pyFTS.models import yu
for count,dataset_name in enumerate(dataset_names):
dataset = get_dataset(dataset_name)

model1 = chen.ConventionalFTS(partitioner=partitioners[dataset_name])
model1.name=dataset_name
model1.fit(dataset[:train_split], save_model=True, file_path='model1'+dataset_name, order=1)

After that, I want to make multi-steps ahead prediction by making one-step prediction first, then use the previous prediction to make the next-step prediction. The prediction codes are shown below:
fig, ax = plt.subplots(nrows=3, ncols=1, figsize=[20,10])

forecasts = []

for count,dataset_name in enumerate(dataset_names):
dataset = get_dataset(dataset_name)

ax[count].plot(dataset[train_split:train_split+200])

model1 = cUtil.load_obj('model1'+dataset_name)

prev_forecasts = dataset[train_split-1:train_split]

for n in range(200):
     
    new_forecast = model1.predict(prev_forecasts[n:n+1])
    
    prev_forecasts = np.append(prev_forecasts,new_forecast)

#forecasts = model1.predict(dataset[train_split:train_split+1])
forecasts = prev_forecasts

ax[count].plot(forecasts)

ax[count].set_title(dataset_name)

plt.tight_layout()

The results are not good.
image

So in this library, the one-step prediction is based on the true data of previous day, even in the test process? Am I right?

Looking forward to your reply!

from pyfts.

RobinloveCode avatar RobinloveCode commented on May 23, 2024

Hi, thanks to get in touch!

To answer your questions I need to know which partitioner, how many partitions, which model with which model's parameters did you used on this experiment.

Can you share the code & data for reproduction?

Thank you for your response.

I use the grid partitioner. the codes are shown below:

from pyFTS.partitioners import Grid, Util as pUtil

fig, ax = plt.subplots(nrows=2, ncols=3, figsize=[20,5])

partitioners = {}
partitioners_diff = {}

for count,dataset_name in enumerate(dataset_names):
dataset = get_dataset(dataset_name)

partitioner = Grid.GridPartitioner(data=dataset, npart=30)
partitioners[dataset_name] = partitioner
partitioner_diff = Grid.GridPartitioner(data=dataset, npart=30, transformation=tdiff)
partitioners_diff[dataset_name] = partitioner_diff

pUtil.plot_sets(dataset, [partitioner.sets], titles=[dataset_name], axis=ax[0][count])
pUtil.plot_sets(dataset, [partitioner_diff.sets], titles=[''], axis=ax[1][count])
Then I train the model with original data(TAIEX)
from pyFTS.models import yu
for count,dataset_name in enumerate(dataset_names):
dataset = get_dataset(dataset_name)

model1 = chen.ConventionalFTS(partitioner=partitioners[dataset_name])
model1.name=dataset_name
model1.fit(dataset[:train_split], save_model=True, file_path='model1'+dataset_name, order=1)
After that, I want to make multi-steps ahead prediction by making one-step prediction first, then use the previous prediction to make the next-step prediction. The prediction codes are shown below:
fig, ax = plt.subplots(nrows=3, ncols=1, figsize=[20,10])

forecasts = []

for count,dataset_name in enumerate(dataset_names):
dataset = get_dataset(dataset_name)

ax[count].plot(dataset[train_split:train_split+200])

model1 = cUtil.load_obj('model1'+dataset_name)

prev_forecasts = dataset[train_split-1:train_split]

for n in range(200):

new_forecast = model1.predict(prev_forecasts[n:n+1])

prev_forecasts = np.append(prev_forecasts,new_forecast)

#forecasts = model1.predict(dataset[train_split:train_split+1])
forecasts = prev_forecasts

ax[count].plot(forecasts)

ax[count].set_title(dataset_name)
plt.tight_layout()

The results are not good.
image

So in this library, the one-step prediction is based on the true data of previous day, even in the test process? Am I right?

Looking forward to your reply!

from pyfts.

petroniocandido avatar petroniocandido commented on May 23, 2024

Some tips:

from pyfts.

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.