#兼容 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
多元线性回归实现代码
最新推荐文章于 2024-07-28 13:33:18 发布