oracle / accelerated-data-science

ADS is the Oracle Data Science Cloud Service's python SDK supporting, model ops (train/eval/deploy), along with running workloads on Jobs and Pipeline resources.
https://accelerated-data-science.readthedocs.io/
Universal Permissive License v1.0
87 stars 43 forks source link

[Bug]: ADSTunner example is broken (due to dependencies) #957

Open Zhuoli opened 1 week ago

Zhuoli commented 1 week ago

Oracle-ads version used

Description

The example of ADSTuner is broken [here] I ran in multiple issues complaining dependenct methods no longer available even after downgrading sklearn matplot.

Python 3.10.12

How to Reproduce

#https://accelerated-data-science.readthedocs.io/en/latest/user_guide/model_training/ads_tuner.html
! pip install category_encoders 
! pip install lightgbm
! pip install pytest
! pip install scikit-learn==1.1.3
! pip install xgboost
! python3 -m pip install "oracle-ads[opctl]"
! pip install matplotlib==3.6.2

import category_encoders as ce
import lightgbm
import logging
import numpy as np
import os
import pandas as pd
import pytest
import sklearn
import xgboost

from ads.hpo.stopping_criterion import *
from ads.hpo.distributions import *
from ads.hpo.search_cv import ADSTuner

from lightgbm import LGBMClassifier
from sklearn import preprocessing
from sklearn.compose import ColumnTransformer
from sklearn.datasets import load_iris, load_boston
from sklearn.decomposition import PCA
from sklearn.ensemble import AdaBoostRegressor, AdaBoostClassifier
from sklearn.impute import SimpleImputer
from sklearn.linear_model import SGDClassifier, LogisticRegression
from sklearn.metrics import make_scorer, f1_score
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.feature_selection import SelectKBest, f_classif
from xgboost import XGBClassifier
! python -m pip show matplotlib
! python3 -m pip install "oracle-ads[optuna]"
model = SGDClassifier() ##Initialize the model
X, y = load_iris(return_X_y=True)
X_train, X_valid, y_train, y_valid = train_test_split(X, y)
tuner = ADSTuner(model, cv=3) ## cv is cross validation splits
tuner.search_space() ##This is the default search space
tuner.tune(X_train, y_train, exit_criterion=[NTrials(10)])

What was Observed

ERROR - Exception Traceback (most recent call last): File "/home/zhuoli/Projects/github/zhuoli/automlx/.env/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3577, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "/tmp/ipykernel_3001602/1993493913.py", line 4, in tuner = ADSTuner(model, cv=3) ## cv is cross validation splits File "/home/zhuoli/Projects/github/zhuoli/automlx/.env/lib/python3.10/site-packages/ads/common/decorator/runtime_dependency.py", line 174, in wrapper return func(*args, **kwargs) File "/home/zhuoli/Projects/github/zhuoli/automlx/.env/lib/python3.10/site-packages/ads/hpo/search_cv.py", line 382, in init self._study = optuna.study.create_study( File "/home/zhuoli/Projects/github/zhuoli/automlx/.env/lib/python3.10/site-packages/optuna/study/study.py", line 1136, in create_study storage = storages.get_storage(storage) File "/home/zhuoli/Projects/github/zhuoli/automlx/.env/lib/python3.10/site-packages/optuna/storages/init.py", line 31, in get_storage return _CachedStorage(RDBStorage(storage)) File "/home/zhuoli/Projects/github/zhuoli/automlx/.env/lib/python3.10/site-packages/optuna/storages/_rdb/storage.py", line 187, in init self._version_manager.check_table_schema_compatibility() File "/home/zhuoli/Projects/github/zhuoli/automlx/.env/lib/python3.10/site-packages/optuna/storages/_rdb/storage.py", line 1310, in check_table_schema_compatibility current_version = self.get_current_version() File "/home/zhuoli/Projects/github/zhuoli/automlx/.env/lib/python3.10/site-packages/optuna/storages/_rdb/storage.py", line 1337, in get_current_version assert version is not None AssertionError AssertionError:

What was Expected

No error expected

Version

2.11.19

qiuosier commented 1 week ago

There is breaking change on SQLAlchemy causing the issue. The workaround is to install order version:

pip install "SQLAlchemy<2"
Zhuoli commented 1 week ago

There is breaking change on SQLAlchemy causing the issue. The workaround is to install order version:

pip install "SQLAlchemy<2"

Good now, thanks for your quick reply!