我正在使用 sklearn MLPClassifier 类并收到错误消息:无法将数组数据从 dtype('float64') 转换为 dtype('
我有一个将字符串条目转换为列表函数的函数:
def listinha_da_amanda(entrada):
listinha = []
auxiliar_lista = ''
for i in range(len(entrada)):
if (entrada[i] != ','):
auxiliar_lista += entrada[i]
elif (entrada[i] == ','):
listinha.append(auxiliar_lista)
auxiliar_lista = ''
return listinha
def rna(entrada):
import pandas as pd
import numpy as np
base = pd.read_csv('app/sonotas.csv')
previsores = base.iloc[:, 1:10].values
classe = base.iloc[:, 10].values
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
previsores = scaler.fit_transform(previsores)
from sklearn.neural_network import MLPClassifier
classificador = MLPClassifier(verbose=True, max_iter=1000, solver='adam', hidden_layer_sizes=(12), activation='relu')
classificador.fit(previsores, classe)
resolv = listinha_da_amanda(entrada)
resolv2 = []
resolv2.append(resolv)
resultado = classificador.predict(resolv2)
return resultado
输入示例:9,8.6,6,7.6,8.1,7.8,8.3,9.4,8.9,
我正在使用 Django 框架。