n_initとrandom_stateの役割がわからないです。
seed = 0 np.random.seed(seed) ks = KShape(n_clusters=2, n_init=10, verbose=True, random_state=seed)
とコードを書いてKShape法を使っています。
https://tslearn.readthedocs.io/en/latest/gen_modules/clustering/tslearn.clustering.KShape.html?highlight=KShape
のドキュメントを見ながらKShapeメソッドのn_initとrandom_stateの役割を理解しようとしています。
まず、n_init に関してですが、
異なるセントロイドでKShapeのアルゴリズムが走る回数を設定する、という説明ですが、この説明がよく理解できません。
n_init (int (default: 1)) – Number of time the k-Shape algorithm will be run with different centroid seeds. The final results will be the best output of n_init consecutive runs in terms of inertia.
学習回数、という意味に取れそうですが、それはmax_iter引数の役割であると思うので違うとは思います。
random_stateはセントロイドを初期化するのに使うという説明ですが、次のセントロイドはそれぞれのデータの中心が選ばれるはずなので、なぜ乱数で決定するのか理解できません。
random_state (integer or numpy.RandomState, optional) – Generator used to initialize the centers. If an integer is given, it fixes the seed. Defaults to the global numpy random number generator.
これらの引数の役割を理解されている方がいらっしゃいましたら教えてください、よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/08/03 04:40