辅助编程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递归)
今天要讲一个是冒泡排序,进一个是快排,首先是冒泡排序,我相信大家接触的第一个排序并且比较有用的算法就是冒泡排序了,冒泡排序是算法里面比较简单的一种,所以我们先看看一下冒泡排序 还是个前面一样,我们…...

CMake基础:构建流程详解
目录 1.CMake构建过程的基本流程 2.CMake构建的具体步骤 2.1.创建构建目录 2.2.使用 CMake 生成构建文件 2.3.编译和构建 2.4.清理构建文件 2.5.重新配置和构建 3.跨平台构建示例 4.工具链与交叉编译 5.CMake构建后的项目结构解析 5.1.CMake构建后的目录结构 5.2.构…...
Leetcode 3577. Count the Number of Computer Unlocking Permutations
Leetcode 3577. Count the Number of Computer Unlocking Permutations 1. 解题思路2. 代码实现 题目链接:3577. Count the Number of Computer Unlocking Permutations 1. 解题思路 这一题其实就是一个脑筋急转弯,要想要能够将所有的电脑解锁&#x…...
Java多线程实现之Callable接口深度解析
Java多线程实现之Callable接口深度解析 一、Callable接口概述1.1 接口定义1.2 与Runnable接口的对比1.3 Future接口与FutureTask类 二、Callable接口的基本使用方法2.1 传统方式实现Callable接口2.2 使用Lambda表达式简化Callable实现2.3 使用FutureTask类执行Callable任务 三、…...

Springcloud:Eureka 高可用集群搭建实战(服务注册与发现的底层原理与避坑指南)
引言:为什么 Eureka 依然是存量系统的核心? 尽管 Nacos 等新注册中心崛起,但金融、电力等保守行业仍有大量系统运行在 Eureka 上。理解其高可用设计与自我保护机制,是保障分布式系统稳定的必修课。本文将手把手带你搭建生产级 Eur…...
什么?连接服务器也能可视化显示界面?:基于X11 Forwarding + CentOS + MobaXterm实战指南
文章目录 什么是X11?环境准备实战步骤1️⃣ 服务器端配置(CentOS)2️⃣ 客户端配置(MobaXterm)3️⃣ 验证X11 Forwarding4️⃣ 运行自定义GUI程序(Python示例)5️⃣ 成功效果
【C++进阶篇】智能指针
C内存管理终极指南:智能指针从入门到源码剖析 一. 智能指针1.1 auto_ptr1.2 unique_ptr1.3 shared_ptr1.4 make_shared 二. 原理三. shared_ptr循环引用问题三. 线程安全问题四. 内存泄漏4.1 什么是内存泄漏4.2 危害4.3 避免内存泄漏 五. 最后 一. 智能指针 智能指…...
适应性Java用于现代 API:REST、GraphQL 和事件驱动
在快速发展的软件开发领域,REST、GraphQL 和事件驱动架构等新的 API 标准对于构建可扩展、高效的系统至关重要。Java 在现代 API 方面以其在企业应用中的稳定性而闻名,不断适应这些现代范式的需求。随着不断发展的生态系统,Java 在现代 API 方…...
嵌入式常见 CPU 架构
架构类型架构厂商芯片厂商典型芯片特点与应用场景PICRISC (8/16 位)MicrochipMicrochipPIC16F877A、PIC18F4550简化指令集,单周期执行;低功耗、CIP 独立外设;用于家电、小电机控制、安防面板等嵌入式场景8051CISC (8 位)Intel(原始…...

Unity中的transform.up
2025年6月8日,周日下午 在Unity中,transform.up是Transform组件的一个属性,表示游戏对象在世界空间中的“上”方向(Y轴正方向),且会随对象旋转动态变化。以下是关键点解析: 基本定义 transfor…...

若依登录用户名和密码加密
/*** 获取公钥:前端用来密码加密* return*/GetMapping("/getPublicKey")public RSAUtil.RSAKeyPair getPublicKey() {return RSAUtil.rsaKeyPair();}新建RSAUti.Java package com.ruoyi.common.utils;import org.apache.commons.codec.binary.Base64; im…...