一个脚本打比赛之SMP WEIBO 2016

## 一个脚本打比赛之SMP WEIBO 2016 ## 前言:如何对用户进行精准画像是社交网络分析的基础问题。本文就如何对weibo用户网络提取特征发表一点小的想法,还请尽管拍砖。 数据来源:SMP WEIBO 2016 任务目标:分析用户关联关系与用户发帖内容,通过无监督与有监督方法对用户进行聚类。 ———- 第一部分:筛选source,即判定用户发表的内容是否是垃圾信息。
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import pandas as pd
import numpy as np
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.decomposition import LatentDirichletAllocation
from time import time
%matplotlib inline
训练数据字段含义: uid: 用户唯一标识,由数字组成 retweet count: 转发数,数字 review count: 评论数,数字 source: 来源,文本 time: 创建时间,时间戳文本(目前有两种格式,yyyy-MM-dd HH:mm:ss和yyyy-MM-dd HH:mm) content: 文本内容(可能包含@信息、表情符信息等)
with open('train/train/train_status.txt','r') as f:
    lines = f.readlines()
status=[]
for line in lines:
    status.append(line.strip().split(','))
tr_status = pd.DataFrame(status).loc[:,:5]
tr_status.columns=['uid','retweet','review','source','time','content']
tr_status.to_csv('train_status.csv',index=False)
display(tr_status.head())
with open('valid/valid_status.txt','r') as f:
    lines = f.readlines()
status=[]
for line in lines:
    status.append(line.strip().split(','))
v_status = pd.DataFrame(status).loc[:,:5]
v_status.columns=['uid','retweet','review','source','time','content']
v_status.to_csv('valid_status.csv',index=False)
display(v_status.head())
.dataframe thead tr:only-child th { text-align: right; } .dataframe thead th { text-align: left; } .dataframe tbody tr th { vertical-align: top; }
uid retweet review source time content
0 1103763581 0 0 Arduino中文社区 2016-01-07 13:14 我 用 微博 在 Arduino 中文 社区 上 登录 啦 ! Arduino 中文 社区 …
1 1103763581 0 2 荣耀6 Plus 2015-11-10 09:13:35 很 长 时间 没有 上 微博 看看 了 , 估计 都 快 被 忘记 了 吧 ! 无锡·新安 …
2 1103763581 0 0 荣耀6 Plus 2015-07-26 20:07:57 # 农村 现状 # 20 年 前 还是 个 小孩 , 一 到 瓜果 成熟 的 季节 , 三五…
3 1103763581 0 0 荣耀6 Plus 2015-06-22 18:39:47 我 分享 了 @环球时报 的 文章 社评 : 法国 出租 与 专车 司机 冲突 的 启示
4 1103763581 0 6 荣耀6 Plus 2015-06-10 07:37:22 好久 没 上 微博 了 , 不 知道 大家 还 记得 我 不 ? 梁家巷 显示 地图
.dataframe thead tr:only-child th { text-align: right; } .dataframe thead th { text-align: left; } .dataframe tbody tr th { vertical-align: top; }
uid retweet review source time content
0 1753249671 0 0 iPhone客户端 2016-05-06 10:01 扑通 扑通 我 的 心跳 ! 久久 不 能 平 …… 深 呼吸 、 深 呼吸 、 深 呼吸 !
1 1753249671 0
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值