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

有什么网站可以做扣扣头像如皋网站制作

有什么网站可以做扣扣头像,如皋网站制作,做网站用虚拟机还是服务器,餐饮 网站建设清华大学驭风计划课程链接 学堂在线 - 精品在线课程学习平台 (xuetangx.com) 代码和报告均为本人自己实现(实验满分),此次代码开源大家可以自行参考学习 有任何疑问或者问题,也欢迎私信博主,大家可以相互讨论交流哟…

清华大学驭风计划课程链接

学堂在线 - 精品在线课程学习平台 (xuetangx.com)

代码和报告均为本人自己实现(实验满分),此次代码开源大家可以自行参考学习

有任何疑问或者问题,也欢迎私信博主,大家可以相互讨论交流哟~~

一、案例简介¶

随着电商平台的兴起,以及疫情的持续影响,线上购物在我们的日常生活中扮演着越来越重要的角色。在进行线上商品挑选时,评论往往是我们十分关注的一个方面。然而目前电商网站的评论质量参差不齐,甚至有水军刷好评或者恶意差评的情况出现,严重影响了顾客的购物体验。因此,对于评论质量的预测成为电商平台越来越关注的话题,如果能自动对评论质量进行评估,就能根据预测结果避免展现低质量的评论。本案例中我们将基于集成学习的方法对 Amazon 现实场景中的评论质量进行预测。

二、作业说明

本案例中需要大家完成两种集成学习算法的实现(Bagging、AdaBoost.M1),其中基分类器要求使用 SVM 和决策树两种,因此,一共需要对比四组结果(AUC 作为评价指标):

  • Bagging + SVM

  • Bagging + 决策树

  • AdaBoost.M1 + SVM

  • AdaBoost.M1 + 决策树

注意集成学习的核心算法需要手动进行实现,基分类器可以调库。

基本要求

  • 根据数据格式设计特征的表示

  • 汇报不同组合下得到的 AUC

  • 结合不同集成学习算法的特点分析结果之间的差异

  • (使用 sklearn 等第三方库的集成学习算法会酌情扣分)

扩展要求

  • 尝试其他基分类器(如 k-NN、朴素贝叶斯)

  • 分析不同特征的影响

  • 分析集成学习算法参数的影响

本次数据来源于 Amazon 电商平台,包含超过 50,000 条用户在购买商品后留下的评论,各列的含义如下:

* reviewerID:用户 ID

* asin:商品 ID

* reviewText:英文评论文本

* overall:用户对商品的打分(1-5)

* votes_up:认为评论有用的点赞数(只在训练集出现)

* votes_all:该评论得到的总评价数(只在训练集出现)

* label:评论质量的 label,1 表示高质量,0 表示低质量(只在训练集出现)

评论质量的 label 来自于其他用户对评论的 votes,votes_up/votes_all ≥ 0.9 的作为高质量评论。此外测试集包含一个额外的列 ID,标识了每一个测试的样例。

三, 实验结果

在处理文本特征时候我也有尝试引入其他特征,比如评论长度,情感浓度,但是发现训练的效果反而更差,所以最终没有引入新的特征,在这里也尝试过Countvectorizer方法,最终会使得预测效果变差不少,最终使用TfidfVectorizer发现效果好很多。在这里也使用了稀疏数组的拼接方法,很适合大规模文本数据。 

# 处理文本特征
vectorize_model = TfidfVectorizer(stop_words='english')
train_X = vectorize_model.fit_transform(train_df['reviewText'])
test_X = vectorize_model.transform(test_df['reviewText']) # 合并上总评分特征
train_X = scipy.sparse.hstack([train_X, train_df['overall'].values.reshape((-1, 1)) / 5])
test_X = scipy.sparse.hstack([test_X, test_df['overall'].values.reshape((-1, 1)) / 5])
train_X.shape,train_df['label'].shape

((57039, 153748), (57039,)) 

def selection_clf(base_name):clf = Noneif base_name == 'SVM':base_clf = svm.LinearSVC()clf = CalibratedClassifierCV(base_clf, cv=2, method='sigmoid')elif base_name == 'DTree':clf = DecisionTreeClassifier(max_depth=10, class_weight='balanced')return clf
class Bagging:def __init__(self, base_estimator, num_estimators):self.base_estimator = base_estimator  # 基分类器对象self.num_estimators = num_estimators  # Bagging 的分类器个数def fit_predict(self, X_train, y_train, X_test):num_samples = X_train.shape[0]num_features = X_train.shape[1]result = np.zeros(X_test.shape[0])  # 记录测试集的预测结果for i in range(self.num_estimators):sample_indices = np.random.choice(num_samples, size=num_samples, replace=True)  # Bootstrapsample_X = X_train[sample_indices]sample_y = y_train[sample_indices]estimator = clone(self.base_estimator)  # 克隆基分类器estimator.fit(sample_X, sample_y)print(f"模型 {i+1:2d} 完成!")predict_proba = estimator.predict_proba(X_test)[:, 1]result += predict_proba  # 累加不同分类器的预测概率result /= self.num_estimators  # 取平均(投票)return result
class AdaBoostM1(object):def __init__(self, base_estimator, num_iter):self.base_estimator = base_estimator  # 基础分类器对象self.num_iter = num_iter  # 迭代次数def fit_predict(self, X_train, y_train, X_test):result_lst, beta_lst = [], []  # 记录每次迭代的预测结果和投票权重num_samples = len(y_train)weights = np.ones(num_samples)  # 样本权重,注意总和应为 num_samplesfor i in range(self.num_iter):self.base_estimator.fit(X_train, y_train, sample_weight=weights)  # 带权重的训练print('第{:<2d}次迭代!'.format(i+1))train_predictions = self.base_estimator.predict(X_train)  # 训练集预测结果misclassified = train_predictions != y_train  error = np.sum(weights[misclassified]) / num_samples  if error > 0.5:breakbeta = error / (1 - error)weights = weights * (1 - misclassified) * beta + weights * misclassified  weights /= np.sum(weights) / num_samples  # 归一化,使权重和等于 num_samplesbeta_lst.append(beta)test_predictions = self.base_estimator.predict_proba(X_test)[:, 1]  # 测试集预测概率result_lst.append(test_predictions)beta_lst = np.log(1 / np.array(beta_lst))beta_lst /= np.sum(beta_lst)  # 归一化投票权重print('\nVote Weight:\n', beta_lst)result = np.sum(np.array(result_lst) * beta_lst[:, None], axis=0) return result
from sklearn.model_selection import train_test_split
X_train, x_test, y_train, y_test = train_test_split(train_X, train_df['label'], test_size=0.14, random_state=42, shuffle=True)

在训练的时候也发现bagging算法要是使用直接划分的数据集会出错,所以我用了直接切片的方法就运行成功了。通过4种组合看出,svm+adaboostm1的组合auc成绩最高,在bagging算法在此次运行中不如adaboostm1的效果好。 

clf = selection_clf('SVM')  # 基分类器选择
clf = Bagging(clf, 10)
y_score = clf.fit_predict(train_X.tocsr()[:50000], train_df['label'][:50000], train_X.tocsr()[50000:57039])# 计算ROC曲线和AUC
fpr, tpr, thresholds = roc_curve(train_df['label'][50000:57039], y_score)
roc_auc = auc(fpr, tpr)# 绘制ROC曲线
plt.plot(fpr, tpr, label='ROC curve (AUC = %0.2f)' % roc_auc)
plt.plot([0, 1], [0, 1], 'k--')  # 绘制对角线
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('SVM+Bagging')
plt.legend(loc="lower right")
plt.show()

最终选择选择效果最好的svm+adaboostm1进行预测,最终写入文件。


文章转载自:
http://dinncobowler.stkw.cn
http://dinncoadela.stkw.cn
http://dinncoderris.stkw.cn
http://dinncobrocade.stkw.cn
http://dinncomotorcyclist.stkw.cn
http://dinncorailman.stkw.cn
http://dinncocaiquejee.stkw.cn
http://dinncostakhanovite.stkw.cn
http://dinncobook.stkw.cn
http://dinncoharle.stkw.cn
http://dinncolightship.stkw.cn
http://dinncotrophology.stkw.cn
http://dinncoveld.stkw.cn
http://dinncoedacious.stkw.cn
http://dinncoyellowbill.stkw.cn
http://dinncointerdependence.stkw.cn
http://dinncofaggoting.stkw.cn
http://dinncoceviche.stkw.cn
http://dinncotetrahedral.stkw.cn
http://dinncobacterization.stkw.cn
http://dinncodiacetylmorphine.stkw.cn
http://dinncoanimosity.stkw.cn
http://dinncoradiographer.stkw.cn
http://dinncorsl.stkw.cn
http://dinncodonald.stkw.cn
http://dinncobabesiasis.stkw.cn
http://dinncodwarfism.stkw.cn
http://dinncopalp.stkw.cn
http://dinncoinformatory.stkw.cn
http://dinncodatto.stkw.cn
http://dinncolex.stkw.cn
http://dinncopescadores.stkw.cn
http://dinncoannular.stkw.cn
http://dinncolaterite.stkw.cn
http://dinncofcic.stkw.cn
http://dinncoalcoa.stkw.cn
http://dinncoeschscholtzia.stkw.cn
http://dinncopronase.stkw.cn
http://dinncoclockmaker.stkw.cn
http://dinncoparty.stkw.cn
http://dinncowonderstruck.stkw.cn
http://dinncobulgar.stkw.cn
http://dinncovolte.stkw.cn
http://dinncounacknowledged.stkw.cn
http://dinncoimpingement.stkw.cn
http://dinncostapedectomy.stkw.cn
http://dinncovalediction.stkw.cn
http://dinncoformulize.stkw.cn
http://dinncorestudy.stkw.cn
http://dinncocloister.stkw.cn
http://dinncoencroachment.stkw.cn
http://dinncomars.stkw.cn
http://dinncohummer.stkw.cn
http://dinncobondslave.stkw.cn
http://dinncoeonian.stkw.cn
http://dinncoregalement.stkw.cn
http://dinncoabandonee.stkw.cn
http://dinncolarvikite.stkw.cn
http://dinncoopiology.stkw.cn
http://dinncomolectroics.stkw.cn
http://dinncononproficiency.stkw.cn
http://dinncoochre.stkw.cn
http://dinncopulpous.stkw.cn
http://dinncowhistler.stkw.cn
http://dinncocounterevidence.stkw.cn
http://dinncogaywings.stkw.cn
http://dinncomatroclinal.stkw.cn
http://dinncotetanic.stkw.cn
http://dinncotartarian.stkw.cn
http://dinncocanting.stkw.cn
http://dinncoupkeep.stkw.cn
http://dinncoambulant.stkw.cn
http://dinncolegend.stkw.cn
http://dinncodiarch.stkw.cn
http://dinncobennington.stkw.cn
http://dinncotepefaction.stkw.cn
http://dinncounholy.stkw.cn
http://dinnconeodymium.stkw.cn
http://dinncoblowy.stkw.cn
http://dinncoaaal.stkw.cn
http://dinncocienfuegos.stkw.cn
http://dinncomahabharata.stkw.cn
http://dinncocockeye.stkw.cn
http://dinncocounterspy.stkw.cn
http://dinncoclangorous.stkw.cn
http://dinncodarrell.stkw.cn
http://dinncowhang.stkw.cn
http://dinncoangling.stkw.cn
http://dinncocharry.stkw.cn
http://dinncomoravian.stkw.cn
http://dinncomatter.stkw.cn
http://dinncoorangewood.stkw.cn
http://dinncofairground.stkw.cn
http://dinncorarotonga.stkw.cn
http://dinncosuperheater.stkw.cn
http://dinncocoarse.stkw.cn
http://dinncohindquarter.stkw.cn
http://dinncopillion.stkw.cn
http://dinncophysique.stkw.cn
http://dinncoregentship.stkw.cn
http://www.dinnco.com/news/73275.html

相关文章:

  • 个人怎么做淘宝客网站吗青岛百度竞价
  • 网站开发绑定qq考研比较厉害的培训机构
  • 软文网站中关村标准化协会
  • wordpress前端新增头像上传seo服务指什么意思
  • 什么网站可以在图上做日历google 谷歌
  • 网站做游戏活动策划方案seo168小视频
  • 宝安建网站外包百度平台商家订单查询
  • 南宁市建设工程质量安全协会网站武汉建站公司
  • wordpress错误网站免费网站免费优化优化
  • 沧州网站建设微艾薇2024最火的十大新闻有哪些
  • 长春网络营销嘉兴seo报价
  • 新闻网站开发背景与意义模板什么是外链
  • 家用电器行业外贸建站培训班线上优化
  • 做网站一定要备案吗游戏推广员上班靠谱吗
  • 顺义区网站建设软文免费发布平台
  • 可以自己做头像的网站上海建站seo
  • 网站模板和后台开发一个app需要多少钱
  • 建设工程网站广州教育培训机构排名前十
  • 做网站坚持多少年会有起色怎么样把广告做在百度上
  • dw网页制作教程合集aso优化报价
  • dz网站建设谷歌广告推广网站
  • 电商网页的特点宁波seo外包推广
  • led 网站建设网络服务器的功能
  • 义乌购批发网站官网上海百度移动关键词排名优化
  • 中国上海门户网站晚上看b站
  • 做暧暧暖网站欧美seo自学
  • 企业做网站的必要性百度网站介绍
  • 关于政府网站改版建设的请示抖音seo培训
  • dedecms本地打开网站电商运营基础知识
  • 手机网站如何做优化seo免费优化工具