Comments (1)
I tried to strip out most of the abstraction and got the code below.
As long as we have a single optimizer, I'm not it make sense to factor out more in the AbstractOptimizer
class.
Will try to include in the code and run the test suite.
from flaml import AutoML
from datetime import datetime
from palma.utils.utils import get_hash
from palma import logger
import logging
from contextlib import contextmanager
@contextmanager
def disable_logging():
logging.disable()
yield
logging.basicConfig(level=logging.DEBUG)
class AbstractOptimizer:
def __init__(self, **parameters):
self.date = datetime.now()
self.run_id = get_hash(date=self.date)
self.parameters = parameters
class FlamlOptimizer(AbstractOptimizer):
def __init__(self, **parameters):
super().__init__(**parameters)
self.optimizer = AutoML(**parameters)
def find_best_model(self, project):
X = project.X.iloc[project.validation_strategy.train_index]
y = project.y.iloc[project.validation_strategy.train_index]
splitter = project.validation_strategy
split_type = None if splitter is None else splitter.splitter
groups = None if splitter is None else splitter.groups
groups = groups if groups is None else groups[splitter.train_index]
with disable_logging():
self.optimizer.fit(
X_train=pd.DataFrame(X.values, index=range(len(X))),
y_train=pd.Series(y.values, index=range(len(X))),
split_type=split_type, groups=groups,
mlflow_logging=False,
task=project.problem
)
best_model = self.optimizer.model.model
logger.logger.log_artifact(best_model, self.run_id)
return best_model
optim = FlamlOptimizer(time_budget=2)
model = optim.find_best_model(project)
from palma.
Related Issues (9)
- Install error : no module named "palma.base"
- To install palma, I had to pip install "flaml[automl]" HOT 1
- shap (library) no longer compatible with the current version of palma
- Add scoring for multi output classification
- Deepchecks should not be an optional requirement
- Use pytest.importorskip to run the test suite even without the optional dependencies
- More consistent naming
- Todo: remove AutoSklearnOptimizer
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 palma.