自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(32)
  • 收藏
  • 关注

原创 代价函数(损失函数

交叉熵损失(Cross-Entropy Loss):用于分类问题,衡量模型预测结果与真实标签之间的差异。代价函数(Cost Function),也称为损失函数(Loss Function),是在机器学习和优化问题中用于衡量模型预测结果与真实值之间的差异的函数。需要注意的是,代价函数的选择可能会受到数据分布、模型假设和问题的特定要求等因素的影响。因此,在选择代价函数时,需要仔细考虑这些因素,并进行实验和评估来确定最适合的代价函数。代价函数的选择应该与模型的目标相一致,并且能够提供对模型预测结果的合理衡量。

2023-12-12 19:52:17 533

原创 shell expect sftp

shell expect sftp

2023-09-25 16:33:17 1530

原创 Mac M1系统将外接磁盘(光盘驱动器、光驱)从边栏删除后恢复

2023-08-10 20:52:14 185

原创 Python GIL锁的限制

Python Gil锁的限制转载自这里

2023-01-01 10:54:28 93

原创 mac pyinstaller 打包后闪退

搜了好久,都没能解决,看着别人说一条命令在Mac就OK了,看着挺气人!找到正确解决答案,发现就是很简单还同时解决了这个AttributeError: module 'enum' has no attribute 'IntFlag'异常处理方法更新 pyinstaller相关包到最新版本pip install --upgrade PyInstaller pyinstaller-hooks-contrib我的版本:Mac:11.6.5PyInstaller==5.1pyinstaller-h

2022-05-23 18:37:57 281

原创 jupyter template_path not recognized

Config option `template_path` not recognized by `LenvsHTMLExporter`. Did you mean one of: `extra_template_paths, template_name, template_paths`?问题:安装jupyter notebook插件后启动、执行代码时终端会出现这种警告信息解决方法:pip list查看安装包 nbconvert版本,高于5.6.1则属同种情况,(不高于也可以试一下)pip in

2021-11-23 18:48:03 1716 2

原创 python连接MySQL异常解决; pymysql.err.OperationalError ... Connection refused

异常提示pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 61] Connection refused)")解决:conn = pymysql.connect( host='localhost', user='test', password='test', db='test', charset='utf8', unix_sock

2021-10-09 10:40:53 1014

原创 混淆矩阵、ROC与auc

模型A示例: 1. 正例:在模型 A 的场景中,猫是正例。 2. 负例:在模型 A 的场景中,其他是负例。 3. TP(真阳性):真实的类别是猫,同时模型也预测为猫,有 60 张。 4. FP(假阳性):真实的类别是其他,但模型预测为猫,有 20 张。 5. TN(真阴性):真实的类别是其他,同时模型也预测为其他,有 10 张。 6. FN(假阴性):真实的类别是猫,但模型预测为其他,有 10 张。1. 正确率: 被正确分类的样本比例,衡量预测值与真值相符合的程度 Accuracy .

2021-09-28 09:53:33 221

原创 numpy.bincount 详解

搜到Xurtle博主的文章,看了好一会终于悟出weights参数的作用,记录一下;np.bincount(x)输出结果记为ybincount输出结果的数组(假设为y),其元素数量比x中的最大值大1,y给出了y的索引值在x中出现的次数。# 可以看到x中最大的数为7,因此bin的元素数量为8,那么它的索引值为0->7x = np.array([0, 1, 1, 3, 2, 1, 7])# 索引0出现了1次,索引1出现了3次......索引5出现了0次......np.bincount(x)#

2021-09-23 15:58:41 375

原创 vim安装自动补全插件后不生效

确保 ~/.vimrc配置的Python路径是否和执行install.py的Python一致

2021-08-26 18:14:54 590

原创 重置tmux配置

tmux source-file ~/.tmux.conf

2021-08-26 18:12:56 748

原创 fasttext gcc问题

安装fasttext gcc异常,可以用下面这个pip install fasttext-wheel

2021-05-08 16:37:31 120

原创 pip 设置镜像源

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

2021-04-08 11:23:45 82

原创 正则匹配中文

import rere_text = re.compile(r'[\u4e00-\u9fa5]')str_obj = '我爱中国!'re_text.findall(str_obj)# out# ['我', '爱', '中', '国']

2021-04-02 16:34:11 77

原创 sorted

sorted(iterable, key=func, reverse=False)iterbale: 可迭代对象key: 函数;参数为iterable的每个元素reverse: 排序规则,默认False 正序排序,True 逆序排序d = {6: 123, 7: 123, 8: 123}sort_d = sorted(d.items(), key= lambda x: x[0], reverse=False)# res# {6: 123, 7: 123, 8: 123}...

2021-03-27 09:11:03 99

原创 列表分片

列表分片id_slices = [paper_sim_ques_l[i: i+self.batch_size] for i in range(0, sim_cnt, self.batch_size)]

2021-03-25 14:22:14 66

原创 cookiecutter subprocess.CalledProcessError

 ~/Desktop/fast_project  cookiecutter https://github.com/tiangolo/full-stack-fastapi-postgresqlTraceback (most recent call last): File "/Users/iyx/Library/Python/3.7/bin/cookiecutter", line 8, in <module> sys.exit(main()) File "/Library/Fr

2021-03-19 11:00:49 176

原创 准确率、召回率、精确率

2021-03-03 08:58:26 175

原创 Elasticsearch笔记

Elasticsearch 是一个实时的分布式搜索分析引擎,它能让你以前所未有的速度和规模,去探索你的数据。 它被用作全文检索、结构化搜索、分析以及这三个功能的组合header_str = 'Content-Type: application/json'只取出指定字段,并排序# 只取出id、name、age字段,并以age逆序排序【正序排序asc】{ "query": { "match_all": { } }, "sort": [ { "age.

2020-12-23 19:25:03 84

原创 fastapi 422 Unprocessable Entity

记 fastapi 422 Unprocessable Entityget 请求不能用post形式(单独写在类里)设置参数,要写在请求函数里

2020-12-19 15:04:02 992 1

原创 记pymongo突然提示导入异常解决方法

安装包pymongo突然提示导入异常记录早上欢欢喜喜来上班,激情满满准备开始一天的工作,满怀敬畏之心执行我完美脚本,突然就来个bug !人生就是这样惊喜和惊吓不知道哪个先来,但是!作为强大的程序猿,惊喜和惊吓都要当做惊喜来对待,因为现在的惊吓很有可能是未来的惊喜!Traceback (most recent call last): File "<stdin>", line 1, in <module>ModuleNotFoundError: No module nam

2020-12-17 10:56:02 811

原创 pip改为pip3

pip改为pip3记录问题:最近换了电脑用pip安装时总是默认用Python2,导致安装后Python3里仍然不能使用安装的包pip -V 查看当前pip使用的Python版本临时解决办法:python3 -m pip install 包名把pip永久改为pip3:第一步:sudo vim /usr/local/bin/pip第二步把文件第一行改为:#!/usr/local/opt/python/bin/python3.7即:#!/usr/local/opt/python/bin/py

2020-11-11 16:31:55 2512 2

原创 Elasticsearch 按条件删除指定数据

`在这里插入代码片`import os import sys`在这里插入代码片`import jsonimport requestsfrom elasticsearch import Elasticsearch, helpershost = '10.12.61.253'po

2020-10-10 16:39:51 2926

原创 Elasticsearch加载大量数据

import osimport sysfrom elasticsearch import Elasticsearchfrom elasticsearch import helpersdef load_ques_data(es, index_v, fpw): '''es: Elasticsearch对象, index_v: 索引名 fpw: 文件写入对象 ''' query={"query" : {"match_all" : {}}} scanResp= he

2020-10-10 16:29:03 361 1

原创 网页json数据格式化展示

需要安装一个json插件(谷歌浏览器)https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa?utm_source=chrome-ntp-icon

2020-10-10 14:57:52 258

原创 Elasticsearch 删除多余域映射(字段)

由于Elasticsearch域映射创建后不能随便删改,所以如果没有设计好就开始开发就可能出现域映射会有多余字段(我通常把域映射和字段当做一个东西),对于追求完美同学们心里总是不舒服的

2020-09-22 15:55:39 1451

原创 查询ES索引域映射、ES索引配置

【代码】查询ES索引域映射、ES索引配置。

2020-09-16 11:07:04 401 1

原创 Linux命令 grep、sed

linux grep sed

2020-09-15 23:30:47 181 1

原创 python 列表生成式、map、filter、reduce

列表生成式列表生成式有返回值基础语法格式:[expression for element in iterable]# 基础使用new_list = [i for i in range(3)]'''new_list: [0, 1, 2]''' # 添加if条件new_list = [i for i in ['python', 'java'] if i == 'python']'''new_list: ['python']'''# 添加if-elsenew_list = [i if

2020-09-15 19:18:47 399

原创 MAC matplotlib 中文显示异常

import matplotlib # 获得matplotlib配置文件print (matplotlib.matplotlib_fname())结果/anaconda3/lib/python3.7/site-packages/matplotlib/mpl-data/matplotlibrc在这个文件里找到fonts.family所在行,修改为 font.family : sans-serif,并在下一行添加font.sans-serif : SimHei再找到unicode_minu

2020-06-14 21:28:12 176

原创 @staticmethod

被@staticmethod装饰器装饰的函数没有self参数,可以不生成类对象直接用类名调用被装饰的函数,与__init__函数无关当然生成类对象再调用该函数也是可以的示例如下:class Test(): def __init__(a): self.a = a def _print_beau(): print('beautiful') def _print_perf(arg1): print(arg1) print('perfect')Test._print_bea.

2020-05-29 16:39:48 487

原创 mongoexport、mongoimport

–query(或-q) json字典(查询条件)导入:mongoimport --host 127.0.0.1 --port port -u test -p test --db test_db -c test_col --type json --file /home/pengkunpeng/parse_ebook/kj/res_data导出:mongoexport --host 127.0.0.1 --port port -u test -p test --db test_db --collect

2020-05-16 13:21:18 179

空空如也

空空如也

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

TA关注的人

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