Isolation Forest sklearn implementationを使用して357個の機能を持つデータセットを訓練しようとしています。 max features変数が1.0(デフォルト値)に設定されていると、私はうまくトレーニングして結果を得ることができます。sklearnを使用したIsolation Forestアルゴリズムでmax featuresパラメータを設定する際にエラーが発生しました
は、しかし、最大の特徴ときは2に設定され、それが次のエラーを与える:
ValueError: Number of features of the model must match the input.
Model n_features is 2 and input n_features is 357
機能のカウントが1(int型)とない1.0であるとき、それはまた同じエラーになります(浮く)。
私が理解したことは、フィーチャ数が2(int)の場合、各ツリーを作成する際に2つの機能を考慮する必要があるということでした。これは間違っていますか? max featuresパラメータを変更するにはどうすればよいですか?それは述べドキュメントで
from sklearn.ensemble.iforest import IsolationForest
def isolation_forest_imp(dataset):
estimators = 10
samples = 100
features = 2
contamination = 0.1
bootstrap = False
random_state = None
verbosity = 0
estimator = IsolationForest(n_estimators=estimators, max_samples=samples, contamination=contamination,
max_features=features,
bootstrap=boostrap, random_state=random_state, verbose=verbosity)
model = estimator.fit(dataset)
scikitバージョン0.18以下の問題があります。 [問題はこちら](https://github.com/scikit-learn/scikit-learn/issues/5732)を参照してください。あなたのscikit-versionを0.20 –
に更新してくださいThanks @ VivekKumar、それは問題であるようです。 – Fleur