未验证 提交 47f73fbe 编写于 作者: P pycaret 提交者: GitHub

Add files via upload

上级 3a56f53d
......@@ -174,6 +174,9 @@ def setup(data,
X = data.drop(target,axis=1)
y = data[target]
#copy original data for pandas profiler
data_before_preprocess = data.copy()
#determining target type
if y.value_counts().count() > 2:
target_type = 'Multiclass'
......@@ -345,7 +348,11 @@ def setup(data,
'''
clear_output()
print(' ')
print('Setup Succesfully Completed!')
if profile:
print('Setup Succesfully Completed! Loading Profile Now... Please Wait!')
else:
print('Setup Succesfully Completed!')
functions = pd.DataFrame ( [ ['session_id', seed ],
['Target Type', target_type],
['Original Data',X.shape ],
......@@ -358,6 +365,15 @@ def setup(data,
functions_ = functions.style.hide_index()
display(functions_)
if profile:
try:
import pandas_profiling
pf = pandas_profiling.ProfileReport(data_before_preprocess)
clear_output()
display(pf)
except:
print('Data Profiler Failed. No output to show, please continue with Modeling.')
'''
Final display Ends
'''
......@@ -389,7 +405,11 @@ def setup(data,
clear_output()
print(' ')
print('Setup Succesfully Completed!')
if profile:
print('Setup Succesfully Completed! Loading Profile Now... Please Wait!')
else:
print('Setup Succesfully Completed!')
functions = pd.DataFrame ( [ ['session_id', seed ],
['Target Type', target_type],
['Original Data',X.shape ],
......@@ -402,6 +422,15 @@ def setup(data,
functions_ = functions.style.hide_index()
display(functions_)
if profile:
try:
import pandas_profiling
pf = pandas_profiling.ProfileReport(data_before_preprocess)
clear_output()
display(pf)
except:
print('Data Profiler Failed. No output to show, please continue with Modeling.')
'''
Final display Ends
'''
......@@ -446,10 +475,13 @@ def setup(data,
display(functions_)
if profile:
import pandas_profiling
pf = pandas_profiling.ProfileReport(data)
clear_output()
display(pf)
try:
import pandas_profiling
pf = pandas_profiling.ProfileReport(data_before_preprocess)
clear_output()
display(pf)
except:
print('Data Profiler Failed. No output to show, please continue with Modeling.')
'''
Final display Ends
......@@ -3481,6 +3513,7 @@ def tune_model(estimator = None,
return best_model
def blend_models(estimator_list = 'All',
fold = 10,
round = 4,
......@@ -3591,6 +3624,21 @@ def blend_models(estimator_list = 'All',
if 'sklearn' not in str(type(i)) and 'CatBoostClassifier' not in str(type(i)):
sys.exit("(Value Error): estimator_list parameter only accepts 'All' as string or trained model object")
#checking method param with estimator list
if estimator_list != 'All':
if method == 'soft':
check = 0
for i in estimator_list:
if hasattr(i, 'predict_proba'):
pass
else:
check += 1
if check >= 1:
sys.exit('(Type Error): Estimator list contains estimator that doesnt support probabilities and method is forced to soft. Either change the method or drop the estimator.')
#checking fold parameter
if type(fold) is not int:
sys.exit('(Type Error): Fold parameter only accepts integer value.')
......@@ -3743,12 +3791,20 @@ def blend_models(estimator_list = 'All',
progress.value += 1
if turbo:
estimator_list = [lr,knn,nb,dt,svm,ridge,rf,qda,ada,gbc,lda,et,xgboost,lightgbm]
voting = 'hard'
if method == 'hard':
estimator_list = [lr,knn,nb,dt,svm,ridge,rf,qda,ada,gbc,lda,et,xgboost,lightgbm]
voting = 'hard'
elif method == 'soft':
estimator_list = [lr,knn,nb,dt,rf,qda,ada,gbc,lda,et,xgboost,lightgbm]
voting = 'soft'
else:
estimator_list = [lr,knn,nb,dt,svm,rbfsvm,gpc,mlp,ridge,rf,qda,ada,gbc,lda,et,xgboost,lightgbm]
voting = 'hard'
if method == 'hard':
estimator_list = [lr,knn,nb,dt,svm,rbfsvm,gpc,mlp,ridge,rf,qda,ada,gbc,lda,et,xgboost,lightgbm]
voting = 'hard'
elif method == 'soft':
estimator_list = [lr,knn,nb,dt,rbfsvm,gpc,mlp,rf,qda,ada,gbc,lda,et,xgboost,lightgbm]
voting = 'soft'
else:
estimator_list = estimator_list
......
......@@ -387,17 +387,12 @@ def create_model(model = None,
elif model == 'kmodes':
from kmodes.kmodes import KModes
model = KModes(n_clusters=num_clusters, n_jobs=-1, random_state=seed)
model = KModes(n_clusters=num_clusters, n_jobs=1, random_state=seed)
full_name = 'K-Modes Clustering'
elif model == 'kprototypes':
from kmodes.kprototypes import KPrototypes
model = KPrototypes(n_clusters=num_clusters, n_jobs=-1, random_state=seed)
full_name = 'K-Prototypes Clustering'
elif model == 'skmeans':
from spherecluster import SphericalKMeans
model = SphericalKMeans(n_clusters=num_clusters, n_jobs=-1, random_state=seed)
model = SphericalKMeans(n_clusters=num_clusters, n_jobs=1, random_state=seed)
full_name = 'Spherical K-Means Clustering'
#monitor update
......
......@@ -163,6 +163,9 @@ def setup(data,
X = data.drop(target,axis=1)
y = data[target]
#copy original data for pandas profiler
data_before_preprocess = data.copy()
progress.value += 1
if sampling is True and data.shape[0] > 25000: #change back to 25000
......@@ -271,7 +274,12 @@ def setup(data,
'''
clear_output()
print(' ')
print('Setup Succesfully Completed!')
if profile:
print('Setup Succesfully Completed! Loading Profile Now... Please Wait!')
else:
print('Setup Succesfully Completed!')
functions = pd.DataFrame ( [ ['session_id', seed ],
['Original Data',X.shape ],
['Sampled Data',X.shape ],
......@@ -283,6 +291,15 @@ def setup(data,
functions_ = functions.style.hide_index()
display(functions_)
if profile:
try:
import pandas_profiling
pf = pandas_profiling.ProfileReport(data_before_preprocess)
clear_output()
display(pf)
except:
print('Data Profiler Failed. No output to show, please continue with Modeling.')
'''
Final display Ends
'''
......@@ -313,7 +330,12 @@ def setup(data,
clear_output()
print(' ')
print('Setup Succesfully Completed!')
if profile:
print('Setup Succesfully Completed! Loading Profile Now... Please Wait!')
else:
print('Setup Succesfully Completed!')
functions = pd.DataFrame ( [ ['session_id', seed ],
['Original Data',X.shape ],
['Sampled Data',X_selected.shape ],
......@@ -325,6 +347,15 @@ def setup(data,
functions_ = functions.style.hide_index()
display(functions_)
if profile:
try:
import pandas_profiling
pf = pandas_profiling.ProfileReport(data_before_preprocess)
clear_output()
display(pf)
except:
print('Data Profiler Failed. No output to show, please continue with Modeling.')
'''
Final display Ends
'''
......@@ -368,10 +399,13 @@ def setup(data,
display(functions_)
if profile:
import pandas_profiling
pf = pandas_profiling.ProfileReport(data)
clear_output()
display(pf)
try:
import pandas_profiling
pf = pandas_profiling.ProfileReport(data_before_preprocess)
clear_output()
display(pf)
except:
print('Data Profiler Failed. No output to show, please continue with Modeling.')
'''
Final display Ends
......@@ -386,6 +420,8 @@ def setup(data,
return X, y, X_train, X_test, y_train, y_test, seed, experiment__
def create_model(estimator = None,
ensemble = False,
method = None,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册