Skip to content

Instantly share code, notes, and snippets.

View iphysresearch's full-sized avatar
🏛️
researching .....

He Wang iphysresearch

🏛️
researching .....
View GitHub Profile
@iphysresearch
iphysresearch / C2_winfun_time.py
Last active June 2, 2020 04:30
Chapter 2 - Window functions (time domain)
import numpy as np
from scipy.signal import triang, tukey
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(context='paper',
style='ticks',
font_scale=1,
rc={'figure.figsize': (8, 5),
'figure.dpi': 100, # need fixed

ROC 全称是“受试者工作特征”(Receiver Operating Characteristic)曲线。体现了不同算法在不同任务下“期望泛化性能”的好坏。

ROC 曲线与画 P-R 曲线的方法完全一样,唯一的区别排序计算的坐标轴改为了“真正例率”(True Postitve Rate,TPR) 和“假正例率”(False Positive Rate,FPR):


真实情况 预测结果 预测结果
正例 反例
正例 TP(真正例) FN(假反例)
@iphysresearch
iphysresearch / GroupNeighbor.py
Created August 9, 2019 01:54
Group Neighbor Elements
def GroupNeighbor(l):
"""
Eg: Input <= np.array
l = np.array([58,59,
87,98,
101,102,103,104,
111,122,
133,134,135,136])
GroupNeighbor(l) = [[58, 59],
[101, 102, 103, 104],
@iphysresearch
iphysresearch / Q1.py
Created February 26, 2019 09:15
[Spiral Memory]
## Spiral Memory
# You come across an experimental new kind of memory stored on an infinite two-dimensional grid.
# Each square on the grid is allocated in a spiral pattern starting at a location marked 1 and then counting up while spiraling outward. For example, the first few squares are allocated like this:
# 17 16 15 14 13
# 18 5 4 3 12
# 19 6 1 2 11
# 20 7 8 9 10
@iphysresearch
iphysresearch / redis_demo.py
Last active January 10, 2019 08:18
[Redis-py 3.0 demo] a demo for Redis-py 3.0 (http://gree2.github.io/python/2016/05/14/python-with-docker-redis) #redis #demo #python
#! usr/bin/python
#coding=utf-8
# http://gree2.github.io/python/2016/05/14/python-with-docker-redis
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys, os, time
@iphysresearch
iphysresearch / test.ipynb
Last active December 24, 2018 08:37
[test] des... #pynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iphysresearch
iphysresearch / min-char-rnn.py
Last active May 3, 2018 03:42 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O 输入训练数据
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars) # 字符数目和单词数目
@iphysresearch
iphysresearch / Plot_s_dbw_part1.py
Last active April 10, 2018 13:50
Plot_s_dbw.py
import numpy as np
import S_Dbw as sdbw
from sklearn.cluster import KMeans
from sklearn.datasets.samples_generator import make_blobs
from sklearn.metrics.pairwise import pairwise_distances_argmin
np.random.seed(0)
S_Dbw_result = []
batch_size = 45
@iphysresearch
iphysresearch / S_Dbw.py
Created April 10, 2018 13:46
S_Dbw_part5.py
def S_Dbw_result(self):
"""
compute the final result
"""
return self.Dens_bw()+self.Scat()
@iphysresearch
iphysresearch / S_Dbw.py
Last active April 10, 2018 14:09
S_Dbw_part4.py
def Scat(self):
# 分母部分:
sigma_s = np.std(self.data,axis=0)
sigma_s_2norm = np.sqrt(np.dot(sigma_s.T,sigma_s))
# 分子部分:
sum_sigma_2norm = 0
for i in range(self.k):
matrix_data_i = self.data[self.data_cluster == i]
sigma_i = np.std(matrix_data_i,axis=0)