Comments (5)
Hi @michaelGK92 ,
Could you post your code? Then I will modify it accordingly.
Thanks,
Lars
from sherpa.
the code is from your wiki.I test it on my python.when I use it in windows, it does not work.
the random forest.py
`from sklearn.datasets import load_breast_cancer
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import cross_val_score
import time
import sherpa
import sherpa.algorithms.bayesian_optimization as bayesian_optimization
parameters = [sherpa.Discrete('n_estimators', [2, 50]),
sherpa.Choice('criterion', ['gini', 'entropy']),
sherpa.Continuous('max_features', [0.1, 0.9])]
algorithm = bayesian_optimization.GPyOpt(max_concurrent=1,
model_type='GP_MCMC',
acquisition_type='EI_MCMC',
max_num_trials=100)
X, y = load_breast_cancer(return_X_y=True)
study = sherpa.Study(parameters=parameters,
algorithm=algorithm,
lower_is_better=False)
for trial in study:
print("Trial ", trial.id, " with parameters ", trial.parameters)
clf = RandomForestClassifier(criterion=trial.parameters['criterion'],
max_features=trial.parameters['max_features'],
n_estimators=trial.parameters['n_estimators'],
random_state=0)
scores = cross_val_score(clf, X, y, cv=5)
print("Score: ", scores.mean())
study.add_observation(trial, iteration=1, objective=scores.mean())
study.finalize(trial)
print(study.get_best_result())
from sherpa.
Hi @michaelGK92 ,
Try this code (inside sherpa.Study
I added disable_dashboard=True
).
from sklearn.datasets import load_breast_cancer
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import cross_val_score
import time
import sherpa
import sherpa.algorithms.bayesian_optimization as bayesian_optimization
parameters = [sherpa.Discrete('n_estimators', [2, 50]),
sherpa.Choice('criterion', ['gini', 'entropy']),
sherpa.Continuous('max_features', [0.1, 0.9])]
algorithm = bayesian_optimization.GPyOpt(max_concurrent=1,
model_type='GP_MCMC',
acquisition_type='EI_MCMC',
max_num_trials=100)
X, y = load_breast_cancer(return_X_y=True)
study = sherpa.Study(parameters=parameters,
algorithm=algorithm,
disable_dashboard=True,
lower_is_better=False)
for trial in study:
print("Trial ", trial.id, " with parameters ", trial.parameters)
clf = RandomForestClassifier(criterion=trial.parameters['criterion'],
max_features=trial.parameters['max_features'],
n_estimators=trial.parameters['n_estimators'],
random_state=0)
scores = cross_val_score(clf, X, y, cv=5)
print("Score: ", scores.mean())
study.add_observation(trial, iteration=1, objective=scores.mean())
study.finalize(trial)
print(study.get_best_result())
study.save(".")
Then later you can do
import sherpa
sherpa.Study.load_dashboard(".")
from the same directory.
from sherpa.
from sherpa.
I installed ubuntu app on my windows, installed python and copied the file:
sudo cp -i /mnt/c/Users/.... /xyz.py
I run the code from ubuntu.
python3 xyz.py
my file includes:
import tempfile
model_dir = tempfile.mkdtemp()
...
study.save(model_dir)
print (model_dir)
opening the file e.g.:
import sherpa
sherpa.Study.load_dashboard("/tmp/tmpja_m1w61")
removing all tmp files:
cd /tmp
find . -type d -name 'tmp*' -exec rm -r {} ; -prune
from sherpa.
Related Issues (20)
- Show dashboard after run complete? HOT 1
- pandas >= 1.10 KeyError
- Parallel Sherpa MongoDB access issues HOT 2
- Old version of slickgrid causing dashboard column limit?
- Considering pruned trial information when sampling
- Resume optimization
- ValueError: `f0` passed has more than 1 dimension.
- Sherpa study can not find keras module
- Bayesian optimization with Random Forest HOT 1
- random_seed cannot actually be set when creating a new study HOT 1
- Can't pickle local object 'Flask.init..' HOT 3
- use development install instead of path export?
- trivial Baysian Optimization raises TypeError
- Incompatability with Pandas > 1.5.0
- Possible typo on guide website: HOT 1
- Using shlex to split runner_command HOT 1
- Only install enum34 for old versions of Python HOT 4
- Sherpa Dashboard Links Invalid HOT 1
- Problem with Dashboard HOT 4
- Error when using bayesian optimization HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sherpa.