删除排序数组中的重复项
删除排序数组中的重复项 删除排序数组中的重复项1 题目: https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/ 思路: 双指针,定义 nums[0...i] 为为非重复数列,遍历整个数列不断的维护这个定义 代码: class Solution: def removeDuplicates(self,
asyncio
import threading import time 多线程例子 def spider(): #..... time.sleep(0.02) def main1(): for i in range(100): spider() def main2(): thread_list = [] for i in range(100): thread = threading.Thread(target = spider) thread.start() thread_list.append(thread) for t in thread_list: t.join() if __name__ == "__main__": start = time.time() main1() end = time.time() print("time1 :{:.4f}".format(end-start)) start = time.time() main2() end = time.time() print("time2 :{:4f}".format(end-start)) time1 :2.0523 time2 :0.037929 yield def fib(n):
移除元素
移除元素 还是以前刷过的题 https://leetcode-cn.com/problems/remove-element/ 以前的思路早忘了 然后我重新做了一下,一开始就一行代码 class Solution: def removeElement(self, nums: List[int], val: int) -> int: return len(list(filter(lambda x:x!=val,nums))) 然后发现输出和正确输出不一样。于是
Decision Tree
import numpy as np import matplotlib.pyplot as plt import pandas as pd dataset = pd.read_csv('./datasets/Social_Network_Ads.csv') X = dataset.iloc[:, [2, 3]].values y = dataset.iloc[:, 4].values from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0) from sklearn.preprocessing import StandardScaler sc = StandardScaler() X_train = sc.fit_transform(X_train) X_test = sc.transform(X_test) from sklearn.tree import DecisionTreeClassifier classifier = DecisionTreeClassifier(criterion = 'entropy', random_state = 0) classifier.fit(X_train, y_train) DecisionTreeClassifier(criterion='entropy', random_state=0) classifier.
TextRank
参考:https://blog.csdn.net/asialee_bird/article/details/96894533 TextRank
关键词提取
文本关键词提取 参考:https://blog.csdn.net/asialee_bird/article/details/96454544 概
pyplot
matplotlib.pyplot学习 绘图标记 import matplotlib.pyplot as plt import numpy as np ypoints = np.array([1,3,4,5,8,9,6,1,3,4,5,2,4]) plt.plot(ypoints, marker = 'o') # "o"代表实心圆 plt.show() maker可用的符号如下
机器学习的一些概念
范数的定义 \[ {\lVert x \rVert}_p := \left(\sum_{i=1}^n{\lvert x_i\rvert}^p\right)^{\frac{1}{p}} \] 标准化与归一化 定义 归一化和标准化都是对数据做变换的方式,将原始的一列数据转换到某个范围,或者某种形态。 >归一
交叉熵损失函数
Softmax理解 主要记录了在使用softmax这个函数中遇到的一些问题,比较基础,但确实困扰了一段时间。 在学习word2vec中, 使用的一