QNNs for Stock Price Trend Prediction background cover

QNNs for Stock Price Trend Prediction

Develop quantum neural network models using PyTorch to predict stock price trends based on limit order book data.

Quantum Signals

Hosted by

Quantum Signals

Hasarindu Perera
hasarinduperera

2

Posted

Getting an error when running the dummy model

Hi there, I am getting below error when running the notebook.
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[4], line 2
      1 # Get predictions from the model
----> 2 predictions = model(torch.Tensor(input[0]))
      4 # Move predictions to CPU and convert to NumPy array
      5 predictions = predictions.cpu().numpy()

TypeError: 'method' object is not subscriptable
I believe maybe it is because the notebook uses input as a variable?
# Get predictions from the model
predictions = model(torch.Tensor(input[0]))

# Move predictions to CPU and convert to NumPy array
predictions = predictions.cpu().numpy()
Anyways I tried to change that part and run aqora test but got another error.
# Example input to test the model
sample_input = torch.rand((1, 10))  # Random input with 10 features

# Get predictions from the model
predictions = model(sample_input)

# Move predictions to CPU and convert to NumPy array
predictions = predictions.cpu().detach().numpy()

Order by:

Antoine Chauvin

2

Posted by antoine

Hi there, I am getting below error when running the notebook.
Are you running the notebook with aqora test as expected? Or do you run it using Visual Studio Code?
Anyways I tried to change that part and run aqora test but got another error.
Can you quote the full error trace in the topic please?

Hasarindu Perera

2

Posted by hasarinduperera

Are you running the notebook with aqora test as expected? Or do you run it using Visual Studio Code?
aqora test worked fine on terminal. But then I tried to follow the notebook (running cell by cell). That's when I got the error.
Can you quote the full error trace in the topic please?
Model output: [[1 1 2 1 2]]
Model output: [[1 1 2 1 2]]
[1 FAIL] Evaluation error
Model output: [[1 1 2 1 2]]
Traceback (most recent call last):
  File "/home/personal/Documents/Personal/Documents/aqora/quantum-signals-lob/.venv/lib/python3.10/site-packages/use_case/run.py", line 32, in score
    return compute_score(Tensor(solution), Tensor(original_input[1]))
  File "/home/personal/Documents/Personal/Documents/aqora/quantum-signals-lob/.venv/lib/python3.10/site-packages/use_case/metrics.py", line 54, in compute_score
    scores = [
  File "/home/personal/Documents/Personal/Documents/aqora/quantum-signals-lob/.venv/lib/python3.10/site-packages/use_case/metrics.py", line 55, in <listcomp>
    compute_metrics(truth[:, h], prediction[:, h])[cst.Metrics.F1.value]
  File "/home/personal/Documents/Personal/Documents/aqora/quantum-signals-lob/.venv/lib/python3.10/site-packages/use_case/metrics.py", line 19, in compute_metrics
    cr = classification_report(truth, prediction, output_dict=True, zero_division=0)
  File "/home/personal/Documents/Personal/Documents/aqora/quantum-signals-lob/.venv/lib/python3.10/site-packages/sklearn/utils/_param_validation.py", line 213, in wrapper
    return func(*args, **kwargs)
  File "/home/personal/Documents/Personal/Documents/aqora/quantum-signals-lob/.venv/lib/python3.10/site-packages/sklearn/metrics/_classification.py", line 2626, in classification_report
    y_type, y_true, y_pred = _check_targets(y_true, y_pred)
  File "/home/personal/Documents/Personal/Documents/aqora/quantum-signals-lob/.venv/lib/python3.10/site-packages/sklearn/metrics/_classification.py", line 103, in _check_targets
    check_consistent_length(y_true, y_pred)
  File "/home/personal/Documents/Personal/Documents/aqora/quantum-signals-lob/.venv/lib/python3.10/site-packages/sklearn/utils/validation.py", line 457, in check_consistent_length
    raise ValueError(
ValueError: Found input variables with inconsistent numbers of samples: [1, 32]
[2 FAIL] Evaluation error
  Failed to run pipeline                                                                                                            ERROR Oh no! Failed to run pipeline

To try and fix this, you can:
 - Check the above error and try again

Hasarindu Perera

2

Posted by hasarinduperera

PS: after the code change, notebook worked fine, I am getting above error, when running aqora test.
To clarify, in initial stage, aqora test worked, but notebook did not, now after my code change, notebook does work, aqora test is not.
Maybe I am doing something wrong or foolish, please forgive me if that's the case.

Antoine Chauvin

2

Posted by antoine

We do not currently support running submission notebooks directly from Visual Studio Code. Please run your submission using aqora test for now. We are currently working on integrating aqora test with python notebook runners, but for now you will have to use aqora test.
ValueError: Found input variables with inconsistent numbers of samples: [1, 32]
This error is thrown by sklearn as part of their function check_consistent_length. Have you tried to return different output in your notebook?

Hasarindu Perera

2

Posted by hasarinduperera

Please run your submission using aqora test for now.
Got it, thanks! So basically what I have to do is, experiment with the model and run aqora test right?

Antoine Chauvin

2

Posted by antoine

Yes exactly 😉 I also highly recommend you subscribe to our newsletter in order to follow our latest development on the platform!

Hasarindu Perera

1

Posted by hasarinduperera

Sure, I will. Thanks!

Jannes Stubbemann

1

Posted by stubbi

@hasarinduperera thanks for posting!
@antoine can I ask you to take a look at this one? 🙏

Want to join this discussion?

Join our community today and start discussing with our members by participating in exciting events, competitions, and challenges. Sign up now to engage with quantum experts!