辅助编程coding的两种工具:Github Copilot、Cursor
目录
- Cursor
- 简介
- 下载地址:
- 使用技巧:
- CHAT:
- example 1:
- 注意:
- example 2:
- Github Copilot
- 官网
- 简介
- 以插件方式安装
- pycharm
- 自动写代码
- example 1:写一个mysql取数据的类
- example 2:写一个多重共线性检测的类
- 总结
Cursor
简介
Cursor is an editor made for programming with AI. It’s early days, but right now Cursor can help you with a few things…
- Write: Generate 10-100 lines of code with an AI that’s smarter than Copilot
- Diff: Ask the AI to edit a block of code, see only proposed changes
- Chat: ChatGPT-style interface that understands your current file
- And more: ask to fix lint errors, generate tests/comments on hover, etc
下载地址:
https://www.cursor.so/

使用技巧:
https://twitter.com/amanrsanger
CHAT:
example 1:





注意:
对于上面最后一张图的中的代码,如果直接在IDE里面运行是不会报错的,但是有一句代码
vif["VIF"] = [variance_inflation_factor(df.values, i) for i in range(df.shape[1]-1)]
是不符合多重共线性分析或者VIF的数学原理的。因为VIF是对自变量间线性关系的分析,如果直接调用OLS;如果把OLS里面的目标函数换成非线性方程,就是表达的非线性关系。而上面的代码是把df.values都传入了variance_inflation_factor函数,包括了自变量和因变量,因此是不符合多重共线性分析原理的。
所以应改成:
import pandas as pddata = {'x1': [1, 2, 3, 4, 5],'x2': [2, 4, 6, 8, 10],'x3': [3, 6, 9, 12, 15],'y': [2, 4, 6, 8, 10]}df = pd.DataFrame(data)from statsmodels.stats.outliers_influence import variance_inflation_factor# Get the VIF for each feature
vif = pd.DataFrame()
vif["feature"] = df.columns[:-1]
# vif["VIF"] = [variance_inflation_factor(df.values, i) for i in range(df.shape[1]-1)]
vif["VIF"] = [variance_inflation_factor(df.values[:, :-1], i) for i in range(df.shape[1]-1)]# Print the results
print(vif)
原理解释:
def variance_inflation_factor(exog, exog_idx):"""Variance inflation factor, VIF, for one exogenous variableThe variance inflation factor is a measure for the increase of thevariance of the parameter estimates if an additional variable, given byexog_idx is added to the linear regression. It is a measure formulticollinearity of the design matrix, exog.One recommendation is that if VIF is greater than 5, then the explanatoryvariable given by exog_idx is highly collinear with the other explanatoryvariables, and the parameter estimates will have large standard errorsbecause of this.Parameters----------exog : {ndarray, DataFrame}design matrix with all explanatory variables, as for example used inregressionexog_idx : intindex of the exogenous variable in the columns of exogReturns-------floatvariance inflation factorNotes-----This function does not save the auxiliary regression.See Also--------xxx : class for regression diagnostics TODO: does not exist yetReferences----------https://en.wikipedia.org/wiki/Variance_inflation_factor"""k_vars = exog.shape[1]exog = np.asarray(exog)x_i = exog[:, exog_idx]mask = np.arange(k_vars) != exog_idxx_noti = exog[:, mask]r_squared_i = OLS(x_i, x_noti).fit().rsquaredvif = 1. / (1. - r_squared_i)return vif
example 2:


GPT-4太大写不了,给出的是调GPT-2的示例代码。
Github Copilot
官网
https://github.com/features/copilot
简介
- GitHub Copilot uses the OpenAI Codex to suggest code and entire functions in real-time, right from your editor.
- Trained on billions of lines of code, GitHub Copilot turns natural language prompts into coding suggestions across dozens of languages.
- Don’t fly solo
Developers all over the world use GitHub Copilot to code faster, focus on business logic over boilerplate, and do what matters most: building great software. - Focus on solving bigger problems
Spend less time creating boilerplate and repetitive code patterns, and more time on what matters: building great software. Write a comment describing the logic you want and GitHub Copilot will immediately suggest code to implement the solution. - Get AI-based suggestions, just for you
GitHub Copilot shares recommendations based on the project’s context and style conventions. Quickly cycle through lines of code, complete function suggestions, and decide which to accept, reject, or edit. - Code confidently in unfamiliar territory
Whether you’re working in a new language or framework, or just learning to code, GitHub Copilot can help you find your way. Tackle a bug, or learn how to use a new framework without spending most of your time spelunking through the docs or searching the web.

目前有个人版、商业版和教育版三种,教育版里面学生账户比教师账户的免费功能更多,只需要一个学校邮箱和一卡通就可以认证学生账户或者教师账户,还是很方便。
以插件方式安装
pycharm



自动写代码
以下代码除了第一行注释都是copilot自动补全的
example 1:写一个mysql取数据的类
# 写一个mysql取数据的类
import pymysql
class Mysql:def __init__(self,host,user,password,database,port=3306):self.host = hostself.user = userself.password = passwordself.database = databaseself.port = portself.conn = pymysql.connect(host=self.host,user=self.user,password=self.password,database=self.database,port=self.port)self.cursor = self.conn.cursor()def fetchone(self,sql):self.cursor.execute(sql)return self.cursor.fetchone()def fetchall(self,sql):self.cursor.execute(sql)return self.cursor.fetchall()def close(self):self.cursor.close()self.conn.close()def commit(self):self.conn.commit()def rollback(self):self.conn.rollback()def execute(self,sql):self.cursor.execute(sql)self.commit()def executemany(self,sql,values):self.cursor.executemany(sql,values)self.commit()
example 2:写一个多重共线性检测的类
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
class Multicollinearity:def __init__(self,df):self.df = dfdef get_vif(self):vif = pd.DataFrame()vif["VIF Factor"] = [self.get_vif_score(i) for i in range(self.df.shape[1])]vif["features"] = self.df.columnsreturn vifdef get_vif_score(self,i):y = self.df.iloc[:,i]x = self.df.drop(self.df.columns[i],axis=1)lr = LinearRegression()lr.fit(x,y)r2 = r2_score(y,lr.predict(x))return 1/(1-r2)
总结
用工具自动写代码的时候,最好要用实际例子或实际数据检查一下,就算没有报错,对于数值计算最好也要debug跑一遍看它生成的代码是否符合你的描述或者数学原理。具体原因见上文的注意。
相关文章:
辅助编程coding的两种工具:Github Copilot、Cursor
目录Cursor简介下载地址:使用技巧:CHAT:example 1:注意:example 2:Github Copilot官网简介以插件方式安装pycharm自动写代码example 1:写一个mysql取数据的类example 2:写一个多重共线性检测的类…...
MySQL5.7安装教程
1.鼠标右击【MySQL5.7】压缩包(win11及以上系统需先点击“显示更多选项”)选择【解压到 MySQL5.7】 2.打开解压后的文件夹,双击运行【mysql-installer-community-5.7.27.0】 3.勾选【I accept the license terms】,点击【Next】 4…...
ML@sklearn@ML流程Part3@AutomaticParameterSearches
文章目录Automatic parameter searchesdemomodel_selection::Hyper-parameter optimizersGridSearchCVegRandomizedSearchCVegNoteRandomForestRegressorMSEpipeline交叉验证🎈egL1L2正则Next stepsUser Guide vs TutorialAutomatic parameter searches Automatic p…...
Ubuntu22安装OpenJDK
目录 一、是否自带JDK 二、 删除旧JDK(如果自带JDK满足需求就直接使用了) 三、下载OpenJDK 四、新建/home/user/java/文件夹 五、 设置环境变量 六、查看完成 附:完整版连接: 一、是否自带JDK java -version 二、 删除旧…...
【数据库管理】②实例管理及数据库启动关闭
1. 实例和参数文件 1.1 instance 用于管理和访问 database. instance 在启动阶段读取初始化参数文件(init parameter files). 1.2 init parameter files [rootoracle-db-19c ~]# su - oracle [oracleoracle-db-19c ~]$ [oracleoracle-db-19c ~]$ cd $ORACLE_HOME/dbs [oracl…...
【2023】Kubernetes之Pod与容器状态关系
目录简单创建一个podPod运行阶段:容器运行阶段简单创建一个pod apiVersion: v1 kind: pod metadata: name: nginx-pod spec:containers:- name: nginximages: nginx:1.20以上代码表示创建一个名为nginx-pod的pod资源对象。 Pod运行阶段: Pod创建后&am…...
LabVIEW阿尔泰PCIE 5654 例程与相关资料
LabVIEW阿尔泰PCIE 5654 例程与相关资料 阿尔泰PCIE 5654多功能采集卡,具有500/250Ksps、32/16路模拟量输入;100Ksps,16位,4/2/0路同步电压模拟量输出;8路DIO ;8路PFI;1路32位多功能计数器。PC…...
spark2.4.4有哪些主要的bug
Issue Navigator - ASF JIRA -...
信息学奥赛一本通 1347:【例4-8】格子游戏
【题目链接】 ybt 1347:【例4-8】格子游戏 【题目考点】 1. 并查集:判断无向图是否有环 【解题思路】 该题为判断无向图是否有环。可以使用并查集来完成。 学习并查集时,每个元素都由一个整数来表示。而该问题中每个元素是一个坐标点&a…...
acwing3417. 砝码称重
acwing3417. 砝码称重算法 1: DFS算法2 : DP算法 1: DFS /*** 数据范围 对于 50%的评测用例,1≤N≤15. 对于所有评测用例,1≤N≤100,N 个砝码总重不超过 1e5. */ /* 算法 1: DFS 思路 : 对于每个砝码,有放在左边,放在右边,和不放三种选择,使…...
生成式 AI:百度“文心一言”对标 ChatGPT?什么技术趋势促使 ChatGPT 火爆全网?
文章目录前言一、生成式 AI 的发展和现状1.1、什么是生成式 AI?1.2、生成式 AI 的发展趋势1.3、AI 生成内容的业务场景和分类二、生成式 AI 从分析领域到创作领域2.1、 降低内容创作门槛,增加 UGC 用户群体2.2、提升创作及反馈效率,铺垫线上实…...
PCL 非线性最小二乘法拟合圆柱
文章目录 一、简介二、实现代码三、实现效果参考资料一、简介 这里通过非线性最小二乘的方法来实现圆柱体的拟合,具体的计算过程如下所述: 图中, p p p为输入数据的点位置,求解的参数为柱体的轴向向量 a...
【设计模式】迪米特法则
文章目录一、迪米特法则定义二、迪米特法则分析三、迪米特法则实例一、迪米特法则定义 迪米特法则(Law of Demeter, LoD):一个软件实体应当尽可能少地与其他实体发生相互作用。 二、迪米特法则分析 如果一个系统符合迪米特法则,那么当其中某一个模块发…...
CSS3笔试题精讲1
Q1 BFC专题 防止父元素高度坍塌 4种方案 父元素的高度都是由内部未浮动子元素的高度撑起的。 如果子元素浮动起来,就不占用普通文档流的位置。父元素高度就会失去支撑,也称为高度坍塌。 即使有部分元素留在普通文档流布局中支撑着父元素,如果浮动 起来的元素高度高于留下的…...
交叉编译用于移植的Qt库
前言 如果在Ubuntu上使用qt开发可移植到周立功开发板的应用程序,需要在Ubuntu上交叉编译用于移植的Qt库,具体做法如下: 1、下载源码 源码qt-everywhere-opensource-src-5.9.6.tar.xz拷贝到ubuntu自建的software文件下 2、解压 点击提取到此处 3、安装配置 运行脚本文…...
泰凌微TLSR8258 zigbee开发环境搭建
目录必备软件工具抓包分析辅助工具软件开发包PC 辅助控制软件 (ZGC)必备软件工具 下载地址:http://wiki.telink-semi.cn/ • 集成开发环境: TLSR8 Chips: Telink IDE for TC32 TLSR9 Chips: Telink RDS IDE for RISC-V • 下载调试工具: Telink Burning and Debugg…...
C#实现商品信息的显示异常处理
实验四:C#实现商品信息的显示异常处理 任务要求: 在进销存管理系统中,商品的库存信息有很多种类,比如商品型号、商品名称、商品库存量等。在面向对象编程中,这些商品的信息可以存储到属性中,然后当需要使…...
细数N个获取天气信息的免费 API ,附超多免费可用API 推荐(三)
前言 市面上有 N 多个查询天气信息的软件、小程序以及网页入口,基本都是通过调用天气查询 API 去实现的。 今天整理了一下多种场景的天气预报API 接口分享给大家,有需要赶紧收藏起来。 天气预报查询 天气预报查询支持全国以及全球多个城市的天气查询…...
20230404英语学习
今日单词 decade n.十年 allocate vt.分配,分派,把…拨给 compress v.压缩;缩短;浓缩 regenerate v.(使)复兴,(使)振兴;(使)再生 …...
冒泡排序 快排(hoare递归)
今天要讲一个是冒泡排序,进一个是快排,首先是冒泡排序,我相信大家接触的第一个排序并且比较有用的算法就是冒泡排序了,冒泡排序是算法里面比较简单的一种,所以我们先看看一下冒泡排序 还是个前面一样,我们…...
C++初阶-list的底层
目录 1.std::list实现的所有代码 2.list的简单介绍 2.1实现list的类 2.2_list_iterator的实现 2.2.1_list_iterator实现的原因和好处 2.2.2_list_iterator实现 2.3_list_node的实现 2.3.1. 避免递归的模板依赖 2.3.2. 内存布局一致性 2.3.3. 类型安全的替代方案 2.3.…...
微软PowerBI考试 PL300-选择 Power BI 模型框架【附练习数据】
微软PowerBI考试 PL300-选择 Power BI 模型框架 20 多年来,Microsoft 持续对企业商业智能 (BI) 进行大量投资。 Azure Analysis Services (AAS) 和 SQL Server Analysis Services (SSAS) 基于无数企业使用的成熟的 BI 数据建模技术。 同样的技术也是 Power BI 数据…...
屋顶变身“发电站” ,中天合创屋面分布式光伏发电项目顺利并网!
5月28日,中天合创屋面分布式光伏发电项目顺利并网发电,该项目位于内蒙古自治区鄂尔多斯市乌审旗,项目利用中天合创聚乙烯、聚丙烯仓库屋面作为场地建设光伏电站,总装机容量为9.96MWp。 项目投运后,每年可节约标煤3670…...
Nginx server_name 配置说明
Nginx 是一个高性能的反向代理和负载均衡服务器,其核心配置之一是 server 块中的 server_name 指令。server_name 决定了 Nginx 如何根据客户端请求的 Host 头匹配对应的虚拟主机(Virtual Host)。 1. 简介 Nginx 使用 server_name 指令来确定…...
NFT模式:数字资产确权与链游经济系统构建
NFT模式:数字资产确权与链游经济系统构建 ——从技术架构到可持续生态的范式革命 一、确权技术革新:构建可信数字资产基石 1. 区块链底层架构的进化 跨链互操作协议:基于LayerZero协议实现以太坊、Solana等公链资产互通,通过零知…...
AI书签管理工具开发全记录(十九):嵌入资源处理
1.前言 📝 在上一篇文章中,我们完成了书签的导入导出功能。本篇文章我们研究如何处理嵌入资源,方便后续将资源打包到一个可执行文件中。 2.embed介绍 🎯 Go 1.16 引入了革命性的 embed 包,彻底改变了静态资源管理的…...
JS设计模式(4):观察者模式
JS设计模式(4):观察者模式 一、引入 在开发中,我们经常会遇到这样的场景:一个对象的状态变化需要自动通知其他对象,比如: 电商平台中,商品库存变化时需要通知所有订阅该商品的用户;新闻网站中࿰…...
动态 Web 开发技术入门篇
一、HTTP 协议核心 1.1 HTTP 基础 协议全称 :HyperText Transfer Protocol(超文本传输协议) 默认端口 :HTTP 使用 80 端口,HTTPS 使用 443 端口。 请求方法 : GET :用于获取资源,…...
C#学习第29天:表达式树(Expression Trees)
目录 什么是表达式树? 核心概念 1.表达式树的构建 2. 表达式树与Lambda表达式 3.解析和访问表达式树 4.动态条件查询 表达式树的优势 1.动态构建查询 2.LINQ 提供程序支持: 3.性能优化 4.元数据处理 5.代码转换和重写 适用场景 代码复杂性…...
计算机基础知识解析:从应用到架构的全面拆解
目录 前言 1、 计算机的应用领域:无处不在的数字助手 2、 计算机的进化史:从算盘到量子计算 3、计算机的分类:不止 “台式机和笔记本” 4、计算机的组件:硬件与软件的协同 4.1 硬件:五大核心部件 4.2 软件&#…...
