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

h5响应式网站建设.net网站开发怎么发布

h5响应式网站建设,.net网站开发怎么发布,山东德州网站建设哪家最好,网站建设与管理 十四五国规教材【Python】数据挖掘与机器学习(一) 大家好 我是寸铁#x1f44a; 总结了一篇【Python】数据挖掘与机器学习(一)sparkles: 喜欢的小伙伴可以点点关注 #x1f49d; 【实验1】预测鲍鱼年龄 问题描述 请从一份数据中预测鲍鱼的年龄#xff0c;数据集在abalone.cvs中#xff…【Python】数据挖掘与机器学习(一) 大家好 我是寸铁 总结了一篇【Python】数据挖掘与机器学习(一)sparkles: 喜欢的小伙伴可以点点关注 【实验1】预测鲍鱼年龄 问题描述 请从一份数据中预测鲍鱼的年龄数据集在abalone.cvs中数据集一共有4177 个样本每个样本有9个特征。其中rings为鲍鱼环数鲍鱼每一年长一环类似树轮是预测 变量sex属性已经经过处理M1表示雄性、F-1表示雌性、I0表示幼体。 有9列数据分别是: 要求 (1)给出回归模型给出线性回归模型的回归系数以及 (2)需要分训练数据与测试数据采用训练数据学习给出R2采用测试数据计算MSE. 代码 import sklearn import tensorflow as tf import numpy as np import pandas import sklearn.model_selection as ms import matplotlib.pyplot as pltdef main():df pandas.read_csv(abalone.csv)df df.valuesy df[:, [-1]].astype(float32) # 提取第9 列x df[:, 1:8].astype(float32) # 提取1-8 列sex df[:, 0].astype(float32) # 取出第0 列后续要转换成2 个哑元male sex 1female sex -1oneMa np.zeros((len(sex), 1), dtypefloat32) # 雄性oneFe np.zeros((len(sex), 1), dtypefloat32) # 雌性oneMa[male] 1oneFe[female] 1ones np.ones((len(x), 1), dtypefloat32) # 全是 1 的向量x np.hstack((ones, oneMa, oneFe, x)) # 凑成一个 X 大矩阵print(x.shape)rows, cols x.shapeweight tf.Variable(tf.random.normal([cols, 1]), nameweight)# 生成一个 包含 bias 的 weight对应 x 的列数def loss_fn(X, y):y_ tf.matmul(X, weight)assert (y.shape y_.shape) # 确认维数一致这一步很容易出错return tf.reduce_mean(tf.square(y_ - y)) / 2x_train, x_test, y_train, y_test ms.train_test_split(x, y, test_size0.3, random_state32)print(x_train.shape)print(x_test.shape)print(y_train.shape)print(y_test.shape)print(weight)yy_ tf.matmul(x_train, weight)err sklearn.metrics.mean_squared_error(y_train, yy_)print(f训练集 MSE {err})y_ tf.matmul(x_test, weight)err sklearn.metrics.mean_squared_error(y_test, y_)print(f测试集 MSE {err}) # 测试集的 MSER2 sklearn.metrics.r2_score(y_train, yy_)print(fR2 {R2})plt.show()【实验2】成年男性的听力实验 数据集hearing_test.csv 是对 5000 名参与者进行了一项实验以研究年龄和身体健康对听力损失的影响尤其是听高音的能力。此数据显示了研究结果对参与者进行了身体能力的评估和评分然后必须进行音频测试通过/不通过以评估他们听到高频的能力。 特征1.年龄age2. 健康得分physical_score 标签1通过/0不通过 要求 (1)采用以下方法读取数据并给出可视化的显示效果 import seaborn as sns import pandas as pd (绘图包, pip install seaborn) import matplotlib.pyplot as plt df pd.read_csv(hearing_test.csv) sns.scatterplot(xage,yphysical_score,datadf,huetest_result) sns.pairplot(df,huetest_result) plt.show() 由于show默认是阻塞看完图后要把它放在代码最后面 (2)采用以下方法得到数据 df df.values x df[:, [0, 1]] 头两列对应age与physical_score - 3 - y df[:, 2] 第三列对应是否通过 (3)把数据拆分为训练集与测试集最后采用测试数据来验证模型 from sklearn.model_selection import train_test_split x_train, x_test, y_train, y_test train_test_split(x, y, test_size0.4, random_state2022) (4)给出Logistic回归分类方法给出二分类模型的权重给出测试数据的散点图 (5)模型性能评估给出训练集与测试集的准确率 Accuracy、精确度 Precision 和召 回率Recall、F1score。 (6)选做给出两类数据的分割直线。 代码 import seaborn as sns import pandas as pd import matplotlib.pyplot as plt from sklearn.linear_model import LogisticRegression from sklearn.model_selection import train_test_split from tensorflow.python.ops.confusion_matrix import confusion_matrix from sklearn.metrics import accuracy_score from sklearn.metrics import precision_score from sklearn.metrics import recall_score from sklearn.metrics import f1_scoredf pd.read_csv(hearing_test.csv) testA df[df[test_result] 0].values testB df[df[test_result] 1].values sns.scatterplot(xage, yphysical_score, datadf, huetest_result) sns.pairplot(df, huetest_result) df df.values x df[:, [0, 1]] # 头两列对应 age 与 physical_score y df[:, 2] # 第三列对应是否通过 x_train, x_test, y_train, y_test train_test_split(x, y,test_size0.4, random_state2022) model LogisticRegression(fit_interceptTrue).fit(x_train, y_train) weight model.coef_ bias model.intercept_ print(权重, weight, bias) print(训练集准确率:, model.score(x_train, y_train)) print(测试集准确率:, model.score(x_test, y_test)) y_pred model.predict(x_test) print(混淆矩阵\n, confusion_matrix(y_test, y_pred))print(accuracy:, accuracy_score(y_test, y_pred)) print(precision:, precision_score(y_test, y_pred)) print(recall:, recall_score(y_test, y_pred)) print(f1 score:, f1_score(y_test, y_pred)) x1_boundary, x2_boundary [], []plt.figure() plt.scatter(x1_boundary, x2_boundary, cb, s10) plt.scatter(testA[:, 0], testA[:, 1], cr, s1) plt.scatter(testB[:, 0], testB[:, 1], cg, s1) plt.show() 看到这里的小伙伴恭喜你又掌握了一个技能 希望大家能取得胜利坚持就是胜利 我是寸铁我们下期再见 往期好文 保姆级教程 【保姆级教程】Windows11下go-zero的etcd安装与初步使用 【保姆级教程】Windows11安装go-zero代码生成工具goctl、protoc、go-zero 【Go-Zero】手把手带你在goland中创建api文件并设置高亮 报错解决 【Go-Zero】Error: user.api 27:9 syntax error: expected ‘:‘ | ‘IDENT‘ | ‘INT‘, got ‘(‘ 报错解决方案及api路由注意事项 【Go-Zero】Error: only one service expected goctl一键转换生成rpc服务错误解决方案 【Go-Zero】【error】 failed to initialize database, got error Error 1045 (28000):报错解决方案 【Go-Zero】Error 1045 (28000): Access denied for user ‘root‘‘localhost‘ (using password: YES)报错解决方案 【Go-Zero】type mismatch for field “Auth.AccessSecret“, expect “string“, actual “number“报错解决方案 【Go-Zero】Error: user.api 30:2 syntax error: expected ‘)‘ | ‘KEY‘, got ‘IDENT‘报错解决方案 【Go-Zero】Windows启动rpc服务报错panic:context deadline exceeded解决方案 Go面试向 【Go面试向】defer与time.sleep初探 【Go面试向】defer与return的执行顺序初探 【Go面试向】Go程序的执行顺序 【Go面试向】rune和byte类型的认识与使用 【Go面试向】实现map稳定的有序遍历的方式
http://www.pierceye.com/news/936304/

相关文章:

  • 济南网站制作设计公司WordPress文章相册修改
  • 购物网站建设思维导构图电商平台建设方案
  • 一个网站一年的费用多少惠州网站制作哪里好
  • 网站界面设计材料收集国内外包网站
  • 自如网站做的好 服务网站开发实训
  • 档案网站建设的意义网页制作工具可以分为
  • 网站建设价格是哪些方面决定的wordpress32m
  • 建设公司网站哪家好网站建设 中企动力洛阳分公司
  • 如何做自己的大淘客网站开公司建网站
  • 在线网站设计工具腾讯做的电子商务网站
  • 重庆建设工程证照查询网站东莞松山湖
  • 唐山市政建设总公司网站南阳网站推广招聘
  • wordpress搭建网站网站建立网络优化
  • 杭州住房和城乡建设部网站东莞常平粤海水务
  • 网站设计方案案例yw55516can优物入口
  • 重庆有哪些做网站公司好丹东 建设集团 招聘信息网站
  • 深圳高端网站建设建设凡科网站
  • 类似织梦的建站cms百度广州分公司待遇
  • 仿qq商城版淘宝客网站源码模板+带程序后台文章dede织梦企业程序上海专业制作网页
  • 网站建设服务8合肥网红打卡地
  • 网站按关键词显示广告图片如何在本地搭建网站
  • 安徽网站建设认准-晨飞网络域名和网站建设
  • 上海人才网最新招聘信息官方网站互联网软件
  • 网站备案审核流程图长治专业做网站
  • 网站建设的参考文献英文北京市住房建设官网站
  • 网站文件夹命名seo大连网站建设方案咨询
  • 重庆推广一个网站网站标题flash
  • 潍坊住房与城乡建设局网站邮箱号怎么注册
  • 有没有免费开网站的电子商务网站建设讨论
  • 拓者室内设计网站东方甄选采用了哪些网络营销方式