- 博客(28)
- 收藏
- 关注
原创 牛客网合唱团
n = 3arr = [7,4,7]K,D = 2,50fm = [([0] * n) for i in range(K)] # k*dfn = [([0] * n) for i in range(K)] # k*dres = 0# for i in range(n):# fm[0][i] = arr[i]# fn[0][i] = arr[i]## fo...
2018-11-07 09:31:23
264
原创 407. Trapping Rain Water II(python shixian)
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.The above elevation map is represented by array [0...
2018-05-28 20:31:14
292
原创 齐普夫定律的验证-----Python实现(北航研究生自然语言处理课程作业)
本次作业采用的数据集是1956年至1960年的人民日报数据集。数据集链接:https://pan.baidu.com/s/12TRzzev7XhwY4ph1cKIYpw 密码:3g7v齐普夫定律验证齐普夫定律是美国学者G.K.齐普夫于20世纪40年代提出的词频分布定律。它可以表述为:如果把一篇较长文章中每个词出现的频次统计起来,按照高频词在前、低频词在后的递减顺序排列,并用自然数给这些词编上等级...
2018-04-02 23:37:41
3949
2
原创 机器学习实战(10) ——K均值聚类算法(python实现)
这是学习机器学习算法实战这本书时,写的代码实战。让自己对各个算法有更直观的了解,不能一直不写啊。不管简单还是不简单都亲自一行一行的敲一遍啊。具体的源码和和数据链接:https://pan.baidu.com/s/1G2S2pb5gfBnxGNNTFgTkEA 密码:fov0这个第十章的代码和自己做的测试kMeans.py .这章代码较少,但后面的调用雅虎接口一直调不通。# -*- coding: ...
2018-04-02 23:06:36
589
原创 机器学习实战(9) ——树回归(python实现)
这是学习机器学习算法实战这本书时,写的代码实战。让自己对各个算法有更直观的了解,不能一直不写啊。不管简单还是不简单都亲自一行一行的敲一遍啊。具体的源码和和数据链接:https://pan.baidu.com/s/1G2S2pb5gfBnxGNNTFgTkEA 密码:fov0这个第九章的代码和自己做的测试ressTree.py 这章代码坑较多。写的真的心累啊# -*- coding: utf-8 -...
2018-03-29 18:34:21
411
2
原创 机器学习实战(7) ——利用AdaBoost元算法提高分类性能(python实现)
这是学习机器学习算法实战这本书时,写的代码实战。让自己对各个算法有更直观的了解,不能一直不写啊。不管简单还是不简单都亲自一行一行的敲一遍啊。具体的源码和和数据链接:https://pan.baidu.com/s/1G2S2pb5gfBnxGNNTFgTkEA 密码:fov0下面是是第七章写的adaboost.py程序# -*- coding: utf-8 -*-# author: Yufeng ...
2018-03-28 17:17:35
298
原创 机器学习实战(8) ——预测数值型数据回归(python实现)
这是学习机器学习算法实战这本书时,写的代码实战。让自己对各个算法有更直观的了解,不能一直不写啊。不管简单还是不简单都亲自一行一行的敲一遍啊。具体的源码和和数据链接:https://pan.baidu.com/s/1G2S2pb5gfBnxGNNTFgTkEA 密码:fov0这个第八章的代码和自己做的测试regression.py。基本符合结果。# -*- coding: utf-8 -*-# a...
2018-03-28 17:13:35
822
原创 机器学习实战(4) ——Logistic回归(python实现)
这是学习机器学习算法实战这本书时,写的代码实战。让自己对各个算法有更直观的了解,不能一直不写啊。不管简单还是不简单都亲自一行一行的敲一遍啊。具体的源码和和数据链接:https://pan.baidu.com/s/1G2S2pb5gfBnxGNNTFgTkEA 密码:fov0下面是主程序logRegress.py和其中在实际操作中遇到的问题啊# -*- coding: utf-8 -*-# aut...
2018-03-22 21:42:20
317
原创 机器学习实战(3) ——基于概率论的分类方法:朴素贝叶斯(python实现)
这是学习机器学习算法实战这本书时,写的代码实战。让自己对各个算法有更直观的了解,不能一直不写啊。不管简单还是不简单都亲自一行一行的敲一遍啊。具体的源码和和数据链接:https://pan.baidu.com/s/1G2S2pb5gfBnxGNNTFgTkEA 密码:fov0下面是主程序bayes.py和其中在实际操作中遇到的问题啊# -*- coding: utf-8 -*-# author: ...
2018-03-20 23:20:33
217
原创 机器学习实战(2) ——决策树算法(python实现)
这是学习机器学习算法实战这本书时,写的代码实战。让自己对各个算法有更直观的了解,不能一直不写啊。不管简单还是不简单都亲自一行一行的敲一遍啊。具体的源码和和数据链接:https://pan.baidu.com/s/1G2S2pb5gfBnxGNNTFgTkEA 密码:fov0第一个程序是treePlotter.py主要讲述如何使用matplotlib绘制树# -*- coding: utf-8 -...
2018-03-19 20:11:08
348
原创 matplotlib学习笔记(一)
''''''from numpy import *import matplotlibimport matplotlib.pyplot as pltfrom matplotlib.patches import Rectanglen = 1000 #number of points to createxcord = zeros((n))print(xcord)#[0. 0. ...
2018-03-15 21:38:17
366
原创 机器学习实战(1) ——K-近邻算法(python实现)
这是学习机器学习算法实战这本书时,写的代码实战。让自己对各个算法有更直观的了解,不能一直不写啊。不管简单还是不简单都亲自一行一行的敲一遍啊。具体的源码和和数据链接:https://pan.baidu.com/s/1G2S2pb5gfBnxGNNTFgTkEA 密码:fov0# -*- coding: utf-8 -*-# author: Yufeng Songfrom numpy imp...
2018-03-15 21:06:06
285
原创 1000个点随机选三个,判断其他点是不是在三角形内部----Python面试题
随机生成1000个点,选取任意3个点组成三角形,问,如何判断其余的997个点在三角形内或外?(请用python实现代码)# -*- coding: utf-8 -*-# author: Yufeng Songimport numpy as npimport random# 定义点class Vertex(object): def __init__(self, x, y): ...
2018-02-02 21:47:30
1138
1
原创 LeetCode 78. Subsets--Python实现
Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,3], a solution is:[ [3], [1...
2018-01-29 17:24:41
590
原创 LeetCode 77. Combinations--python实现
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]
2018-01-29 11:53:27
313
原创 LeetCode 30. Substring with Concatenation of All Words----Python实现
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and
2018-01-29 02:03:46
334
原创 LeetCode 3. Longest Substring Without Repeating Characters---Python实现
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 "
2018-01-29 01:53:53
156
原创 LeetCode 76. Minimum Window Substring--Python实现
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BAN
2018-01-29 01:45:09
254
原创 LeetCode 72. Edit Distance-----Python实现
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:
2018-01-24 00:18:53
264
原创 LeetCode 70 Climbing Stairs--Python实现
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive
2018-01-22 16:36:58
213
原创 LeetCode---69. Sqrt(x)---Python实现
Implement int sqrt(int x).Compute and return the square root of x.x is guaranteed to be a non-negative integer.Example 1:Input: 4Output: 2Example 2:Input: 8Output: 2Explanation: Th
2018-01-22 15:33:58
733
原创 LeetCode 65. Valid Number--Python实现
Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguo
2018-01-16 15:55:17
566
原创 LeetCode 64. Minimum Path Sum---Python实现
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at
2018-01-16 15:13:29
207
原创 LeetCode 63. Unique Paths II--Python实现
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the
2018-01-16 15:01:22
259
原创 LeetCode 62.Unique Paths---Python实现
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the
2018-01-16 14:48:40
782
原创 LeetCode 61. Rotate List---Python实现
Given a list, rotate the list to the right by k places, where k is non-negative.Example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.本题关键在于构建一个循环链表,注意k要对链表长度取余。# Defi
2018-01-16 14:33:23
151
原创 LeetCode 51. N-Queens--Python实现
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.
2018-01-16 09:37:53
1702
原创 LeetCode 57. Insert Interval---Python实现
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.E
2018-01-08 16:54:46
431
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人