python と scikit-learn を使用して、グリッド検索を行いたいと思います。しかし、私のモデルのいくつかは空になってしまいます。これらのモデルを無視するようにグリッド検索機能を作成するにはどうすればよいですか?
モデルが空の場合に 0 を返すスコアリング関数を使用できると思いますが、方法がわかりません。
predictor = sklearn.svm.LinearSVC(penalty='l1', dual=False, class_weight='auto')
param_dist = {'C': pow(2.0, np.arange(-10, 11))}
learner = sklearn.grid_search.GridSearchCV(estimator=predictor,
param_grid=param_dist,
n_jobs=self.n_jobs, cv=5,
verbose=0)
learner.fit(X, y)
私のデータは、このlearner
オブジェクトがC
空のモデルに対応するを選択するようになっています。モデルが空でないことを確認する方法はありますか?
編集:「空のモデル」とは、使用する機能を0つ選択したモデルを意味します。特にl1
正規化されたモデルでは、これは簡単に起こります。したがって、この場合、C
SVM の が十分に小さければ、最適化問題は係数の最適解として 0 ベクトルを見つけます。したがって、 は s のpredictor.coef_
ベクトルになります0
。