---
title: "基于机器学习(machine learning)的SEO实战日记6--训练集准备"
author: "黄国甫"
date: "2020-01-10T10:06:19Z"
tags: []
categories: ["互联网"]
slug: "machine-learning-seo-6"
draft: false
lastmod: "2020-01-10T10:07:35Z"
id: 2511887
url: "https://peter1981.iteye.com/blog/2511887"
---

有了关键词列表和关键词的词频后，我们接下来就可以着手准备训练数据集，以下是训练集的定义：

|表名：seo_train|
|表中文名：热词训练集表	|
|字段名称|字段类型|字段解释|
|keywords|varchar(100)|关键词|
|rw_url	|varchar(1000)	|关键词所在url|
|title_score	|decimal(8,4)	|在title中出现的次数|
|keyword_score	|decimal(8,4)	|在keywords中出现的次数|
|description_score	|decimal(8,4)|	在description中出现的次数|
|other_score	|decimal(8,4)	|在网页其他地方出现的次数|
|rw_position	|int	|url基于该关键的排名|



```sql

Create table seo_train(keywords varchar(100), rw_url varchar(1000),title_score decimal(8,4),   keyword_score decimal(8,4) , description_score decimal(8,4) , other_score decimal(8,4) ,rw_position int) character set utf8mb4 collate utf8mb4_bin;
```

**相关数据的生成逻辑如下：**
keywords字段基于表relative_hotwords中的keywords；
rw_url字段基于表relative_web中的rw_url
title_score、keyword_score、description_score、other_score字段从web_detail表的web_html字段中提取获得
rw_position字段基于keywords关键词从百度搜索中抓取。
由于表relative_hotwords的记录数较多，达到了4.7万，为了提高效率，对词做了过滤，筛选了6千个搜索热度排名高的词。搜索热度排名基于百度指数。
通过剔除重复的，最终我们获得表seo_train的数据量是7341条。
此处代码略，未完待续……