05 2021 档案

摘要:利用高斯函数,使得较近的数据点决策作用更大! 代码也比较简洁!Accuracy=0.9466666666666667 注意一下: 其实h=1的选取相当于你的先验知识;或者说多尝试几次 让电脑自己试错,有时候其实方法直接的界定其实没有那么严格啦 1 import numpy as np 2 from 阅读全文
posted @ 2021-05-28 18:08 墨鳌 阅读(264) 评论(0) 推荐(0)
摘要:借鉴了老师的代码,但是没有封装 效果还是挺好的 average accuracy>90% 1 from random import shuffle 2 import numpy as np 3 from collections import Counter 4 5 6 def read(path: 阅读全文
posted @ 2021-05-28 15:07 墨鳌 阅读(163) 评论(0) 推荐(0)
摘要:[K-means Algorithm][3D子图] 由于K-means Algorithm是基于随机点选取的, 所以可能结果较差,甚至RE ! ! ! 1 import numpy as np 2 import random 3 import matplotlib.pyplot as plt 4 f 阅读全文
posted @ 2021-05-27 18:25 墨鳌 阅读(125) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2021-05-22 23:59 墨鳌 阅读(3) 评论(0) 推荐(0)
摘要:结构体自定义排序函数,调用stdlib.h库的系统快速排序qsort 1 //sjf non-preemptive with same arrival time 2 3 #include<stdio.h> 4 #include<stdlib.h> 5 #define N 5010 6 7 struc 阅读全文
posted @ 2021-05-22 21:25 墨鳌 阅读(111) 评论(0) 推荐(0)
摘要:这里直接是一个二分类,比较简单 本质上就是把各个事件看成独立的,概率分别计算,概率相乘求出条件概率(后验概率) 然后为了防止概率过小,取log,连乘变为连加,即求和 网页上相关的资料很多,这里就不再赘述了,直接上代码: 推荐视频: https://www.bilibili.com/video/BV1 阅读全文
posted @ 2021-05-21 12:29 墨鳌 阅读(147) 评论(0) 推荐(0)
摘要:1 import java.io.BufferedReader; 2 import java.io.FileReader; 3 4 public class TestRead { 5 6 public static void main(String[] args) { 7 try { 8 Buffe 阅读全文
posted @ 2021-05-20 22:09 墨鳌 阅读(146) 评论(0) 推荐(0)
摘要:1 import numpy as np 2 from sklearn.manifold import TSNE 3 import matplotlib.pyplot as plt 4 from mpl_toolkits.mplot3d import Axes3D 5 6 7 def read(pa 阅读全文
posted @ 2021-05-20 20:57 墨鳌 阅读(95) 评论(0) 推荐(0)
摘要:1 import numpy as np 2 3 4 def update(a: int, b: int, c: int) -> tuple: 5 if a > b and a > c and a > 0: 6 return a, "↖" 7 if b > a and b > c and b > 0 阅读全文
posted @ 2021-05-20 17:18 墨鳌 阅读(75) 评论(0) 推荐(0)
摘要:1 import numpy as np 2 3 4 def update(a: int, b: int, c: int) -> tuple: 5 if a > b and a > c: 6 return a, "↖" 7 if b > a and b > c: 8 return b, "↑" 9 阅读全文
posted @ 2021-05-20 17:09 墨鳌 阅读(67) 评论(0) 推荐(0)
摘要:1 import numpy as np 2 3 4 def LCS(X: str, Y: str) -> tuple: 5 n, m = len(X), len(Y) 6 dp = [[0 for col in range(m + 1)] for row in range(n + 1)] 7 fl 阅读全文
posted @ 2021-05-19 14:54 墨鳌 阅读(55) 评论(0) 推荐(0)
摘要:1 INF = 10000 2 3 4 def getGraph() -> tuple: 5 G = [ 6 #a b c d e 7 [0, 4, 5, 0, 0], # a 8 [0, 0, 0, 8, 0], # b 9 [0, 0, 0, 0, -7], # c 10 [0, 0, 0, 0 阅读全文
posted @ 2021-05-19 14:38 墨鳌 阅读(54) 评论(0) 推荐(0)
摘要:1 def horsepool(S: str, P: str) -> tuple: 2 n, m, M = len(S), len(P), 26 3 shift_table = [m for _ in range(M)] 4 for i in range(m - 1): 5 shift_table[ 阅读全文
posted @ 2021-05-19 14:19 墨鳌 阅读(92) 评论(0) 推荐(0)
摘要:1 import numpy as np 2 3 4 def sign(x: float) -> int: 5 if x > 0: 6 return 1 7 elif x < 0: 8 return -1 9 else: 10 return 0 11 12 13 def f(w, x, b) -> 阅读全文
posted @ 2021-05-11 16:57 墨鳌 阅读(99) 评论(0) 推荐(0)
摘要:5折交叉验证,测试10次,取平均值: 1 import random 2 3 4 def read(path: str) -> tuple: 5 with open(path, "r") as f: 6 text = f.readlines() 7 M = [] 8 for row in text: 阅读全文
posted @ 2021-05-10 16:46 墨鳌 阅读(71) 评论(0) 推荐(0)
摘要:Python 信息熵-条件熵计算 1 import csv 2 import numpy as np 3 4 5 def read(path: str) -> tuple: 6 with open(path, 'r') as f: 7 text = csv.reader(f) 8 A = [] 9 阅读全文
posted @ 2021-05-10 15:28 墨鳌 阅读(84) 评论(0) 推荐(0)
摘要:也就两个部分: Node: 1 package models.BST; 2 3 public class BSTNode<E extends Comparable<E>> { 4 E data; 5 BSTNode<E> leftChild, rightChild; 6 7 public BSTNo 阅读全文
posted @ 2021-05-07 00:22 墨鳌 阅读(113) 评论(0) 推荐(0)