当前位置: 首页 > 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递归)

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

React第五十七节 Router中RouterProvider使用详解及注意事项

前言 在 React Router v6.4 中&#xff0c;RouterProvider 是一个核心组件&#xff0c;用于提供基于数据路由&#xff08;data routers&#xff09;的新型路由方案。 它替代了传统的 <BrowserRouter>&#xff0c;支持更强大的数据加载和操作功能&#xff08;如 loader 和…...

智慧工地云平台源码,基于微服务架构+Java+Spring Cloud +UniApp +MySql

智慧工地管理云平台系统&#xff0c;智慧工地全套源码&#xff0c;java版智慧工地源码&#xff0c;支持PC端、大屏端、移动端。 智慧工地聚焦建筑行业的市场需求&#xff0c;提供“平台网络终端”的整体解决方案&#xff0c;提供劳务管理、视频管理、智能监测、绿色施工、安全管…...

在四层代理中还原真实客户端ngx_stream_realip_module

一、模块原理与价值 PROXY Protocol 回溯 第三方负载均衡&#xff08;如 HAProxy、AWS NLB、阿里 SLB&#xff09;发起上游连接时&#xff0c;将真实客户端 IP/Port 写入 PROXY Protocol v1/v2 头。Stream 层接收到头部后&#xff0c;ngx_stream_realip_module 从中提取原始信息…...

用docker来安装部署freeswitch记录

今天刚才测试一个callcenter的项目&#xff0c;所以尝试安装freeswitch 1、使用轩辕镜像 - 中国开发者首选的专业 Docker 镜像加速服务平台 编辑下面/etc/docker/daemon.json文件为 {"registry-mirrors": ["https://docker.xuanyuan.me"] }同时可以进入轩…...

技术栈RabbitMq的介绍和使用

目录 1. 什么是消息队列&#xff1f;2. 消息队列的优点3. RabbitMQ 消息队列概述4. RabbitMQ 安装5. Exchange 四种类型5.1 direct 精准匹配5.2 fanout 广播5.3 topic 正则匹配 6. RabbitMQ 队列模式6.1 简单队列模式6.2 工作队列模式6.3 发布/订阅模式6.4 路由模式6.5 主题模式…...

【网络安全】开源系统getshell漏洞挖掘

审计过程&#xff1a; 在入口文件admin/index.php中&#xff1a; 用户可以通过m,c,a等参数控制加载的文件和方法&#xff0c;在app/system/entrance.php中存在重点代码&#xff1a; 当M_TYPE system并且M_MODULE include时&#xff0c;会设置常量PATH_OWN_FILE为PATH_APP.M_T…...

02.运算符

目录 什么是运算符 算术运算符 1.基本四则运算符 2.增量运算符 3.自增/自减运算符 关系运算符 逻辑运算符 &&&#xff1a;逻辑与 ||&#xff1a;逻辑或 &#xff01;&#xff1a;逻辑非 短路求值 位运算符 按位与&&#xff1a; 按位或 | 按位取反~ …...

Python常用模块:time、os、shutil与flask初探

一、Flask初探 & PyCharm终端配置 目的: 快速搭建小型Web服务器以提供数据。 工具: 第三方Web框架 Flask (需 pip install flask 安装)。 安装 Flask: 建议: 使用 PyCharm 内置的 Terminal (模拟命令行) 进行安装,避免频繁切换。 PyCharm Terminal 配置建议: 打开 Py…...

高端性能封装正在突破性能壁垒,其芯片集成技术助力人工智能革命。

2024 年&#xff0c;高端封装市场规模为 80 亿美元&#xff0c;预计到 2030 年将超过 280 亿美元&#xff0c;2024-2030 年复合年增长率为 23%。 细分到各个终端市场&#xff0c;最大的高端性能封装市场是“电信和基础设施”&#xff0c;2024 年该市场创造了超过 67% 的收入。…...

五、jmeter脚本参数化

目录 1、脚本参数化 1.1 用户定义的变量 1.1.1 添加及引用方式 1.1.2 测试得出用户定义变量的特点 1.2 用户参数 1.2.1 概念 1.2.2 位置不同效果不同 1.2.3、用户参数的勾选框 - 每次迭代更新一次 总结用户定义的变量、用户参数 1.3 csv数据文件参数化 1、脚本参数化 …...