python - classification using sklearn RandomForestClassifier -


I am using Scikit RandomForestClassifier to classify unbalanced data. Target class data is either '1' or '0' (99% of value is 0).

I want to specify a weight. How can i do it

I found it in ductionation:

sample_weight: array-like, size = [n_semple] or none

sample weight. If none, the samples are weighted evenly. When looking for split in each node, the child nodes with pure zero or negative weight for the partition is ignored. In the case of classification, division is also ignored, if any class takes negative weight in the node, then the result will be ignored too.

I need to increase the effect of '1'

Is it supposed to have done this:

  s_weight = np. Array ([100 If I i_train for i = 1 1])   

or this way:

  s_weight = y_train [,, 1 : 100] .T.ravel ()   

.

  clf.fit (X_train, y_train, sample_weight = s_weights)   

As I have not received the expected results, can anyone confirm ?

technically

  s_weight = np.array ([100 If I am in y_train for == 1 and i] 1)   

is correct, though the load in RF is not so easy. For example, in case of SVM, you will find the best load Must be valid (which may be less than 100 )

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -