def set_class_func(CLASS, FUNC):
try:
funclist = [i for i in dir(FUNC) if callable(getattr(FUNC,i)) and not i.startswith('_') ]
for func in funclist:
setattr(CLASS,str(func),classmethod(func))
except Exception as e:
import sys
print("Error When Create Class Method From {} TO {}".format(CLASS,FUNC))
sys.exit(1)
import os
print(os.path.dirname(os.path.abspath("__file__")))
print('Loading Data...',end='')
print('Done)
LinearSVC(probability=True) # 提示没有该属性
#Similar to SVC with parameter kernel=’linear’, but implemented in terms of liblinear rather than libsvm, so it has more flexibility in the choice of penalties and loss functions and should scale better to large numbers of samples.
# http://scikit-learn.org/stable/modules/svm.html
SVC( kernel="linear", probability=True)
class A:
def __init__(self,l):
self.l = l
def get_params(self, deep = False):
return {'l':self.l}
from sklearn.calibration import CalibratedClassifierCV
svm = LinearSVC()
clf = CalibratedClassifierCV(svm)
clf.fit(X_train, y_train)
y_proba = clf.predict_proba(X_test)
- BaggingClassifier is Roughly Equivalent to RandomForestClassifier
from sklearn.tree import DecisionTreeClassifier
BaggingClassifier((DecisionTreeClassifier, splitter="random",max_leaf_nodes=16),
n_estimators=500, max_samples=1.0, bootstrap=True, n_jobs=-1)