@lookflyfarez (lookfly fares)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

React State Not Updating Immediately After setState – Why Is My Count Still 0?

sklearnの並列処理でDataConversionWarning
Q&A

scikit-learn
Parallel
並列処理
DataConversionWarning
解決したいこと
sklearnを並列処理で動かす実験をしています。
1)
Parallel(n_jobs=1)(
で起動した場合は、何のエラーもなく動くのですが、
2)
Parallel(n_jobs=-1)( にして並列処理にすると
DataConversionWarning:が発生します。

そのワーニングが言う通り、shapeで(n_samples,)の形状にしたり、y_dataがViewの場合はcopyにもしたのですがワーニングは出力されるので、その原因がよく分かりません。
解決方法を教えて下さい。

発生している問題・エラー
../python3.11/site-packages/sklearn/preprocessing/label.py:129: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
y = column_or_1d(y, dtype=self.classes
.dtype, warn=True)
該当するソースコード

(並列処理部)
  ...
Xs_train, Xs_test, ys_train, ys_test = custom_train_test_split(X_train, y_train, test_size=test_size, random_state=42)
ys_train = ys_train.copy()
ys_test = ys_test.copy()
ys_train = np.ascontiguousarray(ys_train.reshape(-1,))
ys_train = check_y_shape(model_name, store_id, ys_train, loc=f'{location()}')

model = get_model_instance(model_name, store_id)

ys_train = check_y_shape(model_name, store_id, ys_train)
model.fit(Xs_train, ys_train)	

自分で試したこと

check_y_shape()は、ys_trainの形状が(n, 1)の場合に (n, )にshapeし、viewならば、copyし直す処理で

British Airways Multi city
0 likes

1Answer

Your answer might help someone💌