- 博客(25)
- 资源 (3)
- 收藏
- 关注
原创 TypeError: 'tuple' object does not support item assignment
PythonTypeError: ‘tuple’ object does not support item assignment报错信息:tuple是只可读,而不支持写的,所以在这就出现了关于tuple赋值的问题。
2019-07-31 17:17:04 821
原创 NameError:name ‘xrange’ is not defined
运行某代码时,报错:NameError:name ‘xrange’ is not defined原因:在Python 3中,range()与xrange()合并为range( )。我的python版本为python3.5。解决办法:将xrange( )函数全部换为range( )。参考博文...
2019-07-31 17:04:13 158
原创 Python cPickle和pickle 在python 2和python 3中兼容性问题
我们以一个简单的文件打开和文件读为例说明,pickle读文件时可能存在的编码问题:使用with结构避免手动的文件关闭操作import gzipimport picklewith gzip.open('./mnist.pkl.gz', 'rb') as f: training_data, validation_data, test_data = pickle.load(f)如果沿...
2019-07-31 16:30:38 1001
原创 Python numpy np.random.randn及np.random.rand的区别
Python numpynp.random.randn及np.random.rand的区别numpy中有一些常用的用来产生随机数的函数,randn()和rand()就属于这其中。numpy.random.randn(d0, d1, …, dn)是从标准正态分布中返回一个或多个样本值。numpy.random.rand(d0, d1, …, dn)的随机样本位于[0, 1)之间。impor...
2019-07-31 15:11:13 1117
原创 Leetcode87 扰乱字符串 C++,Java,Python
Leetcode87 扰乱字符串来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/scramble-string/博主Github:https://github.com/GDUT-Rp/LeetCode题目:给定一个字符串 s1,我们可以把它递归地分割成两个非空子字符串,从而将其表示为二叉树。下图是字符串 s1 = "great" ...
2019-07-31 10:26:33 222
原创 Leetcode123 买卖股票的最佳时机Ⅲ C++,Java,Python
Leetcode123 买卖股票的最佳时机Ⅲ来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-iii/博主Github:https://github.com/GDUT-Rp/LeetCode题目:给定一个数组,它的第 i 个元素是一支给定的股票在第 i 天的价格。设计一...
2019-07-30 13:01:13 462
原创 Leetcode121 买卖股票的最佳时机 C++,Java,Python
Leetcode121 买卖股票的最佳时机来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock博主Github:https://github.com/GDUT-Rp/LeetCode题目:给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。如果你最多只允许完成一...
2019-07-29 09:46:00 113
原创 Leetcode85 最大矩形 C++,Java,Python
Leetcode85 最大矩形来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/maximal-rectangle/博主Github:https://github.com/GDUT-Rp/LeetCode题目:给定一个仅包含 0 和 1 的二维二进制矩阵,找出只包含 1 的最大矩形,并返回其面积。示例 1:输入:[ ["1"...
2019-07-28 16:47:32 533
原创 Leetcode84 柱形图中最大的矩形 C++,Java,Python
Leetcode84 柱形图中最大的矩形来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/largest-rectangle-in-histogram/博主Github:https://github.com/GDUT-Rp/LeetCode题目:给定 n 个非负整数,用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 1 。...
2019-07-26 16:20:43 280
原创 Leetcode72 编辑距离 C++,Java,Python
Leetcode72 编辑距离来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/edit-distance/博主Github:https://github.com/GDUT-Rp/LeetCode题目:给定两个单词 word1 和 word2,计算出将 word1 转换成 word2 所使用的最少操作数 。你可以对一个单词进行如下三...
2019-07-24 15:17:38 264
原创 Leetcode162 寻找峰值,C++,Java,Python
Leetcode162 寻找峰值来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/find-peak-element/博主Github:https://github.com/GDUT-Rp/LeetCode题目:峰值元素是指其值大于左右相邻值的元素。给定一个输入数组 nums,其中 nums[i] ≠ nums[i+1],找到峰值元...
2019-07-23 10:49:37 551
原创 Leetcode154 寻找旋转排序数组中的最小值Ⅱ C++,Java,Python
Leetcode154 寻找旋转排序数组中的最小值Ⅱ来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii/博主Github:https://github.com/GDUT-Rp/LeetCode题目:假设按照升序排序的数组在预先未知的某个点上进行了旋转。( ...
2019-07-22 08:46:44 211
原创 Leetcode 153 寻找旋转排序数组中的最小值 C++,Java,Python
Leetcode153 寻找旋转排序数组中的最小值来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array博主Github:https://github.com/GDUT-Rp/LeetCode题目:假设按照升序排序的数组在预先未知的某个点上进行了旋转。( 例如,数组...
2019-07-20 09:33:11 490
原创 Leetcode 44 通配符匹配 C++,Java,Python
Leetcode44 通配符匹配来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/wildcard-matching/博主Github:https://github.com/GDUT-Rp/LeetCode题目:给定一个字符串 (s) 和一个字符模式 § ,实现一个支持 ‘?’ 和 ‘*’ 的通配符匹配。‘?’ 可以匹配任何单个字符...
2019-07-19 11:01:32 213
原创 Leetcode 43 字符串相等 C++,Java,Python
Leetcode43 字符串相乘来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/multiply-strings博主Github:https://github.com/GDUT-Rp/LeetCode题目:给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。...
2019-07-18 21:18:20 162
原创 Leetcode 415 字符串相加 C++,Java,Python
Leetcode415 字符串相乘来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/add-strings博主Github:https://github.com/GDUT-Rp/LeetCode题目:给定两个字符串形式的非负整数 num1 和num2 ,计算它们的和。示例 1:输入: num1 = "2", num2 = "3"...
2019-07-17 16:52:45 225
原创 Leetcode 42 接雨水 C++,Java,Python
Leetcode42 接雨水来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/trapping-rain-water>博主Github:https://github.com/GDUT-Rp/LeetCode题目:给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。上面是由数组 [...
2019-07-16 11:13:10 270
原创 Leetcode 41 缺失的第一个正数 C++,Java,Python
Leetcode41 缺失的第一个正数来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/first-missing-positive题目:给定一个未排序的整数数组,找出其中没有出现的最小的正整数。示例 1:输入: [1,2,0]输出: 3示例 2:输入: [3,4,-1,1]输出: 2示例 3:输入: [7,8,9,11,...
2019-07-15 16:54:51 218
原创 Leetcode 38 报数 C++,Java,Python
Leetcode38 报数来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/count-and-say题目:报数序列是一个整数序列,按照其中的整数的顺序进行报数,得到下一个数。其前五项如下:1112112111112211 被读作 "one 1" ("一个一") , 即 11。11 被读作 "...
2019-07-14 15:33:16 121
原创 Leetcode 37 解数独 C++,Python,Java
Leetcode37 解数独来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/valid-sudoku题目:编写一个程序,通过已填充的空格来解决数独问题。一个数独的解法需遵循如下规则:数字 1-9 在每一行只能出现一次。数字 1-9 在每一列只能出现一次。数字 1-9 在每一个以粗实线分隔的 3x3 宫内只能出现一次。空白格...
2019-07-13 09:56:05 293
原创 Python seaborn 条形图
Python seaborn条形图import seaborn as snsname_list = []time_list = []plt.grid()plt.xlabel('名字')plt.ylabel('本周迟到时长/min')plt.title('%s迟到榜' % week_index)sns.barplot(x=name_list, y=time_list, ci=...
2019-07-12 20:43:39 1722
原创 Python dict 字典 排序
Python dict字典排序name_dict = sorted(name_dict.items(), key=lambda d: d[1], reverse=True)返回的是变成了列表[(‘key’, ‘value’), (‘key2’, ‘value’)]
2019-07-12 20:41:23 264
原创 优化分类指标
优化分类指标介绍某些分类指标并不是完全适用我们的模型,有时候我们需要选择和优化指标来调整我们的模型。Logloss如果要优化log-loss,我们只需要将它和正确的模型匹配。树模型:XGBoost,LightGBM线性:sklearn,Regression, sklearn.SGDRegressor, Vowpa Wabbit神经网络:PyTorch, Keras, Tensorf...
2019-07-09 10:46:21 774
原创 Python 获取指定根目录下的文件路径名 批量删除文件
Python获取指定跟目录下的文件名并删除# -*- coding: utf-8 -*-import osdef file_name(file_dir, keyword, remove_list): for root, dirs, files in os.walk(file_dir): # print('root_dir:', root) # 当前目录路径 ...
2019-07-04 17:05:28 698
原创 Java-正则表达式
Java-正则表达式正则表达式是一个强大的字符串处理工具,可以对字符串进行查找、提取、分割、替换等操作。String类提供的几个特殊方法判断字符串是否匹配指定的正则表达式boolean matches(String regex)所有匹配regex的子串替换replacementString replaceAll(String regex, String replacement)将...
2019-07-04 10:36:27 397
temps_extended.xls
2020-07-24
Python SVM 手写数字识别.ipynb
2020-01-10
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人