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

html网站地图模板武汉seo论坛

html网站地图模板,武汉seo论坛,长沙建网,申请域名后 怎么把网站部署上去文章目录回顾赛题优化1️⃣优化2️⃣回顾赛题 模块内容类型说明/示例赛题背景概述参赛者需构建端到端评论分析系统,实现商品识别、多维情感分析、评论聚类与主题提炼三大任务。商品识别输入video_desc(视频描述) video_tags(标签…

文章目录

  • 回顾赛题
  • 优化1️⃣
  • 优化2️⃣


回顾赛题

模块内容类型说明/示例
赛题背景概述参赛者需构建端到端评论分析系统,实现商品识别、多维情感分析、评论聚类与主题提炼三大任务。
商品识别输入video_desc(视频描述)+ video_tags(标签)
输出商品名称(如:Xfaiyx Smart Translator/Recorder)
多维情感分析情感维度- 情感倾向(5类)
- 用户场景
- 用户疑问
- 用户建议
挑战点隐晦表达处理,如“这重量出门带着刚好”暗示出行场景
评论聚类与主题提炼聚类目标针对5类评论进行聚类分析
输出示例主题词如:续航短|充电慢|发热严重
赛题目标AI目标从原始评论中提取商品与用户洞察,转化为商业智能
评估标准商品识别准确率(Accuracy):正确识别商品的比例
情感分析宏平均 F1 值:多分类性能衡量
评论聚类轮廓系数(Silhouette Score):评估聚类合理性
数据集视频数据85 条,4 个字段,部分标注 product_name
评论数据6,477 条,12 个字段,部分情感字段已标注
挑战与难点标注比例低仅约 15% 样本有人工标注
泛化能力挑战需提升未标注样本上的表现
推荐方法- 半监督学习(如 UDA)
- 提示学习(Prompt Learning)
最终目标总结构建商品识别 → 情感分析 → 聚类主题提炼的完整 AI 处理链路

优化1️⃣

使用 Pipeline 封装 TF-IDF + 分类/聚类流程

  • 说明:通过 make_pipeline()TfidfVectorizerSGDClassifier / KMeans 组合成统一流程,简化训练和预测步骤。

聚类 + 高频关键词提取逻辑封装成函数

  • 说明extract_cluster_theme(...) 函数统一处理文本聚类与主题词抽取,减少冗余代码。

文本字段预处理策略合理整合

  • 说明:将 video_descvideo_tags 组合生成 text 字段用于分类模型训练。
import os
import jieba
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import SGDClassifier
from sklearn.pipeline import make_pipeline
from sklearn.cluster import KMeans# -----------------------------
# 1. 加载数据
# -----------------------------
video_data = pd.read_csv("origin_videos_data.csv")
comments_data = pd.read_csv("origin_comments_data.csv")# 合并视频文本信息作为商品预测输入
video_data["text"] = video_data["video_desc"].fillna("") + " " + video_data["video_tags"].fillna("")# -----------------------------
# 2. 商品名称预测(分类任务)
# -----------------------------
product_name_predictor = make_pipeline(TfidfVectorizer(tokenizer=jieba.lcut, max_features=50),SGDClassifier()
)
video_train = video_data[~video_data["product_name"].isnull()]
product_name_predictor.fit(video_train["text"], video_train["product_name"])
video_data["product_name"] = product_name_predictor.predict(video_data["text"])# -----------------------------
# 3. 评论情感&属性多维度分类
# -----------------------------
target_cols = ['sentiment_category', 'user_scenario', 'user_question', 'user_suggestion']for col in target_cols:predictor = make_pipeline(TfidfVectorizer(tokenizer=jieba.lcut),SGDClassifier())train_data = comments_data[~comments_data[col].isnull()]predictor.fit(train_data["comment_text"], train_data[col])comments_data[col] = predictor.predict(comments_data["comment_text"])# -----------------------------
# 4. 聚类 + 主题提取封装函数
# -----------------------------
def extract_cluster_theme(dataframe, filter_cond, target_column, n_clusters=5, top_n_words=10):"""对特定子集评论进行聚类并提取主题词"""cluster_texts = dataframe[filter_cond]["comment_text"]kmeans_pipeline = make_pipeline(TfidfVectorizer(tokenizer=jieba.lcut),KMeans(n_clusters=n_clusters, random_state=42))kmeans_pipeline.fit(cluster_texts)cluster_labels = kmeans_pipeline.predict(cluster_texts)# 提取高频主题词tfidf = kmeans_pipeline.named_steps['tfidfvectorizer']kmeans = kmeans_pipeline.named_steps['kmeans']feature_names = tfidf.get_feature_names_out()cluster_centers = kmeans.cluster_centers_top_keywords = []for i in range(n_clusters):indices = cluster_centers[i].argsort()[::-1][:top_n_words]keywords = ' '.join([feature_names[idx] for idx in indices])top_keywords.append(keywords)# 写入对应字段dataframe.loc[filter_cond, target_column] = [top_keywords[label] for label in cluster_labels]# -----------------------------
# 5. 进行五个维度的聚类主题提取
# -----------------------------
extract_cluster_theme(comments_data,comments_data["sentiment_category"].isin([1, 3]),"positive_cluster_theme"
)extract_cluster_theme(comments_data,comments_data["sentiment_category"].isin([2, 3]),"negative_cluster_theme"
)extract_cluster_theme(comments_data,comments_data["user_scenario"] == 1,"scenario_cluster_theme"
)extract_cluster_theme(comments_data,comments_data["user_question"] == 1,"question_cluster_theme"
)extract_cluster_theme(comments_data,comments_data["user_suggestion"] == 1,"suggestion_cluster_theme"
)# -----------------------------
# 6. 导出预测结果
# -----------------------------
os.makedirs("submit", exist_ok=True)video_data[["video_id", "product_name"]].to_csv("submit/submit_videos.csv", index=False)comments_data[['video_id', 'comment_id', 'sentiment_category','user_scenario', 'user_question', 'user_suggestion','positive_cluster_theme', 'negative_cluster_theme','scenario_cluster_theme', 'question_cluster_theme','suggestion_cluster_theme'
]].to_csv("submit/submit_comments.csv", index=False)

对比效果

在这里插入图片描述


优化2️⃣

import os
import jieba
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import SGDClassifier
from sklearn.pipeline import make_pipeline
from sklearn.cluster import KMeans# -----------------------------
# 1. 加载数据
# -----------------------------
video_data = pd.read_csv("origin_videos_data.csv")
comments_data = pd.read_csv("origin_comments_data.csv")# 合并视频描述 + 标签,形成商品分类模型的输入字段
video_data["text"] = video_data["video_desc"].fillna("") + " " + video_data["video_tags"].fillna("")# -----------------------------
# 2. 商品名称预测(分类任务)
# -----------------------------
# 构建商品分类器:使用 TF-IDF(最多 50 个词)+ SGD 分类器(适合大规模稀疏特征)
product_name_predictor = make_pipeline(TfidfVectorizer(tokenizer=jieba.lcut, max_features=50),SGDClassifier()
)
# 拿有真实标签的部分训练模型
video_train = video_data[~video_data["product_name"].isnull()]
product_name_predictor.fit(video_train["text"], video_train["product_name"])# 使用模型预测所有视频的商品名称
video_data["product_name"] = product_name_predictor.predict(video_data["text"])# ✅ 可选优化:
# - 模型替换:`SGDClassifier` 可替换为 `LogisticRegression`, `XGBoost`, `RandomForest` 等
# - 分词改进:`jieba` 可替换为 `pkuseg`, `LAC`,或使用 `BERT` tokenizer(更强但慢)
# - 增加 n-gram:`ngram_range=(1,2)` 可捕捉“关键词组合”,提高分类准确率# -----------------------------
# 3. 评论情感&属性多维度分类
# -----------------------------
# 要预测的评论属性标签(分类任务)
target_cols = ['sentiment_category', 'user_scenario', 'user_question', 'user_suggestion']# 对每个目标列都训练一个 TF-IDF + SGD 分类器
for col in target_cols:predictor = make_pipeline(TfidfVectorizer(tokenizer=jieba.lcut),SGDClassifier())train_data = comments_data[~comments_data[col].isnull()]predictor.fit(train_data["comment_text"], train_data[col])comments_data[col] = predictor.predict(comments_data["comment_text"])# ✅ 可选优化:
# - 使用 `MultiOutputClassifier` 构建联合多标签分类器
# - 样本不均衡时,考虑添加 `class_weight='balanced'`
# - 加入 `classification_report` 输出分类指标,辅助调参# -----------------------------
# 4. 聚类 + 主题提取封装函数
# -----------------------------
def extract_cluster_theme(dataframe, filter_cond, target_column, n_clusters=5, top_n_words=10):"""对指定条件筛选出的评论子集,使用 KMeans 聚类并提取每类高频关键词,写入主题字段"""cluster_texts = dataframe[filter_cond]["comment_text"]# 构建聚类模型:TF-IDF + KMeanskmeans_pipeline = make_pipeline(TfidfVectorizer(tokenizer=jieba.lcut),KMeans(n_clusters=n_clusters, random_state=42))kmeans_pipeline.fit(cluster_texts)cluster_labels = kmeans_pipeline.predict(cluster_texts)# 提取每个聚类的高频关键词(TF-IDF 值最高的前 n 个词)tfidf = kmeans_pipeline.named_steps['tfidfvectorizer']kmeans = kmeans_pipeline.named_steps['kmeans']feature_names = tfidf.get_feature_names_out()cluster_centers = kmeans.cluster_centers_top_keywords = []for i in range(n_clusters):indices = cluster_centers[i].argsort()[::-1][:top_n_words]keywords = ' '.join([feature_names[idx] for idx in indices])top_keywords.append(keywords)# 为筛选子集中的每条评论赋予对应主题标签dataframe.loc[filter_cond, target_column] = [top_keywords[label] for label in cluster_labels]# ✅ 可选优化:
# - 聚类算法替换:`KMeans` → `MiniBatchKMeans`(更快)、`LDA`(更语义)、`HDBSCAN`(无需指定簇数)
# - TF-IDF 可以添加 `max_features`, `stop_words`, `ngram_range` 等增强表达
# - 可加 `TSNE` / `UMAP` 降维可视化聚类分布
# - 可保存最具代表性的样本(如每类中心附近评论)# -----------------------------
# 5. 进行五个维度的聚类主题提取
# -----------------------------
# 对以下几类评论子集做主题提取,并写入指定列
extract_cluster_theme(comments_data,comments_data["sentiment_category"].isin([1, 3]),"positive_cluster_theme"
)extract_cluster_theme(comments_data,comments_data["sentiment_category"].isin([2, 3]),"negative_cluster_theme"
)extract_cluster_theme(comments_data,comments_data["user_scenario"] == 1,"scenario_cluster_theme"
)extract_cluster_theme(comments_data,comments_data["user_question"] == 1,"question_cluster_theme"
)extract_cluster_theme(comments_data,comments_data["user_suggestion"] == 1,"suggestion_cluster_theme"
)# ✅ 可选优化:
# - 添加异常处理,避免聚类文本为空时程序崩溃
# - 若后续支持多语言数据,可替换 tokenizer 和聚类逻辑为更通用版本# -----------------------------
# 6. 导出预测结果
# -----------------------------
# 创建输出目录
os.makedirs("submit", exist_ok=True)# 导出商品预测结果
video_data[["video_id", "product_name"]].to_csv("submit/submit_videos.csv", index=False)# 导出评论多分类 + 聚类主题提取结果
comments_data[['video_id', 'comment_id', 'sentiment_category','user_scenario', 'user_question', 'user_suggestion','positive_cluster_theme', 'negative_cluster_theme','scenario_cluster_theme', 'question_cluster_theme','suggestion_cluster_theme'
]].to_csv("submit/submit_comments.csv", index=False)

对比结果:
在这里插入图片描述

http://www.dtcms.com/wzjs/309978.html

相关文章:

  • 商城网站页面模板手机建站教程
  • 药品网站如何建设网上怎么免费推广
  • 桂林wordpress流程优化
  • 外国手机网站设计怎么宣传自己的产品
  • 做网站域名服务器网站页面优化包括
  • 有学做衣服的网站吗郑州高端网站建设哪家好
  • 广州做网站商城的公司b站软件推广大全
  • 石家庄外贸网站制作网页开发公司
  • b2b电子商务平台发展趋势seo长尾关键词
  • 西安市做网站公司seo推广怎么做视频教程
  • 泰州网站建设方案开发网站怎样才能在百度被搜索到
  • 店铺营业执照在哪个网站做年审汕头网站建设推广
  • 织梦系统如何做网站地图网站分为哪几种类型
  • 网站建设客服工作百度一下你就知道官网网页
  • 泰州做房产的网站搜索引擎优化的目标
  • 县 两学一做网站公关负面处理公司
  • 网站管理系统有哪些网站空间
  • 化妆品网站建设实施方案产品推广怎么做
  • 政协网站信息化建设的作用泉州seo按天计费
  • 临沂做商城网站昆明百度关键词优化
  • 郑州做网站的联系方式郑州seo培训
  • 优化网站是什么意思深圳市龙华区
  • 网站建设纠纷怎么投诉时事政治2023最新热点事件
  • 做深度报道的网站域名访问网站
  • 旅游网站设计代码模板网络营销方法有几种类型
  • godaddy如何创建网站百度推广北京总部电话
  • 深圳积分商城网站制作中小企业网络推广
  • 网站下雪特效邯郸网站seo
  • 南宁logo设计公司哪些网站可以seo
  • 九江网站建设哪家公司好互动营销用在哪些推广上面