18 things ChatGPT can do! With source code

  ChatGPT has been soaring for 160 days, and the world is no longer what it used to be.
I have created a new artificial intelligence Chinese website
https://ai.weoknow.com
to update the available chatGPT resources available in China every day


I have sorted out 18 ways to use ChatGPT for everyone, and see which methods you can get.

  • grammar correction

  • text translation

  • language conversion

  • code explanation

  • Fix code errors

  • as an encyclopedia

  • information extraction

  • chat with friends

  • idea generator

  • interview questions

  • Thesis outline

  • story creation

  • problem analogy

  • Create SQL requirements

  • emotion analysis

  • Turn product descriptions into ads

  • keyword extraction

  • chatbot

grammar correction

Purpose: Polishing articles, papers, etc.

text translation

Uses: daily study, business translation, etc.

language conversion

Python–>JAVA

Purpose: For work purposes, it is more convenient for cooperation between different language engineers.

import numpy as np
import plotly.express as px

def thresholding_algo(y, lag, threshold):
    """
    :param y: 输入列表
    :param lag: 滑动窗口大小
    :param threshold: 调节系数,用于调节容忍范围的大小。
    :return:
    """
    # signals:信号列表
    signals = np.zeros(len(y))
    avgFilter = np.zeros(len(y))

    # 初始化平均值列表、差值列表
    avgFilter[lag - 1] = np.mean(y[0:lag])
    dif_li = [0] * len(y)

    for i in range(lag, len(y)):
        if i < len(y) - lag - 30:
            for j in range(i + 11, len(y)):
                if y[j] >= y[i - 1]:
                    break
            if j >= len(y) - 30:
                back = y[i - 1]
            else:
                back = np.mean(y[j + 11:j + 20 + lag])
        else:
            back = y[i - 1]

        # 前后均值差值计算
        tmp = abs(back - avgFilter[i - 1])
        dif = (tmp if tmp > 1 else 1)

        if abs(y[i] - avgFilter[i - 1]) > dif * threshold:
            signals[i] = (1 if y[i] > avgFilter[i - 1] else -1)
            avgFilter[i] = np.mean(y[(i - lag):i])
            y[i] = avgFilter[i - 1]
        else:
            signals[i] = 0
            avgFilter[i] = np.mean(y[(i - lag):i])

        dif_li[i] = dif

    return dict(signals=np.asarray(signals),
                avgFilter=np.asarray(avgFilter),
                y=np.asarray(y),
                dif=np.asarray(dif_li),
                )

public static Map<String, double[]> thresholding_algo(double[] y, int lag, double threshold) {

    double[] signals = new double[y.length];
    double[] avgFilter = new double[y.length];
    Arrays.fill(avgFilter, 0.0);

    avgFilter[lag - 1] = mean(Arrays.copyOfRange(y, 0, lag));
    double[] dif_li = new double[y.length];
    Arrays.fill(dif_li, 0.0);

    for (int i = lag; i < y.length; i++) {
        int j;
        if (i < y.length - lag - 30) {
            for (j = i + 11; j < y.length; j++) {
                if (y[j] >= y[i - 1]) {
                    break;
                }
            }
            double back;
            if (j >= y.length - 30) {
                back = y[i - 1];
            } else {
                back = mean(Arrays.copyOfRange(y, j + 11, j + 20 + lag));
            }
        } else {
            back = y[i - 1];
        }

        double tmp = Math.abs(back - avgFilter[i - 1]);
        double dif = tmp > 1 ? tmp : 1;

        if (Math.abs(y[i] - avgFilter[i - 1]) > dif * threshold) {
            signals[i] = y[i] > avgFilter[i - 1] ? 1 : -1;
            avgFilter[i] = mean(Arrays.copyOfRange(y, i - lag, i));
            y[i] = avgFilter[i - 1];
        } else {
            signals[i] = 0;
            avgFilter[i] = mean(Arrays.copyOfRange(y, i - lag, i));
        }

        dif_li[i] = dif;
    }

    Map<String, double[]> result = new HashMap<>();
    result.put("signals", signals);
    result.put("avgFilter", avgFilter);
    result.put("y", y);
    result.put("dif", dif_li);

    return result;
}

private static double mean(double[] array) {
    double sum = 0.0;
    for (double d : array) {
        sum += d;
    }
    return sum / array.length;
}

Code Explanation-1

Purpose: When we come to a new company and find that the former engineer has left a pile of codes that no one can understand, at this time, if someone can help us explain what these codes mean, then we will not be too happy.

def Fusion_algorithm(y_list):
    """
    最终的融合算法
    1、第一次遍历列表: 处理掉小于上一个值的点,使其等于上一个值。
    2、第二次使用z-score来处理异常点:一种基于统计方法的时序异常检测算法借鉴了一些经典的统计方法,比如Z-score和移动平均线
    该算法将时间序列中的每个数据点都看作是来自一个正态分布,通过计算每个数据点与其临接数据点的平均值和标准差,可以获得Z-score
    并将其用于检测异常值,将z-score大于3的数据点视为异常值,缺点:如果异常点太多,则该算法的准确性较差。
    3、
    :param y_list: 传入需要处理的时间序列
    :return:
    """
    # 第一次处理
    for i in range(1, len(y_list)):
        difference = y_list[i] - y_list[i - 1]
        if difference <= 0:
            y_list[i] = y_list[i - 1]
        # 基于突变检测的方法:如果一个数据点的值与前一个数据点的值之间的差异超过某个阈值,
        # 则该数据点可能是一个突变的异常点。这种方法需要使用一些突变检测算法,如Z-score突变检测、CUSUM(Cumulative Sum)
        # else:
        #     if abs(difference) > 2 * np.mean(y_list[:i]):
        #         y_list[i] = y_list[i - 1]

    # 第二次处理
    # 计算每个点的移动平均值和标准差
    ma = np.mean(y_list)
    # std = np.std(np.array(y_list))
    std = np.std(y_list)
    # 计算Z-score
    z_score = [(x - ma) / std for x in y_list]
    # 检测异常值
    for i in range(len(y_list)):
        # 如果z-score大于3,则为异常点,去除
        if z_score[i] > 3:
            print(y_list[i])
            y_list[i] = y_list[i - 1]

    return y_list

Code Explanation-2

Remarks: In the previous code explanation, we can see that the answer may be affected by the comments in the code. Let's delete the comments and try again. For some points in the explanation that we don't understand, we can continue to ask!

import numpy as np
from sklearn.ensemble import IsolationForest
import plotly.express as px
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
import json

def Fusion_algorithm(y_list):
    for i in range(1, len(y_list)):
        difference = y_list[i] - y_list[i - 1]
        if difference <= 0:
            y_list[i] = y_list[i - 1]
    
        # else:
        #     if abs(difference) > 2 * np.mean(y_list[:i]):
        #         y_list[i] = y_list[i - 1]


    ma = np.mean(y_list)
    std = np.std(y_list)
    z_score = [(x - ma) / std for x in y_list]
    for i in range(len(y_list)):
        if z_score[i] > 3:
            print(y_list[i])
            y_list[i] = y_list[i - 1]

    return y_list

Fix code errors

Purpose: Find an error after writing a piece of code? Let chatGPT help you!

### Buggy Python
import Random
a = random.randint(1,12)
b = random.randint(1,12)
for i in range(10):
    question = "What is "+a+" x "+b+"? "
    answer = input(question)
    if answer = a*b
        print (Well done!)
    else:
        print("No.")

as an encyclopedia

Uses: chatGPT can explain all your questions! But the function of listing novels is a bit stretched. After testing, only the science fiction column is okay, and other genres are not so good. Maybe the chatgpt training engineer is a science fiction fan!

information extraction

Purpose: As a large model in the field of natural language processing, how can information extraction be missing?

chat with friends

Purpose: Enter the character of the other party to simulate chatting. The function in this aspect is not perfect, and there may be new ways to play that I haven't discovered yet.

idea generator

Purpose: Do you often encounter thinking bottlenecks in innovation and don't know how to do it? Don't worry, let chatGPT help you generate ideas!

Combination of VR and Chamber of Secrets

Combined with AR

interview questions

Purpose: Maybe you are a media worker and don't know how to write interview questions? chatGPT can help you solve it.

interview question list

List of interview questions and give corresponding answers

Thesis outline

Purpose: This function is really not too cool for graduate students. I have been depressed about how to write the outline. Listing the outline directly has really helped me a lot! For points that are not understood in the outline, directly ask chatGPT for further explanation. Codes are also available! The content of that chapter is not very good at writing, so let chatGPT arrange it directly, so that a paper will be written soon!

Create a thesis outline

explain the content of the outline

class PBA(nn.Module):
    def __init__(self, PerformanceThreshold, DistributionType, AttentionWeightRange):
        super(PBA, self).__init__()
        self.PerformanceThreshold = PerformanceThreshold
        self.DistributionType = DistributionType
        self.AttentionWeightRange = AttentionWeightRange
        
    def forward(self, input, performance_scores):
        # 计算注意力分数
        attention_scores = []
        for i in range(len(input)):
            if performance_scores[i] > self.PerformanceThreshold:
                attention_scores.append(performance_scores[i])
            else:
                attention_scores.append(0.0)
                
        # 将性能分数映射到注意力权重
        if self.DistributionType == "softmax":
            attention_weights = F.softmax(torch.tensor(attention_scores), dim=0)
        elif self.DistributionType == "sigmoid":
            attention_weights = torch.sigmoid(torch.tensor(attention_scores))
        else:
            raise ValueError("Unknown distribution type: {}".format(self.DistributionType))
        
        # 缩放注意力权重到指定范围
        attention_weights = attention_weights * (self.AttentionWeightRange[1] - self.AttentionWeightRange[0]) + self.AttentionWeightRange[0]
        
        # 计算加权输入
        weighted_input = torch.mul(input, attention_weights.unsqueeze(1).expand_as(input))
        output = torch.sum(weighted_input, dim=0)
        
        return output

story creation

Purpose: This function is really awesome. I can write novels after I make an outline myself!

love story

horror story

problem analogy

Uses: This is a great feature when you want to make a metaphor.

Create SQL requirements

Purpose: Writing SQL is sometimes a headache, and I can't remember it for a long time.

emotion analysis

Purpose: This function reminds me of the sentiment analysis task I did in the previous company.

Turn product descriptions into ads

Uses: This feature is awesome for merchants.

keyword extraction

Purpose: The important role of NLP tasks, keyword extraction!

chatbot

Purpose: Not much to say about this, it’s really good experience for chatting.


  ChatGPT has been soaring for 160 days, and the world is no longer what it used to be.
I have created a new artificial intelligence Chinese website
https://ai.weoknow.com
to update the available chatGPT resources available in China every day

Guess you like

Origin blog.csdn.net/zyqytsoft/article/details/130916270