辅助编程coding的两种工具:Github Copilot、Cursor

这篇具有很好参考价值的文章主要介绍了辅助编程coding的两种工具:Github Copilot、Cursor。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

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/
辅助编程coding的两种工具:Github Copilot、Cursor

使用技巧:

https://twitter.com/amanrsanger

CHAT:

example 1:

辅助编程coding的两种工具:Github Copilot、Cursor
辅助编程coding的两种工具:Github Copilot、Cursor
辅助编程coding的两种工具:Github Copilot、Cursor
辅助编程coding的两种工具:Github Copilot、Cursor
辅助编程coding的两种工具:Github Copilot、Cursor

注意:

对于上面最后一张图的中的代码,如果直接在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 pd

data = {'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 variable

    The variance inflation factor is a measure for the increase of the
    variance of the parameter estimates if an additional variable, given by
    exog_idx is added to the linear regression. It is a measure for
    multicollinearity of the design matrix, exog.

    One recommendation is that if VIF is greater than 5, then the explanatory
    variable given by exog_idx is highly collinear with the other explanatory
    variables, and the parameter estimates will have large standard errors
    because of this.

    Parameters
    ----------
    exog : {ndarray, DataFrame}
        design matrix with all explanatory variables, as for example used in
        regression
    exog_idx : int
        index of the exogenous variable in the columns of exog

    Returns
    -------
    float
        variance inflation factor

    Notes
    -----
    This function does not save the auxiliary regression.

    See Also
    --------
    xxx : class for regression diagnostics  TODO: does not exist yet

    References
    ----------
    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_idx
    x_noti = exog[:, mask]
    r_squared_i = OLS(x_i, x_noti).fit().rsquared
    vif = 1. / (1. - r_squared_i)
    return vif

example 2:

辅助编程coding的两种工具:Github Copilot、Cursor

辅助编程coding的两种工具:Github Copilot、Cursor
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.

辅助编程coding的两种工具:Github Copilot、Cursor
目前有个人版、商业版和教育版三种,教育版里面学生账户比教师账户的免费功能更多,只需要一个学校邮箱和一卡通就可以认证学生账户或者教师账户,还是很方便。

以插件方式安装

pycharm

辅助编程coding的两种工具:Github Copilot、Cursor
辅助编程coding的两种工具:Github Copilot、Cursor
辅助编程coding的两种工具:Github Copilot、Cursor

自动写代码

以下代码除了第一行注释都是copilot自动补全的

example 1:写一个mysql取数据的类

# 写一个mysql取数据的类
import pymysql
class Mysql:
    def __init__(self,host,user,password,database,port=3306):
        self.host = host
        self.user = user
        self.password = password
        self.database = database
        self.port = port
        self.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 = df
    def 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.columns
        return vif
    def 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跑一遍看它生成的代码是否符合你的描述或者数学原理。具体原因见上文的注意文章来源地址https://www.toymoban.com/news/detail-422730.html

到了这里,关于辅助编程coding的两种工具:Github Copilot、Cursor的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • CodeGeeX、CodeWhisperer、Github Copilot三款AI辅助编程工具,程序员该如何选择?

    亚马逊今天在Re:Mars大会上宣布推出CodeWhisperer,这是一款类似于 CodeGeeX 和GitHub Copilot的AI辅助编程工具,它根据一个注释或几个按键来自动补全整个函数。目前支持Java、JavaScript和Python,和 CodeGeeX 一样,使用了数十亿行公开可用的开源代码、自己的代码库、公开可用的文档和公

    2023年04月16日
    浏览(29)
  • AI辅助编程,GitHub copilot chat 体验

    最近,看到很多大佬分享 GitHub copilot chat ,据说能够让效率翻倍,抱着不相信,打假的心态我也弄一个,体验一下,结果真的很赞,下面分享使用 GitHub copilot chat 的过程 ​ 首先,我们需要先了解一下 GitHub copilot chat 是一个什么东西,GitHub Copilot 是一个AI驱动的代码完成工具,

    2024年02月17日
    浏览(16)
  • AI 辅助编程工具,会编程和不会编程的人都需要!附Cursor 保姆级使用教程

      我是卷了又没卷,薛定谔的卷的AI算法工程师「陈城南」。 自 AI 技术被应用到辅助编程工具中后,编程的门槛被大幅降低,会编程和不会编程的人都需要得接触一下来提高自己的日常生产力! 程序员群体 可以通过 AI 编程助手大幅提高自己的工作效率,编写重复且低效的代

    2024年02月06日
    浏览(29)
  • 探索编程新纪元:Code GeeX、Copilot与通义灵码的智能辅助之旅

    在人工智能技术日新月异的今天,编程领域的革新也正以前所未有的速度推进。新一代的编程辅助工具,如Code GeeX、Copilot和通义灵码,正在重塑开发者的工作流程,提升编程效率,并推动编程教育的普及。本文将深入探讨这三款工具的特点、优势与局限,为开发者提供一份详

    2024年03月17日
    浏览(27)
  • 【AGI】Copilot AI编程辅助工具安装教程

    1. 基础激活教程 GitHub和OpenAI联合为程序员们送上了编程神器——GitHub Copilot。 但是,Copilot目前不提供公开使用,需要注册账号通过审核,我也提交了申请:这里第一期记录下,开启教程,欢迎大佬们来讨论交流。 第一步:Github开启copilot权限(已开启的 请忽略此步) copilo

    2024年02月13日
    浏览(21)
  • ChatGPT4.0知识问答、DALL-E生成AI图片、Code Copilot辅助编程,打开新世界的大门

    支持在线修改和图片导出。走一个~ (1)画一个会飞的猪 (2)通过选择select,对会飞的猪进行润色 (3)画一个花色翅膀 (4)来一个难的,根据斗罗大陆的设定,添加一个十万年魂环,哈哈 我记得金色魂环是百万年的了,哈哈。不过还可以理解。 (5)根据斗罗大陆的设计

    2024年04月29日
    浏览(15)
  • 如何在VS Code中运用GitHub Copilot提高编程效率

    本文首发于公众号:更AI (power_ai),欢迎关注,编程、AI干货及时送! GitHub Copilot是一个AI配对编程工具。这是一个花哨的说法,称它为\\\"第二程序员\\\",它在你的源代码编辑器内部工作。在你编写代码时,Copilot会以自动完成的方式给出建议,帮助你更快、更有效地编写代码。 本文

    2024年02月16日
    浏览(25)
  • AI代码辅助工具codeium,替代 codota 或Tabnie ,或github收费的 copilot

    官网例子-安装登录和使用 能学习你的代码,给出你自己已写过的老代码提示,减少很多 复制粘贴工作 对python 的支持很好,比如 输入 def fib(n): ,即可一直 tab 生成 完整的代码 我尝试在java 中的注释部分,生成如上代码,ok 尝试直接在java 定义fib 函数,不知道怎么弄,失败

    2023年04月22日
    浏览(17)
  • 测试了Copilot辅助编程后,就离不开这个AI工具了

    微软用·chatGPT 4· 对·github copilot X·升级后,本是怀着赠热点的心态测试了一下其功能。但 Copilot 智能化程度之高,令我吃惊,两周下来已离开不这个工具了。 下面简单分享一下其使用过程,以及对如何使用好这个工具的个人看法. IDE开发环境我使用的是 VSCode 与 Visual Studio2

    2024年02月06日
    浏览(21)
  • 倚天屠龙:Github Copilot vs Cursor

    武林至尊,宝刀屠龙。号令天下,莫敢不从。倚天不出,谁与争锋! 作为开发人员吃饭的家伙,一款好的开发工具对开发人员的帮助是无法估量的。还记得在学校读书的时候,当时流行CS架构的RAD,Delphi和VisualBasic大行其道。就因为Delphi开发快,即使原来没学过Pascal(当时都

    2024年02月05日
    浏览(19)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包