多元线性回归实现代码

#兼容 pythone2,3
from __future__ import print_function

**#导入相关python库**
import os
import numpy as np
import pandas as pd

#使用matplotlib库画图
import matplotlib
import seaborn
import matplotlib.pyplot as plot
from sklearn import datasets

#设定随机数种子
np.random.seed(36)

**#读取数据**
housing = pd.read_csv(r'D:\si-tech\AI_2\CPU\my_solution\LR\house_predict\kc_train.csv',header=None)
target=housing.xs(1,axis=1)  #提取销售价格列
#训练集
housing=housing.drop(1,axis=1) #要预测的就是销售价格,所以在训练过程中是不需要销售价格的,把第二列删除掉
#测试数据
t=pd.read_csv(r'D:\si-tech\AI_2\CPU\my_solution\LR\house_predict\kc_test.csv',header=None)  

**#数据预处理**

#housing.info()    #查看是否有缺失值

housing.describe(include='all').T #查看数据特征

**#特征缩放**

from sklearn.preprocessing import MinMaxScaler

minmax_scaler=MinMaxScaler()

minmax_scaler.fit(housing)   #进行内部拟合,内部参数会发生变化

scaler_housing=minmax_scaler.transform(housing)

scaler_housing=pd.DataFrame(scaler_housi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值