将我的数据集拟合到我的模型中时出现问题 python
problem fiting my dataset into my model python
我在将数据集拟合到模型中时遇到问题。我不知道这个错误代表什么,当然也不知道如何修复它。谢谢!
import numpy as np
import pandas as pd
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import StandardScaler
from keras.models import Sequential
from keras.layers import Dense
dataset = pd.read_csv('Churn_Modelling.csv')
dataset
X=dataset.iloc[:,3:13].values
Y=dataset.iloc[:,13].values
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
lableencoder_X_2 = LabelEncoder()
X[:, 2] = lableencoder_X_2.fit_transform(X[:, 2])
ct = ColumnTransformer([('ohe', OneHotEncoder(), [1])], remainder='passthrough')
X = np.array(ct.fit_transform(X), dtype = str)
X = X[:, 1:]
classifier.add(Dense(units = 6,kernel_initializer = 'uniform',activation ='relu',input_dim = 11))
classifier.add(Dense(units = 6,kernel_initializer = 'uniform',activation ='relu'))
classifier.add(Dense(units= 1, kernel_initializer = 'uniform',activation = 'sigmoid'))
classifier.compile(optimizer = 'adam', loss = 'binary_crssentropy', metrics = ['accuracy'])
# fit our dataset to our module.
classifier.fit(X_train, y_train, batch_size = 10, epochs = 100)
错误:
嗯,错误信息很清楚。损失函数应该是 binary_crossentropy
而不是 binary_crssentropy
我在将数据集拟合到模型中时遇到问题。我不知道这个错误代表什么,当然也不知道如何修复它。谢谢!
import numpy as np
import pandas as pd
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import StandardScaler
from keras.models import Sequential
from keras.layers import Dense
dataset = pd.read_csv('Churn_Modelling.csv')
dataset
X=dataset.iloc[:,3:13].values
Y=dataset.iloc[:,13].values
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
lableencoder_X_2 = LabelEncoder()
X[:, 2] = lableencoder_X_2.fit_transform(X[:, 2])
ct = ColumnTransformer([('ohe', OneHotEncoder(), [1])], remainder='passthrough')
X = np.array(ct.fit_transform(X), dtype = str)
X = X[:, 1:]
classifier.add(Dense(units = 6,kernel_initializer = 'uniform',activation ='relu',input_dim = 11))
classifier.add(Dense(units = 6,kernel_initializer = 'uniform',activation ='relu'))
classifier.add(Dense(units= 1, kernel_initializer = 'uniform',activation = 'sigmoid'))
classifier.compile(optimizer = 'adam', loss = 'binary_crssentropy', metrics = ['accuracy'])
# fit our dataset to our module.
classifier.fit(X_train, y_train, batch_size = 10, epochs = 100)
错误:
嗯,错误信息很清楚。损失函数应该是 binary_crossentropy
而不是 binary_crssentropy