编辑距离 定义 编辑距离(Edit Distance)是针对两个字符串S1和S2的差异程度进行量化,计算方式是看至少需要多少次的处理才能将S1变成
因子分析 可以看成主成分分析(PCA)的发展和拓展 如果数据之间有较强的相关性,我们就可以把它们打包到一起作为一个值。这就是所谓的数据降维。 有较
# 练习1-具有神经网络思维的Logistic回归 1 数据预处理 1.1 数据加载和查看 在开始之前,我们有需要引入的库: numpy :是用Python进行科学计算
通过sklearn模块实现 import numpy as np import matplotlib.pyplot as plt from sklearn import metrics from sklearn.datasets import make_blobs from sklearn.cluster import KMeans from sklearn.datasets import load_iris %matplotlib inline X,y = make_blobs(n_samples=100,n_fe
翻转二叉树 开始学习二叉树了 先来个简单题 https://leetcode-cn.com/problems/invert-binary-tree/ 很简单 # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def invertTree(self, root: TreeNode) -> TreeNode: if root == None: return None temp = root.left root.left = root.right root.right
对称二叉树 题目: https://leetcode-cn.com/problems/symmetric-tree/ 思路: 利用双向队列,每次把对称的两个对应的节点放入队列中,然后取出来比较,如果值不相等则返回false,如果一边为空 一边不
合并两个有序列表 题目: https://leetcode-cn.com/problems/merge-two-sorted-lists/ 思路: 利用递归的思想,比较两个当前值,因为是有序链表 代码: # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode)
关于损失函数的问题,之前也有很多疑惑。看了网上的很多博客,有从很多角度出发来讲解的,看的也是云里雾里。现在大致做一下整理。 对于最小二乘,为什
协同过滤是推荐系统里面一个常用的算法,因为信息检索领域和推荐系统领域其实是有点相似的(对我目前的认知来说,对两个领域的了解都不深),所以就把
可获得的最大点数 题目: https://leetcode-cn.com/problems/maximum-points-you-can-obtain-from-cards/ 思路: 滑动窗口题目,限定窗口大小然后滑动即可 代码: class Solution: def maxScore(self, cardPoints: List[int], k: int) -> int: n = len(cardPoints) # 滑动窗口大小为 n-k windowSize = n - k # 选前 n-k 个作