Open chorusg opened 7 months ago
Hi @chorusg, yes it is. Unless there was some bug you were seeing to prevent you from using it?
Do you have any simple code example to use this plugin?
On Mon, Apr 15, 2024, 21:24 Alexander Condello @.***> wrote:
Hi @chorusg https://github.com/chorusg, yes it is. Unless there was some bug you were seeing to prevent you from using it?
— Reply to this email directly, view it on GitHub https://github.com/dwavesystems/dwave-scikit-learn-plugin/issues/20#issuecomment-2056987819, or unsubscribe https://github.com/notifications/unsubscribe-auth/AS2T3K243JWIPPFK754DYIDY5PPIRAVCNFSM6AAAAABGHAIV2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJWHE4DOOBRHE . You are receiving this because you were mentioned.Message ID: @.***>
There are a few examples in the README. If you would like additional help, I would recommend creating a post in our community.
It didnt work when I copied the source code in Readme and run in cloud codespace. Any change needs to be made?
Can you be more specific? Specifically can you provide a minimal, reproducible example , as well as the full traceback that your are seeing?
Usage: dwave [OPTIONS] COMMAND [ARGS]... Try 'dwave --help' for help.
What is wrong with the process?
I see, in this case you are installing the package twice. The first with pip install dwave-scikit-learn-plugin
and the second with requirements.txt
/setup.py
. The second is a source install it pulls in an older dwave-cloud-client
version that does not have the auth
feature.
Try running just
pip install dwave-scikit-learn-plugin --upgrade
dwave auth login --oob
After running 2 of them, this issue appears: bash: dwave: command not found
It looks like somehow dwave-cloud-client
got uninstalled. Can you try
pip install dwave-scikit-learn-plugin --upgrade --force
which will install everything from scratch. Also, if there is an error can you please post the entire install output as well as the entire error traceback?
from sklearn.datasets import load_breast_cancer from dwave.plugins.sklearn import SelectFromQuadraticModel
X, y = load_breast_cancer(return_X_y=True)
X_new = SelectFromQuadraticModel(num_features=20).fit_transform(X, y)
Then run: python rtest.py
Traceback (most recent call last):
File "/workspaces/dwave-scikit-learn-plugin/rtest.py", line 6, in
You need access to the D-Wave quantum computers and hybrid solvers. You can get access by running
dwave auth login --oob
I believe with the fresh install that should work now.
It was authorised but still show the above error.
What is the output of dwave ping
?
We had got : Authorization completed successfully. You can now use "dwave auth get" to fetch your token.
then "dwave ping" returned: Error: Invalid configuration: API token not defined (code: 1)
As the message states you need to run dwave auth get
to get an authorization token which will give you access to the
solver.
Or you can do this in one step with dwave auth login --oob && dwave config create --auto-token
.
Traceback (most recent call last):
File "/workspaces/dwave-scikit-learn-plugin/rtest.py", line 1, in
scikit-learn
is installed as part of the pip install dwave-scikit-learn-plugin
install process. It seems like there may be some issues with your install path or your environment, but I think they are unrelated to this package. For general help on installing and using Python packages I would encourage you to checkout Installing packages as well as stackoverflow and other resources.
@chorusg, this seems to be a bug in the default image used by Codespaces.
On codespace creation, they will pip install requirements.txt
if present in the repo. However, python user-base seems to be off during this install (ran via Oryx), so our dwave
executable console script ends up in a directory that's not in PATH
.
If you uninstall it, and install again, from the initialized codespace, dwave
is installed in the proper/accessible bin directory.
So, to fix this, run:
pip uninstall -y dwave-cloud-client && pip install dwave-cloud-client
Please note that this issue is not specific to this repo, or Ocean SDK. Any python package installed from the requirements.txt
during codespace init is affected in the same way.
import numpy as np
from sklearn.datasets import load_breast_cancer from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import GridSearchCV from sklearn.pipeline import Pipeline from dwave.plugins.sklearn import SelectFromQuadraticModel
X, y = load_breast_cancer(return_X_y=True)
num_features = X.shape[1] searchspace = np.linspace(1, num_features, num=5, dtype=int, endpoint=True)
pipe = Pipeline([ ('feature_selection', SelectFromQuadraticModel()), ('classification', RandomForestClassifier()) ])
clf = GridSearchCV(pipe, param_grid=dict(feature_selection__num_features=searchspace)) search = clf.fit(X, y) print(search.bestparams)
Questions:
Hi @chorusg,
For your remaining questions, I'll direct you to our Ocean docs, our system docs, and our community.
GitHub issues are used for feature requests and bug reports. For more general questions about how to use our packages as well as our hybrid solvers and quantum computers, our community is a far better place.
Is this plugin up to date? Can we use it?