I am quite new to both python and scikit-learn. My goal is to get a classification working that should the divide into 6 different string labels with a deep belief net.
I get my data that consists 11 columns like that:
input_file = "Downloads/data.csv"
df = pd.read_csv(input_file, header = 0)
original_headers = list(df.columns.values)
df = df._get_numeric_data()
numeric_headers = list(df.columns.values)
reverse_df = df[numeric_headers]
numpy_array = reverse_df.as_matrix()
X, Y = numpy_array[:,1:], numpy_array[:,0]
Then I do:
# Splitting data
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2, random_state=0)
# Data scaling
min_max_scaler = MinMaxScaler()
X_train = min_max_scaler.fit_transform(X_train)
# Training
classifier = SupervisedDBNClassification(hidden_layers_structure=[256, 256],
learning_rate_rbm=0.01,
learning_rate=0.001,
n_epochs_rbm=20,
n_iter_backprop=100,
l2_regularization=0.0,
activation_function='relu')
classifier.fit(X_train, Y_train)
# Test
X_test = min_max_scaler.transform(X_test)
Y_pred = classifier.predict(X_test)
print 'Done.nAccuracy: %f' % accuracy_score(Y_test, Y_pred)
But that it says me: ValueError:
Can't handle mix of unknown and binary
I think I have to do something like the following statements with the data, but I am not sure how to perform it on the data correctly:
le = preprocessing.LabelEncoder()
le.fit(["Class A", "Class B", "Class C", "Class D", "Class E", "Class F"])
Thank you!
Aucun commentaire:
Enregistrer un commentaire