自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Eminem1147的博客

NJU SE Master

  • 博客(217)
  • 收藏
  • 关注

原创 Softmax算法实现

数据集MNIST。#!/usr/bin/env python3# -*- coding: utf-8 -*-import timeimport mathimport randomimport numpy as npimport pandas as pdfrom sklearn.model_selection import train_test_splitclass S...

2018-11-11 23:01:25 557

原创 统计学习方法_隐马尔可夫模型HMM实现

这里用到的数据集是三角波,使用长度20的序列训练100次,生成长度为100的序列。HMM的初始化非常重要,这里采用随机初始化。#!/usr/bin/env python3# -*- coding: utf-8 -*-import csvimport randomimport numpy as npimport matplotlib.pyplot as pltclass HM...

2018-11-07 14:09:54 413

原创 统计学习方法_AdaBoost算法实现

这里用的是二值化的MNIST,同时将特征的值也二值化了。书上举的例子特征只有一维,但大多数情况下特征不会只有一维,这里每次都会遍历最优切分特征和最优切分点,弱分类器选择最简单的阈值分类器,对于每个弱分类器都有与其对应的切分特征和切分点,在预测的时候将预测数据也只使用需要的特征值即可。#!/usr/bin/env python3# -*- coding: utf-8 -*-import ...

2018-11-02 15:14:42 328

原创 统计学习方法_最大熵模型实现

使用的是二分类的MNIST,注意为了区别不同的特征,给它们加上了x0、x1。注意f(x,y)的含义。最后运行时间很长,最大熵模型更适合小数据集。#!/usr/bin/env python3# -*- coding: utf-8 -*-import timeimport mathimport randomimport numpy as npimport pandas as pd...

2018-10-30 21:09:05 464

原创 TensorFlow_线性回归实现

数据集和前面一篇一样。#!/usr/bin/env python3# -*- coding: utf-8 -*-import numpy as npimport tensorflow as tfimport matplotlib.pyplot as pltif __name__ == '__main__': # 给参数赋值 learning_rate = 0.0...

2018-10-23 20:33:26 195

原创 TensorFlow_NearestNeighbour实现

数据集来自MNIST。#!/usr/bin/env python3# -*- coding: utf-8 -*-import input_dataimport numpy as npimport tensorflow as tfif __name__ == '__main__': mnist = input_data.read_data_sets('/tmp/data...

2018-10-23 20:31:32 195

原创 统计学习方法_逻辑回归实现

数据集使用了类别仅两种的MNIST。#!/usr/bin/env python3# -*- coding: utf-8 -*-import timeimport mathimport randomimport numpy as npimport pandas as pdfrom sklearn.cross_validation import train_test_split...

2018-10-22 19:53:09 201

原创 统计学习方法_决策树实现

这个使用了像素点二值化的MNIST,重点理解递归子树的构造过程。#!/usr/bin/env python3# -*- coding: utf-8 -*-import cv2import timeimport numpy as npimport pandas as pdfrom sklearn.cross_validation import train_test_split...

2018-10-22 14:55:56 202

原创 统计学习方法_支持向量机SVM实现

由于在MNIST上运行SVM耗时过久,所以这里使用了伪造的数据集,并使用线性核和多项式核进行实验。#!/usr/bin/env python3and# -*- coding: utf-8 -*-import timeimport randomimport loggingimport pandas as pdfrom generate_dataset import *cl...

2018-10-20 15:16:23 224

原创 统计学习方法_朴素贝叶斯算法实现

使用的数据集和上一个算法一样,都是完整的MNIST,这里为了简化循环的计算量,将整个图片二值化,同时为了避免浮点数连续相乘和避免出现除以0,用了一些小trick。重点要理解三维数组的条件概率。#!/usr/bin/env python3# -*- coding: utf-8 -*-import timeimport randomimport numpy as npimport pa...

2018-10-15 20:37:48 342

原创 统计学习方法_kNN实现

数据集与上一篇文章不同,可以使用完整的MNIST数据集了,下载地址:MNIST#!/usr/bin/env python3# -*- coding: utf-8 -*-import numpy as npimport pandas as pdimport timeimport cv2from sklearn.cross_validation import train_test_s...

2018-10-15 09:45:55 180

原创 统计学习方法_感知机实现

数据集为二值化的MNIST,下载地址:MNIST#!/usr/bin/env python3# -*- coding: utf-8 -*-import numpy as npimport pandas as pdimport timeimport cv2from sklearn.cross_validation import train_test_split# 提取hog...

2018-10-14 22:59:25 146

原创 CS231n assignment 代码 + 笔记

CS231n 代码 + 笔记:我的GitHub

2018-10-04 13:13:26 607

转载 机器学习经典论文

以下内容来自转载:Active LearningTwo Faces of Active Learning756, Dasgupta, 2011 Active Learning Literature Survey155, Settles, 2010   ApplicationsA Survey of Emerging Approaches to Spam Filtering157...

2018-09-16 11:07:28 560

转载 EM算法

以下内容来自转载:1. 摘要EM(Expectation-Maximum)算法也称期望最大化算法,曾入选“数据挖掘十大算法”中,可见EM算法在机器学习、数据挖掘中的影响力。EM算法是最常见的隐变量估计方法,在机器学习中有极为广泛的用途,例如常被用来学习高斯混合模型(Gaussian mixture model,简称GMM)的参数;隐式马尔科夫算法(HMM)、LDA主题模型的变分推断等等。本...

2018-09-05 18:55:36 491

原创 LeetCode 015 3Sum

Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not cont...

2018-09-01 16:18:12 124

原创 LeetCode 014 Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".class Solution { public String longestCommonPrefi...

2018-09-01 14:47:41 116

原创 kaggle_Titanic_特征工程 数据清洗 SVC

以下代码参考自:Titanic best working Classifier提交上去score为0.79904# 学习特征工程# Learn Feather Engineering%matplotlib inlineimport numpy as npimport pandas as pdimport re as retrain = pd.read_csv('./inp...

2018-08-17 16:39:47 656

转载 Python Sklearn数据集划分函数StratifiedShuffleSplit

以下内容来自转载:文章开始先讲下交叉验证,这个概念同样适用于这个划分函数1.交叉验证(Cross-validation) 交叉验证是指在给定的建模样本中,拿出其中的大部分样本进行模型训练,生成模型,留小部分样本用刚建立的模型进行预测,并求这小部分样本的预测误差,记录它们的平方加和。这个过程一直进行,直到所有的样本都被预测了一次而且仅被预测一次,比较每组的预测误差,选取误差最小的那一组作为训...

2018-08-16 20:47:36 1218

原创 取消MacOS的SIP机制

jupyter notebook的字体太小,于是我打算安装jupyterthemes解决这个问题,但安装过程中发现了很多问题:1. 安装速度极慢,使用清华的源即可解决:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyterthemes2. ...has requirement six=1.9.0,but you ...

2018-08-09 16:23:57 2024 1

原创 LeetCode 013 Roman to Integer

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.For example, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, which ...

2018-08-08 14:55:13 108

原创 LeetCode 012 Integer to Roman

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.For example, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, which ...

2018-08-07 23:07:40 95

原创 LeetCode 011 Container With Most Water

Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two...

2018-08-07 22:04:08 96

转载 极大似然估计

以下来自转载:极大似然估计        以前多次接触过极大似然估计,但一直都不太明白到底什么原理,最近在看贝叶斯分类,对极大似然估计有了新的认识,总结如下:贝叶斯决策        首先来看贝叶斯分类,我们都知道经典的贝叶斯公式:        其中:p(w):为先验概率,表示每种类别分布的概率;:类条件概率,表示在某种类别前提下,某事发生的概率;而为后验概率,表示某事发生了,并且它属于某一类别...

2018-04-09 18:51:36 262 1

原创 LeetCode 010 Regular Expression Matching

 Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire inpu...

2018-03-31 20:09:02 128

原创 LeetCode 009 Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the intege...

2018-03-10 14:57:12 150

原创 LeetCode 008 String to Integer (atoi)

Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases....

2018-02-19 14:01:22 210

原创 LeetCode 007 Reverse Integer

Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we are dealing with an envi...

2018-02-18 21:39:03 155

原创 LeetCode 006 ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I I G...

2018-02-18 21:09:40 130

原创 LeetCode 005 Longest Palindromic Substring

Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: "babad"Output: "bab"Note: "aba" is also a valid answer. Example:I...

2018-02-18 18:00:21 123

原创 LeetCode 004 Median of Two Sorted Arrays 二分 + 递归

 There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 = [1...

2018-02-16 21:22:32 231

原创 LeetCode 003 Longest Substring Without Repeating Characters O(n)做法

 Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "b", w...

2018-02-16 14:27:02 112

原创 LeetCode 002 Add Two Numbers

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...

2018-02-14 14:53:34 128

原创 LeetCode 001 Two Sum O(nlogn)做法

Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same el...

2018-02-13 16:04:11 384

转载 Alias method 别名算法

以下内容来自转载:因为需要用到Alias Sampling Method的方法,但是查了一下,发现没有找到靠谱的关于Alias Method的中文介绍,所以干脆自己写一个好了。 关于Alias Method的介绍的比较好的是一个外国Blog:Darts, Dice, and Coins: Sampling from a Discrete Distribution,以下的介绍也主要参

2018-01-27 18:45:02 7099

转载 模拟退火算法

以下内容来自转载:著名的模拟退火算法,它是一种基于蒙特卡洛思想设计的近似求解最优化问题的方法。 一点历史——如果你不感兴趣,可以跳过     美国物理学家 N.Metropolis 和同仁在1953年发表研究复杂系统、计算其中能量分布的文章,他们使用蒙特卡罗模拟法计算多分子系统中分子的能量分布。这相当于是本文所探讨之问题的开始,事实上,模拟退火中常常被提到的

2017-12-22 21:31:38 640

转载 $.ajax()

以下内容来自转载:jquery中的ajax方法参数总是记不住,这里记录一下。 1.url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址。2.type: 要求为String类型的参数,请求方式(post或get)默认为get。注意其他http请求方法,例如put和delete也可以使用,但仅部分浏览器支持。3.timeout: 

2017-12-07 19:50:48 131

转载 Eclipse添加GBK编码

以下内容来自转载:首先Windows->Preferences, 然后选择General下面的Workspace. Text file encoding选择Other GBK, 如果没有GBK的选项, 没关系, 直接输入GBK三个字母, Apply, GBK编码的中文, 已经不是乱码了

2017-12-04 21:28:38 6467 3

转载 Eclipse配色(保护眼睛)

以下内容来自转载:eclipse色彩主题主要内容:1.下载和安装color theme插件2.编辑区色彩主题设置3.工作目录色彩设置4.自定义配色一、下载和安装color theme插件(如已存在此插件直接进行第二步)查看你的eclipse是否已经存在此插件:点击eclipse菜单栏上的Window ->p

2017-12-04 19:44:01 890

原创 Java JSON解析

解析嵌套JSON的时候一定要看清楚:{ "results": [{ "location": { "id": "C23NB62W20TF", "name": "西雅图", "country": "US", "timezone": "America/Los_Angeles", "timezone_offset": "-07:00"

2017-11-06 19:38:57 187 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除