すべての数値データを含むデータセット (乳がん検出) があり、データセットを X (すべての機能を含む) と y (出力クラス) に分割しました。データをトレーニングセットとテストセットに分割した後、私は直面しています機能スケーリングの適用に関する問題。機能スケーリングの適用時に、Value-Error: could not convert string to float: '?' が発生します。以前は -9999 でした。
X=df.iloc[:,:-1].values
y=df.iloc[:,-1].values
# データをトレーニング データとテスト データに分割します。
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.25,random_state=0)
#「?」の置き換え -9999 で。
df=df.replace('?',-9999)
from sklearn.preprocessing import LabelEncoder
#y にラベル エンコーディングを適用します。
le = LabelEncoder()
y = le.fit_transform(y)
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
ct = ColumnTransformer(transformers=[('encoder', OneHotEncoder(), [0])], remainder='passthrough')
X = np.array(ct.fit_transform(X))
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train[:, 1:] = sc.fit_transform(X_train[:, 1:])
X_test[:, 1:] = sc.transform(X_test[:, 1:])
#この後、値のエラーが発生します。データに残っていないか、カテゴリカルエンコーディングを行う必要がありますか?