Skip to content

Commit

Permalink
Merge pull request #146 from Thilakraj1998/main
Browse files Browse the repository at this point in the history
Minor fix
  • Loading branch information
Thilakraj1998 authored Oct 18, 2021
2 parents 343be68 + 6e792eb commit c594f25
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion blobcity/config/classifier_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ class classifier_config:
'learning_rate': {'float':[1e-3,0.1]},
'reg_alpha': {'int':[1, 1.5]},
'reg_lambda': {'int':[1, 1.5]},
'booster':{'str':['gbtree', 'gblinear','dart']}
'booster':{'str':['gbtree', 'gblinear','dart']},
'verbosity':{'str':[0]}
}
],
"RadiusNeighborsClassifier":[
Expand Down
5 changes: 3 additions & 2 deletions blobcity/main/modelSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import warnings
import itertools
from tqdm import tqdm,tqdm_notebook
from blobcity.store import Model
from blobcity.config import tuner as Tuner
from blobcity.config import classifier_config,regressor_config
Expand Down Expand Up @@ -83,7 +84,7 @@ def trainOnSample(dataframe,target,models,DictClass):
df=dataframe.sample(frac=0.1,random_state=123)
X,Y=df.drop(target,axis=1),df[target]
k=getKFold(X)
modelScore={m:cvScore(models[m][0](),X,Y,k) for m in models }
modelScore={m:cvScore(models[m][0](),X,Y,k) for m in tqdm_notebook(models) }
return dict(itertools.islice(sortScore(modelScore).items(), 5))

def trainOnFull(dataframe,target,models,best,DictClass):
Expand All @@ -99,7 +100,7 @@ def trainOnFull(dataframe,target,models,best,DictClass):
"""
X,Y=dataframe.drop(target,axis=1),dataframe[target]
k=getKFold(X)
modelScore={m:cvScore(models[m][0](),X,Y,k) for m in best }
modelScore={m:cvScore(models[m][0](),X,Y,k) for m in tqdm_notebook(best) }
return dict(itertools.islice(sortScore(modelScore).items(), 1))

def modelSearch(dataframe,target,DictClass):
Expand Down
11 changes: 6 additions & 5 deletions blobcity/utils/AutoFeatureSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ def dropHighCorrelationFeatures(X):
cor_matrix = X.corr()
upper_tri = cor_matrix.where(np.triu(np.ones(cor_matrix.shape),k=1).astype(np.bool))
to_drop = [column for column in upper_tri.columns if any(upper_tri[column] > 0.95)]
X = X.drop(to_drop, axis=1)
return X
if to_drop!=[]:
return X.drop(to_drop, axis=1)
else:
return X

def dropConstantFeatures(X):
"""
Expand All @@ -52,8 +54,7 @@ def dropConstantFeatures(X):
cols=X.columns
constant_filter = VarianceThreshold(threshold=0).fit(X)
constcols=[col for col in cols if col not in cols[constant_filter.get_support()]]
if(constcols!=[]):
X.drop(constcols,axis=1,inplace=True)
if(constcols!=[]): X.drop(constcols,axis=1,inplace=True)
return X

def MainScore(resultscore,dc):
Expand Down Expand Up @@ -99,7 +100,7 @@ def get_feature_importance(X,Y,score_func,dc):
if the dataframe has less then equal to 2 features return orignal dataframe. else return a short listed dataframe on the basis of
categorical features.
"""
if(X.shape[1]<=3):
if(X.shape[1]<3):
return X
else:
fit = SelectKBest(score_func=score_func, k=X.shape[1]).fit(X,Y)
Expand Down

0 comments on commit c594f25

Please sign in to comment.