有没有一种方法可以使用GridSearchCV或任何其他内置的sklearn函数来为OneClassSVM分类器找到最佳的超参数?
我目前要做的是使用训练/测试拆分自己执行搜索,如下所示:
Gamma和nu值定义为:
gammas = np.logspace(-9, 3, 13)
nus = np.linspace(0.01, 0.99, 99)
Run Code Online (Sandbox Code Playgroud)
探索所有可能的超参数并找到最佳参数的函数:
clf = OneClassSVM()
results = []
train_x = vectorizer.fit_transform(train_contents)
test_x = vectorizer.transform(test_contents)
for gamma in gammas:
for nu in nus:
clf.set_params(gamma=gamma, nu=nu)
clf.fit(train_x)
y_pred = clf.predict(test_x)
if 1. in y_pred: # Check if at least 1 review is predicted to be in the class
results.append(((gamma, nu), (accuracy_score(y_true, y_pred),
precision_score(y_true, y_pred),
recall_score(y_true, y_pred),
f1_score(y_true, y_pred),
roc_auc_score(y_true, y_pred),
))
)
# Determine and print the best parameter settings …Run Code Online (Sandbox Code Playgroud) svm scikit-learn multilabel-classification hyperparameters grid-search
我有几个文件与不同的文件:
darkflow依赖于图模式的基于张量流的库
在darkflow的TFNet初始化期间,我收到此错误:
Traceback (most recent call last):
File "/home/justin/Projects/comp3931/main.py", line 6, in <module>
watcher = Watcher('res/vid/planet_earth_s01e01/video.mp4', 'res/vid/planet_earth_s01e01/english.srt')
File "/home/justin/Projects/comp3931/watch.py", line 9, in __init__
self.detector = Detector()
File "/home/justin/Projects/comp3931/detect.py", line 6, in __init__
self.tfnet = TFNet(self.options)
File "/usr/local/lib64/python3.6/site-packages/darkflow/net/build.py", line 75, in __init__
self.build_forward()
File "/usr/local/lib64/python3.6/site-packages/darkflow/net/build.py", line 105, in build_forward
self.inp = tf.placeholder(tf.float32, inp_size, 'input')
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 1677, in placeholder
raise RuntimeError("tf.placeholder() is not compatible with " …Run Code Online (Sandbox Code Playgroud)