![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
机器学习实验
文章平均质量分 50
solumin
朝闻道
展开
-
多核支持向量机实践
定义多核def rbf(gamma=1.0): def rbf_fun(x1,x2): return math.exp((np.linalg.norm(x1-x2))*(-1.0*gamma)) return rbf_fundef lin(offset=0): def lin_fun(x1,x2): return x1.dot(x2.transpose())+offset r...原创 2020-01-05 11:14:50 · 1885 阅读 · 10 评论 -
使用keras的Tokenizer进行文本预处理
from keras.preprocessing import text#facts, accu_label, article_label, imprison_label=load_data()somestr = ['ha ha gua angry','howa ha gua excited naive']tok=text.Tokenizer() #初始化标注器tok.fit_on_te...原创 2019-08-31 15:19:31 · 3885 阅读 · 0 评论 -
文本挖掘流水线
爬虫整体思路爬取xxx评论,爬取网页后从html页面中把需要的字段信息(顾客id、评论时间、评分、评论内容、口味、环境、服务、店铺ID)提取出来并存储到MYSQL数据库中。网页爬取和解析数据存储使用MYSQL数据库,安装教程参考菜鸟教程,python连接MYSQL数据推荐使用pymysql,同样是推荐菜鸟教程菜鸟教程。我们需要先建立一个数据库和表,然后连接并定义游标,然后写对应的sql语...原创 2019-08-31 12:09:15 · 165 阅读 · 0 评论 -
文本分类基础demo
读取停词表N=4774def stop_words(): stop_words_file = open('stop_words_ch.txt', 'r') stopwords_list = [] for line in stop_words_file.readlines(): stopwords_list.append(line.decode('gbk'...原创 2019-08-31 12:08:21 · 445 阅读 · 0 评论 -
基于textCNN的法律文本分类(keras)
数据载入def load_data(): train_fname='test_data/data_valid.json' """ load data from local file """ facts = [] accu_label = [] article_label = [] imprison_label = [] k=0 wi...原创 2019-08-31 12:04:25 · 1285 阅读 · 2 评论 -
使用SVM和Word2Vec进行情感分类
得到句子分词后的结果,并把类别标签保存为y_train.npy,y_test.npy# 加载文件,导入数据,分词def loadfile(): neg=pd.read_excel(config.NEG_PATH,header=None,index=None) pos=pd.read_excel(config.POS_PATH,header=None,index=None) ...原创 2019-08-31 12:00:52 · 10167 阅读 · 7 评论 -
使用文本卷积神经网络,并使用MovieLens数据集完成电影推荐的任务
使用文本卷积神经网络,并使用MovieLens数据集完成电影推荐的任务import pandas as pdfrom sklearn.model_selection import train_test_splitimport numpy as npfrom collections import Counterimport tensorflow as tfimport osimpor...原创 2019-08-29 09:24:29 · 2863 阅读 · 2 评论 -
Windows 7 64位 配置PSI-Blast 生成PSSM矩阵
blast+的本地化构建1.1程序下载 链接到:ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/1.2安装流程建议安装在非系统盘,如将下载的 BLAST 程序安装到 E:\blast,生成 bin、doc 两个子目录,其中 bin 是程序目录,doc是文档目录,这样就安装完毕了。1.3用户环境变量设置右 键点...原创 2018-12-04 09:45:57 · 1835 阅读 · 0 评论 -
PSSP之特征提取(PSSP protein secondary structure prediction)
PSSP之特征提取(PSSP protein secondary structure prediction)One-hot encoding AACPSSM encodingSVM 分类优化之特征清洗One-hot encoding AAC维度为20+3(BXZ)。PSSM encodingfasta文件psi-blast程序+protein db(nr db 40G 下载失败 uni...原创 2018-12-25 11:30:33 · 997 阅读 · 1 评论 -
在极客云的GPU 上成功让textcnn跑起来
期间遇到的问题我来整理一下版本不兼容,注意,我在本机上做实验,用的tf和keras分别是1.40.和2.1.5,在云服务器上一开始爆出了“sofmax的axis的问题,解决方法就是修改版本tf修改为1.4.0keras修改为2.0.8,结果不再报错我以前的tensorflow版本是1.4.1和keras版本2.1.5。降级到tensorflow版本1.4.0和keras版本...原创 2019-03-06 09:48:33 · 845 阅读 · 2 评论 -
py2-py3.4 Debug 过程记录 for text_classification_AI100
part one data_process.pypart one data_process.py1、for line in stop_words_file.readlines(): stopwords_list.append(line.decode('gdk')[:-1])改为for line in stop_words_file.readlines(): ...原创 2019-03-06 09:46:45 · 87 阅读 · 0 评论 -
把终端打印的信息保存为日志文件
#把这三行代码放在程序前import sysf_handler=open('out.log', 'w')sys.stdout=f_handler#另一种方法 只是记录系统的运行信息#日志import logging# 通过下面的方式进行简单配置输出方式与日志级别logging.basicConfig(filename='logger.log', level=logging....原创 2018-12-25 11:10:18 · 1305 阅读 · 0 评论 -
记录程序运行时间
import datetimestart_time=datetime.datetime.now()#long running content#end_timeend_time=datetime.datetime.now()print((end_time-start_time).seconds)原创 2018-12-25 11:10:34 · 390 阅读 · 0 评论 -
彻底解决matplotlib中文乱码问题
首先将windwos中fonts目录下的simhei.ttf拷贝到/home/hadoop/.pyenv/versions/2.7.10/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf(文件路径参考1.c,根据实际情况修改)目录中,然后删除~/.cache/matplotlib的缓冲目录第三在代码中动态设置参数...原创 2019-03-06 09:45:23 · 775 阅读 · 0 评论 -
训练模型的保存与恢复
from sklearn.externals import joblibimport osos.chdir('E:/Academic/Graduation thesis/dataset/train file')joblib.dump(grid_search,'grid_search_model.m')clf=joblib.load('grid_search_model.m')...原创 2018-12-25 11:09:39 · 595 阅读 · 0 评论