当前位置: 首页 > news >正文

辅助编程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递归)

今天要讲一个是冒泡排序,进一个是快排,首先是冒泡排序,我相信大家接触的第一个排序并且比较有用的算法就是冒泡排序了,冒泡排序是算法里面比较简单的一种,所以我们先看看一下冒泡排序 还是个前面一样,我们…...

49天精通Java,第24天,Java链表、散列表、HashSet、TreeSet

目录一、链表二、散列表三、HashSet四、TreeSet五、TreeSet常用方法大家好,我是哪吒。 一、链表 从数组中间删除一个元素开销很大,其原因是向数组中插入元素时,此元素之后的所有元素都要向后端移动,删除时也是,数组中…...

HashMap源码分析小结

HashMap相关问题 HashMap实现原理 HashMap是以键值对的形式存储数据,内部是通过数组链表结构实现,在1.7之后的版本,链表结构可以升级为红黑树,提高查询效率 key和value都支持为null;key为null时hash值是0&#xff0…...

太奇怪了!小公司面试全挂,大厂面试全过,为什么小公司要求比大厂还高?...

大厂的人才去小公司面试,一定是降维打击吗?还真未必。一位网友很困惑:真的奇怪,小公司面试全挂,大厂面试10个过了9个,感觉小公司要求比大厂还高,这是怎么了?来看看网友们的看法。有人…...

Java开发环境配置

Java开发环境配置 Java是目前世界上最流行的编程语言之一,它的使用范围广泛,从Web应用程序到桌面应用程序再到移动应用程序,Java都是一种非常有用的语言。想要进行Java开发,首先需要在计算机上配置Java开发环境。 在本文中&…...

大学英语视听说教程(陈向京版本)

词汇题(55道) 1. You should carefully think over_____ the manager said at the meeting. A. that B. which C. what D. whose 1.选C,考察宾语从句连接词,主句谓语动词think over后面缺宾语,后面的宾语从句谓语动…...

nginx--开源免费

nginx开源免费,支持高性能,高并发的web服务和代理服务软件。 apache,nodejs nginx可以提供的服务: 1、web服务 2、负载均衡(反向代理)(动静分离) 3、web cache(web缓存) nginx…...

阿里云OSS对象存储

目录 1:OSS 1.1:开通OSS服务 1.2:搭建OSS环境 1.2.1:创建Bucket存储空间 1.2.2:创建文件夹上传图片 1.2.3:RAM访问控制 1.3:快速入门 1.3.1:下载SDK 1.3.2:搭建环…...

基于VHDL语言的汽车测速系统设计_kaic

摘 要 汽车是现代交通工具。车速是一项至关重要的指标。既影响着汽车运输的生产率,又关乎着汽车行驶有没有超速违章,还影响着汽车行驶时人们的人身安全。而伴随着我国国民的安全防范意识的逐步增强,人们也开始越来越关心因为汽车的超速而带来的极其严重…...

【数据结构】单链表(笔记总结)

👦个人主页:Weraphael ✍🏻作者简介:目前学习C和算法 ✈️专栏:数据结构 🐋 希望大家多多支持,咱一起进步!😁 如果文章对你有帮助的话 欢迎 评论💬 点赞&…...

Git操作之 git add 撤销、git commit 撤销

1、git add 添加多余文件 撤销操作 git reset HEAD 后面什么都不跟的,就是上一次add 里面的内容全部撤销 git reset HEAD XXX 后面跟文件名,就是对某个文件进行撤销 2、git commit 撤销操作 git reset --soft HEAD^ 这样就成功的撤销了commit操作 注…...