sklearn中使用MLPRegressor实现回归

使用的数据集是上篇文章生成的test.txt文件经过一些处理后得到的数据集文件。

# -*- coding: utf-8 -*-
#--------------------------
#from sklearn.neural_network import MLPClassifier #用于多分类的情况
#SciKit-learn库 可以创建神经网络
#MLP是多层感知器,使用的是前馈神经网络
#只支持交叉熵损失,使用mlp.predict_proda(),最小化交叉熵,同时给似然估计p(y|x)
#支持多分类使用softmax
#mlp = MLPClassifier(hidden_layer_sizes=(13, 13, 13), max_iter=500)
#mlp.fit(xtrain, ytrain)
#--------------------------
from sklearn.neural_network import MLPRegressor
from sklearn.model_selection import train_test_split
import numpy as np
import matplotlib.pyplot as plt
from sklearn import preprocessing
a = np.loadtxt("./test.txt")
scaler = preprocessing.StandardScaler().fit(a)
a = scaler.transform(a)
#print(a.shape) #get value from txt
x = a[:,0] #get the first column from a
y = a[:,1] ##get the second column from a
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
pri
评论 20
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值