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

Question: module 'regreg.api' has no attribute 'quadratic' #51

Open
ChingzhiWU opened this issue Dec 17, 2019 · 2 comments
Open

Question: module 'regreg.api' has no attribute 'quadratic' #51

ChingzhiWU opened this issue Dec 17, 2019 · 2 comments

Comments

@ChingzhiWU
Copy link

Dear, My environment:

windows 10
Python 3.67
Anaconda3
scipy 1.3.3
regreg 0.1.3 pypi_0 pypi

and after I run this line
loss = rr.quadratic.shift(-Ic,coef=0.5)

the error messages are:

AttributeError Traceback (most recent call last)
in
----> 1 loss = rr.quadratic.shift(-Ic,coef=0.5)

AttributeError: module 'regreg.api' has no attribute 'quadratic'

How to solve this problem? Many thanks!

@jonathan-taylor
Copy link
Contributor

jonathan-taylor commented Jan 2, 2020 via email

@ChingzhiWU
Copy link
Author

ChingzhiWU commented Jan 4, 2020

Dear Prof. Jonathan Taylor, Many Thanks.

Actually, I want to try to run this website example.

http://statweb.stanford.edu/~bjk/regreg/examples/fusedlassoapprox.html#fusedlassoapprox

Code:
import numpy as np
import pylab
from scipy import sparse

import regreg.api as R

Y = np.random.standard_normal(500); Y[100:150] += 7; Y[250:300] += 14

sparsity = R.l1norm(500, lagrange=1.3)
#Create D
D = (np.identity(500) + np.diag([-1]*499,k=1))[:-1]
D = sparse.csr_matrix(D)
fused = R.l1norm.linear(D, lagrange=25.5)

loss = R.quadratic.shift(-Y)

problem = R.container(loss, sparsity, fused)
solver = R.FISTA(problem)
solver.fit(max_its=800,tol=1e-10)
soln = solver.composite.coefs

#plot solution
pylab.figure(num=1)
pylab.clf()
pylab.plot(soln, c='g')
pylab.scatter(np.arange(Y.shape[0]), Y)

the error messages are:

AttributeError Traceback (most recent call last)
in
14
15
---> 16 loss = R.quadratic.shift(-Y)
17
18

AttributeError: module 'regreg.api' has no attribute 'quadratic'

How to solve this problem? Many thanks!

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

2 participants