Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error message when running the code. #63

Open
peter308 opened this issue Nov 6, 2021 · 3 comments
Open

error message when running the code. #63

peter308 opened this issue Nov 6, 2021 · 3 comments

Comments

@peter308
Copy link

peter308 commented Nov 6, 2021

Dear developer

When I try to run your code, it shows the below error message:

TypeError Traceback (most recent call last)
in ()
30 # fit the model to the data and get back the params
31
---> 32 tc, m, w, a, b, c, c1, c2, O, D = lppls_model.fit(MAX_SEARCHES)
33
34 # visualize the fit

TypeError: fit() missing 1 required positional argument: 'max_searches'

Can you help to solve it? Tks!

with regards,
Peter

@Joshwani
Copy link
Contributor

Joshwani commented Nov 6, 2021

Hi @peter308, are you able to provide your code? Thanks!

@peter308
Copy link
Author

peter308 commented Nov 9, 2021

Dear Joshwani

I am just using your Juypter code in the example section

"
from lppls import lppls, data_loader
import numpy as np
import pandas as pd
from datetime import datetime as dt
%matplotlib inline

read example dataset into df
data = data_loader.nasdaq_dotcom()

convert time to ordinal
time = [pd.Timestamp.toordinal(dt.strptime(t1, '%Y-%m-%d')) for t1 in data['Date']]

create list of observation data
price = np.log(data['Adj Close'].values)

create observations array (expected format for LPPLS observations)
observations = np.array([time, price])

set the max number for searches to perform before giving-up
the literature suggests 25
MAX_SEARCHES = 25

instantiate a new LPPLS model with the Nasdaq Dot-com bubble dataset
lppls_model = lppls.LPPLS(observations=observations)

fit the model to the data and get back the params
tc, m, w, a, b, c, c1, c2, O, D = lppls_model.fit(MAX_SEARCHES)

visualize the fit
lppls_model.plot_fit()
"

with kind regards,
Peter

@DariusTaheri
Copy link

This error gets raised when you do not instantiate an object of a class before calling a class method. Try running the cell with:

MAX_SEARCHES = 25

before

tc, m, w, a, b, c, c1, c2, O, D = lppls_model.fit(MAX_SEARCHES)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants