Unexpected NaN values during training of SVM with scikit-learn
I'm currently working on a support vector machine (SVM) classification question using `scikit-learn` version 0.24.2. However, I'm working with unexpected `NaN` values in the training process, specifically during the `fit` method. The input data is a NumPy array of shape `(100, 20)` with some missing values that I attempted to handle using mean imputation. Hereβs a snippet of my code: ```python import numpy as np from sklearn.impute import SimpleImputer from sklearn.svm import SVC # Create some random data with NaN values np.random.seed(42) X = np.random.rand(100, 20) X[::5] = np.nan # Introduce NaNs # Impute missing values with the mean imputer = SimpleImputer(strategy='mean') X_imputed = imputer.fit_transform(X) # Create labels y = np.random.randint(0, 2, size=100) # Fit the SVM model model = SVC(kernel='linear') model.fit(X_imputed, y) ``` After running this code, the training process raises an behavior: `ValueError: Input contains NaN, infinity or a value too large for dtype('float64').`. I checked the imputed data using `np.isnan(X_imputed).any()` and it returns `False`, indicating there are no `NaN` values left. I also confirmed the types of the data using `X_imputed.dtype`, which is `float64` as expected. I suspect that there might be an scenario with how NaNs are handled by the SVM internally, or perhaps with the data types at some point during training. I've tried using different imputation strategies (like median), but the scenario continues. What could be causing these `NaN` values to propagate during training, and how can I resolve this scenario? Any insights would be greatly appreciated! My development environment is Windows. Any ideas what could be causing this?