- 博客(47)
- 问答 (2)
- 收藏
- 关注
原创 vtk中 GetOutput 与 GetOutputPort 的用法
GetOutputSetInputDatacube_mapper.SetInputData(cube.GetOutput())GetOutputPortSetInputConnectioncube_extractor.SetInputConnection(cube.GetOutputPort())```
2021-04-14 10:23:43
1669
原创 C++ 拆分字符串为单词的五种方法
本文是对C++ Split string into vector<string> by space- Grandyang 的整理。方法一:#include <iostream>#include <vector>#include <string>#include <sstream> // istringstreamusing namespace std;int main(){ string str { "dog cat c
2020-12-19 15:32:26
3764
1
原创 「思维导图」《深度学习推荐系统 - 王喆》2.3节 矩阵分解算法 - 协同过滤的进化
更多《深度学习推荐系统 - 王喆》相关思维导图,见本人 GitHUb:https://github.com/YunWGui/RecSys-Book-Notes
2020-06-08 18:17:32
590
原创 「思维导图」《深度学习推荐系统 - 王喆》2.2节 协同过滤 - 经典的推荐算法
更多《深度学习推荐系统 - 王喆》相关思维导图,见本人 GitHUb:https://github.com/YunWGui/RecSys-Book-Notes
2020-06-08 09:28:26
3144
原创 pandas 数组获取最大、最小值索引
用 pd.DataFrame.idxmax()In [14]: data = pd.DataFrame(np.random.random((3, 3)), columns=list('ABC'), index=list('abc'))In [15]: dataOut[15]: A B Ca 0.843759 0.667096 0.646913b 0.591783 0.042383 0.394693c 0.528629 0.89
2020-05-27 12:49:00
5698
原创 numpy, pandas显示小数点问题
numpynp.around()temp = np.random.random((2,2))tempOut[10]: array([[0.88241156, 0.68553721], [0.89101074, 0.57547832]])np.around(temp, decimals=2) # decimals 保留小数点位数Out[11]: array([[0.88, 0.69], [0.89, 0.58]])pandaspd.round()da
2020-05-27 12:36:21
4282
3
原创 Python round函数取舍方式详解使用
round 函数并非严格的遵循四舍五入,而是采用银行家舍入法口诀为:四舍六入五考虑,五后非空就进一,五后为空看奇偶,五前为偶应舍去,五前为奇要进一# 四舍a = 1.45print(f"a : {a}, round(a) : {round(a)}")Out[80]: 'a : 1.45, round(a) : 1'# 六入b = 1.67 print(f"b : {b }, round(b) : {round(b)}")Out[81]: 'b : 1.67, round(b) : 2'
2020-05-26 17:41:28
792
2
原创 python 小工具之一:创建一个存储 LeetCode 刷题信息的文件
在 LeetCode 上刷题的时候,总需在要本地创建一个文件以存储一些代码。可每次都需要手动输入相关信息就让人很烦,因此写了如下脚本,可以稍稍简化流程。""" 生成一个存储 LeetCode 刷题信息所需的文档,文档内包含必要的信息 后续规划: 结合爬虫库,实现只需要 url 即可创建一个文件夹"""import os de...
2020-04-19 12:43:53
207
原创 C++ size_t 使用注意事项
size_t是一种无符号整数类型 ( unsigned integer types ),因此进行循环时,要十分注意其边界问题.比如下面这种情况:for ( size_t i = 5; i >=0; --i ) cout << i << " "; 此时,循环是不会自动终止的,因为 size_t 是无符号整型,永远不会出现 i < 0 的情况...
2020-04-13 18:33:08
1059
8
原创 C++ pair 与 make_pair
#include <iostream>#include <string>#include <map>using namespace std;int main(){ multimap<int, string> stu; // 效果一样 stu.insert( make_pair( 1, "student_one" ) );...
2020-04-11 00:28:46
173
原创 C/C++ 经典库函数
经典库函数1. atoiint atoi( const char* str ) : 把参数 str 所指向的字符串转换为一个整数(类型为 int 型)#include <stdio.h>#include <string.h> // strcpy#include <stdlib.h> // atoiint main() { int v...
2020-03-31 16:38:58
277
原创 C++ 判断两个字符串是否相等
#include <iostream>#include <string>#include <string.h>using namespace std;int main(){ string str1 = "abc", str2 = "abc"; if ( strcmp( str1.c_str(), str2.c_str() ) == ...
2020-03-31 14:28:31
3445
2
原创 对 if __name__ == "__main__" 的理解
当文件作为脚本执行时,if __name__ == "__main__:下面的语句才被执行当文件作为模块被导入时,不执行if __name__ == "__main__:下面的语句。例如,创建文件const.pyPI = 3.14def main(): print("PI", PI)main()在同一目录下,创建文件area.pyfrom const import PId...
2019-11-29 17:11:37
159
原创 替代记事本和NotePad++
windows自带记事本打文件没有语法高亮,而且文件稍微大一点,打开就比较吃力。对此,Notepad++ 原本是替换的首选。但是,由于 Notepad++ 的作者是个资深 Tai Du,最近就发布了一个作妖的版本。所以一直寻找 Notepad++ 的替代。就目前使用来看,Notepad2 / Notepad2-mod 是不错的选择。使用方法下载 Notepad2 / Notepad2-m...
2019-11-28 09:33:16
3663
原创 python3默认继承object类
class Person(): name = "zhengtong" class Animal(object): name = "chonghong" if __name__ == "__main__": x = Person() print(f"Person {dir(x)}") print() y = Animal() ...
2019-11-27 16:36:03
842
转载 Python工程的文档结构
转载自Python工程的文档结构Project/|-- bin/| |-- project||-- project/| |-- test/| | |-- __init__.py| | |-- test_main.py| | | |-- __init__.py| |-- main.py||-- setup.py|-- README...
2019-11-27 15:35:24
427
1
原创 TypeError module object is not callable
不知什么缘故,安装新库,pip install package,总是出现如下异常:Traceback (most recent call last): File "D:\Users\liu59\Anaconda3\Scripts\pip-script.py", line 10, in <module> sys.exit(main())TypeError: 'module...
2019-11-26 18:58:50
570
原创 vscode运行python中使用python插件和Code Runner插件的区别
使用vscode的python插件按F5调试时,其运行的版本依赖于你选择的版本运行如下代码:import sysprint(sys.version)而如果运行 Code Runner 插件,其依赖的python版本是加入「环境变量」的python版本...
2019-11-26 16:48:50
1204
原创 numpy重塑矩阵
In [7]: np.linspace(1, 10, 10)Out[7]: array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])In [8]: np.linspace(1, 10, 10).shapeOut[8]: (10,)方案一:使用 np.newaxisIn [9]: np.linspace(1, 10, 10)[:...
2019-11-24 15:59:00
367
原创 numpy.random.choice
以下摘自官方文档numpy.random.choice(a, size=None, replace=True, p=None)Generates a radnom sample from a given 1-D array译:从给定的一维数组(a)中随机采样a : 可以为一维数组或整数;若为整数,则相当于 np.arange(a)size : 随机采样的个数replace : 采...
2019-11-23 20:04:40
99
原创 屏蔽 FutureWarning
使用 python 时,经常出现如下FutureWarning异常,有时候查了半天也无法解决,然而看着又不舒服。此时,可以将其屏蔽,眼不见心不烦。py:193: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for uns...
2019-11-21 21:41:14
4854
转载 如何在 Kaggle 首战中进入前 10%
转载自:如何在 Kaggle 首战中进入前 10%因为原作者的博客将搬迁,且新博客中没有这篇文章,所以特转载保存。Introduction本文采用署名 - 非商业性使用 - 禁止演绎 3.0 中国大陆许可协议进行许可。著作权由章凌豪所有。Kaggle 是目前最大的 Data Scientist 聚集地。很多公司会拿出自家的数据并提供奖金,在 Kaggle 上组织数据竞赛。我最近完成了第一次...
2019-11-20 20:49:59
240
原创 Python可视化 - 极坐标图
https://www.cnblogs.com/arnoldlu/p/7553978.html?tdsourcetag=s_pctim_aiomsgimport numpy as npimport matplotlib.pyplot as plt1. 线状极坐标图fig, ax = plt.subplots()ax = plt.subplot(111, projection='pol...
2019-11-12 21:20:13
5148
原创 LeetCode C++刷题总结
1 NULL 似乎比 nullptr 更快19. 删除链表的倒数第N个节点class Solution {public: ListNode *removeNthFromEnd(ListNode *head, int n) { if (head == NULL || n <= 0) { return NULL; } ...
2019-11-04 10:51:39
531
转载 C++ 中 cstring 和 string 的区别
<string>是C++标准库头文件,包含了拟容器 class std::string 的声明(不过 class string 事实上只是 basic_string<char>的typedef,用于字符串操作。<cstring>是 C 标准库头文件 <string.h>的 C++ 标准库版本。参考 :https://blog.youkuaiyun.com/q...
2019-10-18 15:40:07
257
原创 《python数据科学手册》异常校正
由于一些模块的变迁,导致复现《python数据科学手册》代码(尤其第5章-机器学习)时,经常报错。以下是我个人的一些校证。如果诸位在学习《python数据科学手册》的过程中,遇到什么疑难,欢迎留言。scikit-learn 模块变迁自 scikit-learn 0.20版起,已经用model_selection模块代替cross_validation模块。因此,复现代码时,from sk...
2019-10-12 22:28:26
530
1
原创 git 无法 push
用 git push文档到 github时,出现如下错误:! [rejected] master -> master (non-fast-forward)error: failed to push some refs to 'https://github.com/huijuanl/huijuan072.git'hint: Updates were rejecte...
2019-10-11 11:10:46
184
原创 数值计算注意优先级
实现梯度下降算法时,遇到优先级的问题,1./2*m != 1./(2*m)# 例如当 m = 3 时,1./2 * m = 1./2 * 3 = 0.5 * 3 = 1.51./(2 * m) = 1./(6) = 0.166666...这个错误以前一直没注意到,特此记下...
2019-10-09 21:18:18
160
原创 error: no matching function for call to 'std::exception:exception(const char[15])'
在复现《剑指offer》代码段:throw new exception("queue is empty");时,遇到:error: no matching function for call to 'std::exception:exception(const char[15])'解决方法:#include <stdexcept>std::logic_er...
2019-10-07 09:37:50
1023
2
原创 C++ struct 的用法
即使通过 typedef将 struct node定义为 list,在后续的使用中,仍然可以再次使用 struct node。从而可以造成一些奇怪的报错。#include <iostream>#include <stack>using namespace std;typedef struct node { int data; struct node* ...
2019-10-05 20:52:33
1078
原创 C语言编译多文件
有多个C语言文件,需要一起编译,以下为 gcc实现// 不指定生成 exe 的名称,默认生成 a.exe 文件gcc file.h file1.c file2.c // 指定生成 exe 文件的名称,此处为 filename.exegcc file.h file1.c file2.c -o filename...
2019-10-04 15:41:48
467
原创 git 报 error: failed to push some refs to xxx 的错误
用 git从 github远程库 pull代码时,出现如下错误: ! [rejected] master -> master (non-fast-forward)error: failed to push some refs to 'git@github.com:xxxxxxxx.git'hint: Updates were rejected because t...
2019-10-04 11:24:29
243
原创 Typo: In word xxxx
用 JetBrains IDE (CLion, PyCharm)时,会出现Typo: In word xxxx这是在提醒有拼写错误
2019-10-03 16:39:58
11770
原创 Git 强制覆盖本地内容
git pull :强制覆盖本地内容# 从远程库中下载最新版本git fetch --all# 将本地设为刚获取的最新的内容git reset --hard origin/mastergit pull
2019-09-28 20:47:56
158
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人