正规方程的优化方法对波士顿房价进行预测
def linear1(): """ 正规方程的优化方法对波士顿房价进行预测 :return: """ # 1)获取数据 boston = load_boston() # 2)划分数据集 x_train, x_test, y_train, y_test = train_test_split(boston.data, boston.target, random_state=22) # 3)标准化 transfer = StandardScaler() x_train = transfer.fit_transform(x_train) x_test = transfer.transform(x_test) # 4)预估器 estimator = LinearRegression() estimator.fit(x_train, y_train) # 5)得出模型 print("正规方程-权重系数为:\n", estimator.coef_) print("正规方程-偏置为:\n", estimator.intercept_) # 6)模型评估 y_predict = estimator.predict(x_test) print("预测房价:\n", y_predict) error = mean_squared_error(y_test, y_predict) print("正规方程-均方误差为:\n", error) return None
【推荐】2025 HarmonyOS 鸿蒙创新赛正式启动,百万大奖等你挑战
【推荐】博客园的心动:当一群程序员决定开源共建一个真诚相亲平台
【推荐】开源 Linux 服务器运维管理面板 1Panel V2 版本正式发布
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 我在厂里搞 wine 的日子
· 如何通过向量化技术比较两段文本是否相似?
· 35+程序员的转型之路:经济寒冬中的希望与策略
· JavaScript中如何遍历对象?
· 领域模型应用
· 独立项目运营一周年经验分享
· 一款开源免费、通用的 WPF 主题控件包
· 独立开发,这条路可行吗?
· 【定时任务核心】究竟是谁在负责盯着时间,并在恰当时机触发任务?
· 解决了AI聊天的10个痛点后,我又做了一个新功能:交叉分析表
2020-11-02 JS 学习