当前位置: 首页 > news >正文

02房价预测

目录

代码 

评分算法:


代码 

import numpy as np
from sklearn import datasets
from sklearn.linear_model import LinearRegression# 指定版本才有数据集
# C:\Users\14817\PycharmProjects\pythonProject1\venv\Scripts\activate.bat
# pip install scikit-learn==1.0
# FutureWarning: Function load_boston is deprecated; `load_boston` is deprecated in 1.0 and will be removed in 1.2.boston = datasets.load_boston()X = boston['data']     # 数据
y = boston['target']   # 房价
feature_names = boston['feature_names']  # 具体指标# 切分数据
index = np.array(range(506))
np.random.shuffle(index)train_index = index[:405]
test_index = index[405:]# 80%的训练数据
X_train = X[train_index]
y_train = y[train_index]X_test = X[test_index]
y_test = y[test_index]# 数据建模
np.set_printoptions(suppress=True)
model = LinearRegression(fit_intercept=True)
model.fit(X_train, y_train)# 模型应用
y_pred = model.predict(X_test).round(2)
print(y_pred)
print(y_test)#模型评分
#负数到1之间 ,1 最高分
score = model.score(X_test,y_test)
print(score)

评分算法:

http://www.lryc.cn/news/239615.html

相关文章:

  • 【Springboot】pom.xml中的<build>标签详解
  • 智能驾驶产品开发中如何贯彻“正向开发”理念
  • 【机器学习】038_梯度消失、梯度爆炸
  • 【转】OAK-D双目相机进行标定及标定结果说明
  • whip和whep
  • SpringBoot集成jjwt和使用
  • RedisConnectionFactory is required已解决!!!!
  • redis的高可用之持久化
  • onnx模型转换opset版本和固定动态输入尺寸
  • 远程运维如何更高效的远程管理?向日葵的这几项功能会帮到你
  • python BDD 的相关概念
  • 【Exception】Error: Dynamic require of “path“ is not supported
  • 【蓝桥杯选拔赛真题25】C++两个数比大小 第十三届蓝桥杯青少年创意编程大赛C++编程选拔赛真题解析
  • C++学习——C++运算符重载(含义、格式、示例、遵循的规则)
  • 【unity实战】unity3D中的PRG库存系统和换装系统(附项目源码)
  • 编程语言发展史:C语言的诞生及其影响
  • (二)pytest自动化测试框架之添加测试用例步骤(@allure.step())
  • 【用unity实现100个游戏之16】Unity程序化生成随机2D地牢游戏2(附项目源码)
  • 潮玩宇宙大逃杀游戏开发源码说明
  • UE5 操作WebSocket
  • Linux文件
  • 素短语的定义
  • 【华为OD题库-033】经典屏保-java
  • clang+llvm多进程gdb调试
  • PHP反序列化简单使用
  • 专业课140+总分420+东南大学920专业综合考研,信息学院通信专业考研分享
  • 数据结构与算法编程题11
  • 【LeetCode刷题】--40.组合总和II
  • mysql面试内容点
  • msvcp140.dll是什么?msvcp140.dll丢失的有哪些解决方法