Sci-Kit 学习的 .fit(X,y) 方法是否按顺序工作,如果不是,它是如何工作的?
Does Sci-Kit learn's .fit(X,y) method work sequentially, if not how does it work?
我正在使用 Sci-Kit learn 的 svm 库对图像进行分类。我想知道我什么时候适合测试数据它是按顺序工作还是它会删除以前的分类 material 并重新适应新的测试数据。例如,如果我将 100 张图像拟合到分类器中,我可以继续然后依次拟合另外 100 张图像,还是 SVM 会删除它对原始 100 张图像执行的工作。这对我来说很难解释,所以我将提供示例:
为了使 SVM 分类器适合 200 张图像,我可以这样做吗:
clf=SVC(kernel='linear')
clf.fit(test.data[0:100], test.target[0:100])
clf.fit(test.data[100:200], test.target[100:200])
或者我必须这样做:
clf=SVC(kernel='linear')
clf.fit(test.data[:200], test.target[:200])
我想知道只是因为我 运行 在尝试一次对太多图像使用 .fit(X, y) 时出现内存错误。那么是否可以按顺序使用 fit 并 "increment" 我的分类器向上,以便它在 10000 张图像上进行技术训练,但一次只能训练 100 张图像。
如果可以,请确认并解释一下?如果不可能,请解释一下?
http://scikit-learn.org/stable/developers/index.html#estimated-attributes
The last-mentioned attributes are expected to be overridden when you
call fit a second time without taking any previous value into account:
fit should be idempotent.
https://en.wikipedia.org/wiki/Idempotent
所以是的,第二次调用将擦除旧模型并计算新模型。懂python代码的可以自行查看。例如在 sklearn/svm/classes.py
我认为你需要 minibatch training, but i don't see partial_fit implementation for SVM, maybe it's because scikit-learn team recommend SGDClassifier and SGDRegressor for dataset with size more than 100k samples. http://scikit-learn.org/stable/tutorial/machine_learning_map/, try to use them with minibatch as described here。
我正在使用 Sci-Kit learn 的 svm 库对图像进行分类。我想知道我什么时候适合测试数据它是按顺序工作还是它会删除以前的分类 material 并重新适应新的测试数据。例如,如果我将 100 张图像拟合到分类器中,我可以继续然后依次拟合另外 100 张图像,还是 SVM 会删除它对原始 100 张图像执行的工作。这对我来说很难解释,所以我将提供示例:
为了使 SVM 分类器适合 200 张图像,我可以这样做吗:
clf=SVC(kernel='linear')
clf.fit(test.data[0:100], test.target[0:100])
clf.fit(test.data[100:200], test.target[100:200])
或者我必须这样做:
clf=SVC(kernel='linear')
clf.fit(test.data[:200], test.target[:200])
我想知道只是因为我 运行 在尝试一次对太多图像使用 .fit(X, y) 时出现内存错误。那么是否可以按顺序使用 fit 并 "increment" 我的分类器向上,以便它在 10000 张图像上进行技术训练,但一次只能训练 100 张图像。
如果可以,请确认并解释一下?如果不可能,请解释一下?
http://scikit-learn.org/stable/developers/index.html#estimated-attributes
The last-mentioned attributes are expected to be overridden when you call fit a second time without taking any previous value into account: fit should be idempotent.
https://en.wikipedia.org/wiki/Idempotent
所以是的,第二次调用将擦除旧模型并计算新模型。懂python代码的可以自行查看。例如在 sklearn/svm/classes.py
我认为你需要 minibatch training, but i don't see partial_fit implementation for SVM, maybe it's because scikit-learn team recommend SGDClassifier and SGDRegressor for dataset with size more than 100k samples. http://scikit-learn.org/stable/tutorial/machine_learning_map/, try to use them with minibatch as described here。