自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(5)
  • 问答 (5)
  • 收藏
  • 关注

原创 nltk情感分析、文本相似度、文本分类

import nltkfrom nltk.stem import WordNetLemmatizerfrom nltk.corpus import stopwordsfrom nltk.classify import NaiveBayesClassifiertext1 = 'I like the movie so much!'text2 = 'That is a good movie.'text3 = 'This is a great one.'text4 = 'That is a real

2020-09-26 13:37:50 2126

原创 英文分词nltk进行文本清洗

import nltknltk.download('punkt')#一个默认的方法,也可以用别的方法下载后可能会提示unzipped什么的,不用管,再运行一遍会发现已经satisfied了import nltksentence="python is a widely use high-level programing language"tokens=nltk.word_tokenize(sentence)print(tokens)结果:[‘python’, ‘is’, ‘a’, ‘wide

2020-09-23 20:25:13 1080

原创 聚类模型kmeans算法python实现

#main.pyimport randomfrom kmeans_tools import Cluster, get_distance, gen_random_sampleimport matplotlib.pyplot as pltfrom matplotlib import colors as mcolorsdef kmeans(samples, k, cutoff): """ kmeans函数 """ # 随机选k个样本点作为初始聚类中心

2020-09-19 15:06:16 256

原创 python读取多种格式文件(txt,csv,json,sqlite)

1、txt①读取全部内容txt_filename = './files/python_baidu.txt'# 打开文件file_obj = open(txt_filename, 'r', encoding='utf-8')# 读取整个文件内容all_content = file_obj.read()# 关闭文件file_obj.close()print(all_content)②按行读取txt_filename = './files/python_baidu.txt'# 打开文件

2020-09-18 20:21:32 484

原创 leetcode【简单】1、两数之和

题目:给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。解法1:暴力解法,两层遍历,第二层只需遍历第一层取的数以后的数,用时6440msclass Solution: def twoSum(self,nums,target): n = len(nums) for x in range(n): for y in range(x+1,n):

2020-09-18 15:57:02 61

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除