Skip to content

Commit

Permalink
Minor Enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
Thilakraj1998 committed Oct 18, 2021
1 parent 17380a7 commit 2319fdd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
18 changes: 11 additions & 7 deletions blobcity/config/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import optuna
import warnings
from blobcity.main import modelSelection
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
from sklearn.metrics import r2_score,mean_squared_error,mean_absolute_error
from sklearn.metrics import f1_score,precision_score,recall_score
from sklearn.exceptions import ConvergenceWarning
from sklearn.model_selection import train_test_split,cross_val_score
from sklearn.metrics import r2_score,mean_squared_error,mean_absolute_error,f1_score,precision_score,recall_score
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=ConvergenceWarning)
warnings.filterwarnings("ignore", category=DeprecationWarning)
os.environ["PYTHONWARNINGS"] = "ignore"
optuna.logging.set_verbosity(optuna.logging.WARNING)
"""
Python files consist of function to perform parameter tuning using optuna framework
Expand Down Expand Up @@ -142,9 +146,9 @@ def tuneModel(dataframe,target,modelkey,modelList,ptype):
getParamList(modelkey,modelList)
try:
study = optuna.create_study(direction="maximize")
study.optimize(objective, n_trials=5,n_jobs=-1)
study.optimize(objective,n_trials=10,n_jobs=-1)
metric_result=metricResults(modelName(**study.best_params),X,Y,ptype)
model = modelName(**study.best_params).fit(X,Y)
return (model,study.best_params,study.best_value,metric_result)
except Exception as e:
raise TypeError(f"{e}")
print(e)
14 changes: 11 additions & 3 deletions blobcity/main/modelSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.


import os
import warnings
import itertools
from blobcity.store import Model
from blobcity.config import tuner as Tuner
from blobcity.config import classifier_config,regressor_config
from sklearn.exceptions import ConvergenceWarning
from sklearn.model_selection import cross_val_score
from blobcity.config import tuner as Tuner
from blobcity.store import Model
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=ConvergenceWarning)
warnings.filterwarnings("ignore", category=DeprecationWarning)
os.environ["PYTHONWARNINGS"] = "ignore"

"""
This python file consists of function to get best performing model for a given dataset.
"""

def getKFold(X):

"""
Expand Down

0 comments on commit 2319fdd

Please sign in to comment.