Bei's Blog 
  • 首页
  • 归档
  • 分类
  • 标签
  • 关于
  • 笔记本
  • 友链
  • 添加友链
  •     

getUglyNumber

获取前N个丑数如果一个数的素因子只有 2,3,5 ,我们称它为丑数,1 是第一个丑数, 要求按大小输出前N个丑数 思路 每一个丑数都是由前面的某个丑数乘2,乘3, 或乘5得来 我们当然可以遍历前面所有丑数都分别乘 2、3、5 ,取其中的最小值来得到当前的丑数 一种很好的方法是选取前面若干丑数中最可能乘2产生当前丑数的数 a ,最可能乘 3 产生当前丑数的数 b, 和最可能乘 5 产生当前丑数的数 c ,取 2a,3b,5c 的最小值,就是当前丑数 如何选取并在遍历中更新 a, b, c : a,b,c 为前面已经求得的丑数 每次寻找丑数时用到的 a,b,c 在以后寻找丑数的过程中不能重复使用
 2019-01-09   Algorithms  NowCoder    uglyNumber 

ML调包指南

1. sklearn1.1 SVMimport sklearn.svm svc1 = sklearn.svm.LinearSVC(C=1, loss='hinge') svc1.fit(data[['X1', 'X2']], data['y']) svc1.score(data[['X1', 'X2']], data['y']) data['SVM1 Confidence'] = svc1.decision_function(data[['X1',
 2018-12-21   MachineLearning   

pythonDataStructure

ML中的数据结构1. numpy1. ndarray 多维数组1. 创建ndarray 是一个通用的同构数据容器,即其中的所有元素类型相同。当创建好一个ndarray数组是,同时会在内存中存储 ndarray 的shape 和dtype, shape是 ndarray 的维度大小的元组,dtype 是解释说明 ndarray 数据类型的对象。 data = [1,2,3] data = (1,2,3) data = [[1,2,3],[4,5,6]] arr = np.array(data) 2. zerosnp.zeros(3) np.zeros((3,4)) 3. onesnp.ones(
 2018-12-19   MachineLearning  Utils    python  dataStructure 

NLP_primer

NLP 入门字符串操作 .count() 方法返回特定的子串在字符串中出现的次数。 seq = '12345,1234,123,12,1' seq1 = '1' a = seq.count(seq1) a >> 5 .strip()方法可以去除字符串首尾的指定符号。无指定时,默认去除空格符 ‘ ‘ 和换行符 ‘\n’。 seq = ' hello world!' seq.strip() >>helloworld! seq.strip('!') >>helloworld seq.strip(
 2018-12-18   MachineLearning  NLP    NLP 

Lecture2-ImageClassificationPipeline

1. First classifier:Nearest Neighbor Classifier 数据集:CIFAR-10,提供10个label,50,000 个训练样本,10,000个测试样本。K-NN 中最重要的一个部分就是 距离的计算方法,下面是曼哈顿距离的计算方法。 import numpy as np class NearestNeighbor: def __init__(self): pass def train(self,X,y): '''X is NxD where each row is an examp
 2018-11-30   DeepLearning  CS231n    CS231n  ImageClassification 

Chapter18-LargeScaleMachingLearning

Chapter18-LargeScaleMachingLearning Stochastic gradient descent扩展阅读Chapter17-RecommenderSystemChapter16-AnomalyDetectionChapter15-DimensionalityReduction
 2018-11-28   MachineLearning  MLbyAndrewNg    ML 

Chapter17-RecommenderSystem

Chapter17-RecommenderSystemContent-based recommender systems Collaborative filtering Collaborative filtering algorithm这里 \(x \in R^n\) \(\theta \in R^n\) ,不设置截距项。 Vectorization: Low rank matrix factorization Implementational detail: Mean normalization 扩展阅读Chapter18-LargeScaleMachingLearningChap
 2018-11-23   MachineLearning  MLbyAndrewNg    ML 

Chapter16-AnomalyDetection

Chapter16-AnomalyDetectionGaussian distribution algorithm Developing and evaluating an anomaly detection system Anomaly detection vs. supervised learning Choosing what features to use Multivariate Gaussian distribution前一节介绍的高斯分布式基于单个变量 \(x^i\) ,当多个变量具有相关性的时候,对于测试样本的单个变量来说,符合高斯分布,模型就会误判定为正常样本。 Anoma
 2018-11-21   MachineLearning  MLbyAndrewNg    ML 

Chapter15-DimensionalityReduction

Chapter15-DimensionalityReductionPCA -principal component analysis找到一个低维的平面,来对数据进行投影,以便最小化投影误差的平方,以及最小化每个点,与投影后的对应点之间距离的平方。 choose K compressed representa1on X_{approx} = U_{reduce}Z (\(X{approx} \in R^{nx1}\),\(U{reduce}\in R^{nxk}\),\(Z\in R^{kx1}\)) Advice for applying PCA扩展阅读Chapter18-LargeScal
 2018-11-21   MachineLearning  MLbyAndrewNg    ML 

Chapter14-Clustering

K-means algorithminput: K (number of clusters) Training set \((x^{(1)},x^{(1)},…,x^{(1)})\) \(x^{(i)} \in R^n(drop x_0=1 convention)\) Optimization Objective Random initialization choose the number of clusters 扩展阅读Chapter18-LargeScaleMachingLearningChapter17-RecommenderSystemChapter16-AnomalyDet
 2018-11-16   MachineLearning  MLbyAndrewNg    ML  clustering 
1…910111213

搜索

Hexo Fluid
总访问量 次 总访客数 人