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

怎么在企业站建立网站怎样在网上做推广

怎么在企业站建立网站,怎样在网上做推广,seo公司中国,网络设计行业是干什么的要求: 针对实验1和实验2构建的数据集信息分析 设计实现通过数据简介进行大类分类的程序 代码实现: 训练集数据获取: read_data.py import json import pickledef read_intro():data []trypathr"E:\Procedure\Python\Experiment\f…

要求:

针对实验1和实验2构建的数据集信息分析

设计实现通过数据简介进行大类分类的程序

代码实现:

训练集数据获取:

read_data.py

import json
import pickledef read_intro():data = []trypath=r"E:\Procedure\Python\Experiment\first.json"filepath=r"E:\Procedure\Python\Experiment\res1.json"with open(filepath, 'r', encoding='utf-8') as file:for line in file:record = json.loads(line)if record.get('intro')!='':data.append(record)return datadef store_model(model):# 加载模型file=r'E:\Procedure\Python\Experiment\Machine_Learning\model1.pkl'try:# 尝试以 'xb' 模式打开文件,如果文件不存在则创建新文件with open(file, 'wb') as file:# 使用 pickle 序列化模型并写入文件pickle.dump(model, file)except FileExistsError:print("File already exists. Cannot overwrite existing file.")except Exception as e:print("An error occurred:", e)# 使用加载的模型进行预测#predictions = loaded_model.predict(X_test)
def store_report(report):file=r"E:\Procedure\Python\Experiment\Machine_Learning\class_report.txt"with open(file,'w')as file:file.write(report)returndef get_model():m_path=r'E:\Procedure\Python\Experiment\Machine_Learning\model1.pkl'try:with open(m_path,'rb')as file:loaded_model=pickle.load(file)return loaded_modelexcept Exception as e:print(e)return None
训练模型:

多项式朴素贝叶斯模型用于单一标签文本分类

# 导入所需的库
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, classification_report
import read_data
import random
data=read_data.read_intro()
random.shuffle(data)
X = [item['intro'] for item in data]
y = [item['mainclass'] for item in data]
# 文本向量化
vectorizer = TfidfVectorizer()
X_vectorized = vectorizer.fit_transform(X)# 将数据集划分为训练集和测试集
X_train, X_test, y_train, y_test = train_test_split(X_vectorized, y, test_size=0.2, random_state=42)# 初始化朴素贝叶斯分类器
model = read_data.get_model()
#model = MultinomialNB()
# 训练模型model.fit(X_train, y_train)# 在测试集上进行预测
y_pred = model.predict(X_test)read_data.store_model(model)
# 评估模型性能
accuracy = accuracy_score(y_test, y_pred)
print("Accuracy:", accuracy)# 打印分类报告
print("\nClassification Report:")
report=classification_report(y_test, y_pred,zero_division=0)
print(report)
read_data.store_report(report)

结果:

http://www.hkea.cn/news/112180/

相关文章:

  • 软件外包保密协议seo相关岗位
  • 后台网站开发文档下载班级优化大师app
  • 辛集城乡建设管理局网站网络营销网络推广
  • 阿里云部署一个自己做的网站吗电商网站搭建
  • 免费汽车租赁网站模板网站域名解析ip查询
  • 企业解决方案官网国内seo排名分析主要针对百度
  • 变态版手游石景山区百科seo
  • 阿里云控制台登录入口seo矩阵培训
  • wordpress苗木模板网站搜索排优化怎么做
  • 网站图片引导页怎么做重庆seo招聘
  • 如何做属于自己的领券网站郑州百度网站优化排名
  • 建设银行益阳市分行桃江支行网站公司页面设计
  • vps 网站上传网站seo优化是什么意思
  • wordpress cos腾讯云seo网站优化收藏
  • 鹤岗商城网站建设免费域名申请
  • 江苏三个地方疫情严重抖音视频排名优化
  • 竞价排名广告东莞关键词排名快速优化
  • 做视频网站要什么格式好网络营销公司怎么注册
  • 企业专业网站建设快速网站搭建
  • 武威建设网站的网站google谷歌搜索
  • 长沙公司做网站多少钱推广平台怎么做
  • 现在大家做电商网站用什么源码营销策略都有哪些
  • 可以做试卷的网站英语怎么说seo关键词排名优化系统源码
  • 网站怎么设置支付功能企业网站的主要类型有
  • 成都圣都装饰装修公司北京搜索优化排名公司
  • 境外建设网站贴吧互联网域名注册查询
  • 广州建站工作室淘客推广怎么做
  • 中国最大的网站建设公司百度广告联盟点击一次多少钱
  • wordpress单页主题营销seo手机关键词网址
  • dedecms做电影网站韩国最新新闻