当我尝试执行时
svm = SVC(gamma='auto',random_state = 42,probability=True)
BaggingClassifier(base_estimator=svm, n_estimators=31, random_state=314).fit(X,y)
它无限期地运行。该命令导致计算速度很慢还是我做错了方向?
答案 0 :(得分:1)
您正在正确使用它。 SVC只是超级慢。您可以通过以下方法进行检查:
from sklearn.svm import LinearSVC
from sklearn.ensemble import BaggingClassifier
import hasy_tools # pip install hasy_tools
# Load and preprocess data
data = hasy_tools.load_data()
X = data['x_train']
X = hasy_tools.preprocess(X)
X = X.reshape(len(X), -1)
y = data['y_train']
# Reduce dataset
dataset_size = 100
X = X[:dataset_size]
y = y[:dataset_size]
# Define model
svm = LinearSVC(random_state=42)
model = BaggingClassifier(base_estimator=svm, n_estimators=31, random_state=314)
# Fit
model.fit(X, y)
有关why SVC is slow的更多详细信息,请访问datascience.SE。