When I am trying to execute
svm = SVC(gamma='auto',random_state = 42,probability=True)
BaggingClassifier(base_estimator=svm, n_estimators=31, random_state=314).fit(X,y)
It runs indefinitely. Is the command causing the computation to occur at a very slow pace or am I doing it the wrong way?
You are using it correctly. SVC is just super slow. Here is how you can check that:
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)
More details on why SVC is slow can be found on datascience.SE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With