SVM kernel 介绍 其实核函数和映射关系并不大,kernel可以看作是一个运算技巧。 一般认为,原本在低维线性不可分的数据集在足够高的维度存在线性可分的超
字符串的排列 题目: https://leetcode-cn.com/problems/permutation-in-string/ 思路: 滑动窗口加字典 代码: class Solution(object): def checkInclusion(self, s1, s2): counter1 = collections.Counter(s1) N = len(s2) left = 0 right = len(s1) - 1 counter2 = collections.Counter(s2[0:right]) while right < N: counter2[s2[right]] += 1 if counter1 == counter2: return True counter2[s2[left]] -= 1 if counter2[s2[left]] == 0: del counter2[s2[left]] left +=
类似于pandas的apply,就是在某一维上进行定义的函数操作 apply_along_axis(func1d, axis, arr, *args, **kwargs) 官网的例子 def my_func(a): return (a[0] + a[-1]) * 0.5 b = np.array([[1,2,3], [4,5,6], [7,8,9]]) np.apply_along_axis(my_func, 0, b) # 结果 array([ 4., 5., 6.]) # 结果 array([ 2.,
采购方案 题目: https://leetcode-cn.com/problems/4xy4Wx/ 思路: 题目很简单,思想就是双指针,感觉是个双指针的典型例子就写了下来 先对数组进行从小到大排序,然后双指针从两边移动,如果一直
位运算的一个应用 翻了翻以前用python刷leetcode的记录,最后刷的一道题是这样的 https://leetcode-cn.com/problems/single-number/ 叫只出现一次的数字,当时看题感觉非常简单啊!直接搞
import numpy as np from sklearn.model_selection import train_test_split,cross_val_score from sklearn import datasets from sklearn.neighbors import KNeighborsClassifier data = datasets.load_iris() X = data.data Y = data.target k_scores = [] for k in range(1,31): model = KNeighborsClassifier(n_neighbors=k) #scores = cross_val_score(model,X,Y,cv=10,scoring="accuracy") # for classification loss = -cross_val_score(model,X,Y,cv=10,scoring="neg_mean_squared_error") # for regression k_scores.append(loss.mean()) plt.plot(range(1,31),k_scores) plt.show()
概率图模型概述
B树 B树就是B-树,以前还以为这是两种树,现在才知道这俩就是一个东西。 基本概念 所有的叶子结点都出现在同一层上,并且不带信息(可以看做是外部结
和为s的连续正数序列 题目: https://leetcode-cn.com/problems/he-wei-sde-lian-xu-zheng-shu-xu-lie-lcof/ 思路: 滑动窗口即可,滑动窗口就是选取数组的一部分来进行操作,left 和 right只能向右移动 代码: class Solution: def findContinuousSequence(self, target: int) ->