Evaluation model (1) Analytical hierarchy process (AHP), entropy weight method, TOPSIS analysis and their corresponding PYTHON implementation code and example explanations

Mathematical modeling series of articles:

The following are some model algorithms and codes compiled by me when preparing for the National Digital Analog Competition. I will update the content when I have time:
Evaluation Model (1) Analytic Hierarchy Process (AHP) , Entropy weight method, TOPSIS analysis and its corresponding PYTHON implementation code and explanation of examples
Evaluation model (2) Principal component analysis, factor analysis, comparison between the two and their corresponding explanation of PYTHON implementation code and examples< /span>Optimization model (2) Detailed explanation of nonlinear programming, and examples, Scipy.optimize solves nonlinear programmingOptimization model (1) Detailed explanation of linear programming, and examples, Use Python's Pulp library function to solve linear programming
Optimization model (zero) Overview, classification, analysis of various optimization models and universal problem-solving steps

article

1.1 Analytical Hierarchy Process

Insert image description here

Introduction to analytic hierarchy process:

Problem introduction:
The evaluation model is one of the most basic models and often corresponds to some very practical problems in life. For example, the college entrance examination is over, should you choose Nanjing University or Wuhan University? Knowing the concentrations of several pollutant gases in the air today, how to determine the air quality level? If you want to travel during the holidays, you have several alternative destinations. If you can only choose one, where should you go?

Basic idea:

is a multi-criteria decision-making and evaluation method that combines qualitative and quantitative methods. Decompose the relevant elements of decision-making into the target layer, criterion layer and program layer (the source of the layers), and use people's judgment to evaluate the pros and cons of the decision-making program Carry out sorting and carry out qualitative and quantitative analysis on this basis. It hierarchizes and quantifies people's thinking process, and uses mathematics to provide quantitative basis for analysis, decision-making, evaluation, forecasting and control.

The basic steps:

1. Build a hierarchical structure model;

Insert image description here

2. Construct a pairwise comparison judgment matrix;

The importance of these n indicators is definitely different. We need to determine the weight of these n indicators. Since there are many indicators, it is difficult to directly determine the weight, and the subjective factors are too strong. Therefore, the method we adopt is to compare these indicators in pairs, thereby weakening the subjective factors to a certain extent< /span>

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-yVe5pTQI-1691547591221) (D:\S\typora folder\img\image-20230804162021988.png)]

3. Consistency test ( is to determine whether the subjectively constructed pairwise comparison matrix has good consistency as a whole a>);

The consistency test result requires the CR value (CR=CI/RI) to be less than 0.1, which is used to determine whether there are logical errors when people build the judgment matrix, for example, there are three indicators ABC,We judge that A is more important than B, and B is more important than C, so logically A must be more important than C. However, if we think that C is more important than A when constructing the judgment that A is more important than C, then we have made a logical error and cannot pass the consensus. sex test.

The specific methods are as follows:

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-3VfVYavl-1691547591221) (D:\S\typora folder\img\image-20230804165156798.png)]

  1. Calculation weight;
  • There are three ways to calculate the weight.Generally, the third method will be used more, but in practical applications, the three methods can also be used. The results obtained by the method are averaged to obtain the final weight.

    • Arithmetic average method to find weight
      Insert image description here

    • Calculate weight using geometric mean method
      Insert image description here

    • Eigenvalue method to find weight
      Insert image description here

  1. Solution score (score of each solution after index weight calculation).

Example: After the college entrance examination, should I choose NTU or Wuhan University? The goal of the evaluation is to choose a school. The way to achieve the goal is to choose NTU or Wuhan University. The relevant indicators aredisciplinary strength, campus scenery, male-female ratio (indicators) Wait

  • Assume that the indicator weight has passed the consistency test and is calculated

Insert image description here

​ Score Nanda and Wuhan University according to each indicator (The score can be a hundred-point system, or It can be based on each objective, such as learning atmosphere and employment prospects, and then determine the weight score of Nanda and Wuhan University according to the analytic hierarchy process), and finally add the weighted sum< /span>, you can give a more reasonable score for the two schools.

Insert image description here

Considering that there are different indicators for different evaluation problems, their dimensions are often different, and they are not necessarily all expressed in scores. They are all measures. Therefore, for a certain indicator, when scoring different solutions, we still use "weight" as its measurement standard, and the sum of the weights is 1. As shown in the figure above, the sum of cells with the same color is 1. The indicator weight is easier to understand. Different weights are given to the indicators. The scoring is also measured by "weight". In terms of learning atmosphere, NTU is 0.6 and Wuhan University is 0.4. If we add Southeast, the learning atmosphere may be 0.3, 0.25, 0.45, and the sum is still 1. Of course, we can also use normal scoring as a measurement standard. For example, the learning atmosphere scores are 95 and 90 respectively. However, in order to make the overall calculation more convenient, "weight" is chosen as the measurement standard here, and it is hereby explained.

Advantages and Disadvantages:

advantage:

​ It completely relies on subjective evaluation to rank the pros and cons of solutions, the amount of data required less, the decision-making takes very little time. On the whole, AHP introduces quantitative analysis into the complex decision-making process, and makes full use of the preference information given by decision-makers in pairwise comparisons for analysis. and decision-making support, which not only effectively absorbs the results of qualitative analysis but also gives full play to the advantages of quantitative analysis, thus making the decision-making process highly organized and scientific., especially suitable for use in decision-making analysis of socio-economic systems.

shortcoming:

​ Using AHP to make decisions is highly subjective. When the decision-maker's judgment is too much influenced by his subjective preferences and produces some kind of distortion of the objective laws, the results of AHP are obviously unreliable. .

Scope of application:

​ It is especially suitable for situations where human qualitative judgment plays an important role and it is difficult to directly and accurately measure the decision-making results. To make the decision-making conclusions of AHP conform to objective laws as much as possible, decision-makers must have a relatively in-depth and comprehensive understanding of the problems they face. In addition, when encountering evaluation problems with many factors and large scale, this model is prone to problems. It requires the evaluator to have a thorough grasp of the nature of the problem, the elements involved and the logical relationships between them. Otherwise, the evaluation The results are unreliable and accurate.

ways to improve:

(1) The pairwise comparison matrix can be obtained by Delphi method.

(2) If there are too many evaluation indicators (generally more than 9), the weight obtained by using the analytic hierarchy process is With a certain deviation, the results of the combined evaluation model are no longer reliable. According to the actual situation and characteristics of the evaluation object, certain methods can be used to layer and classify the original indicators so thatthe number of indicators in each category is less than 9 >.

Replenish:

The Delphi method, also known as the expert survey method, was founded and implemented by the Rand Corporation in the United States in 1946. Its essence is a feedback anonymous correspondence method. Its general process is to obtain expert opinions on the issues to be predicted. Organize, summarize, and make statistics, and then anonymously feedback to the experts, solicit opinions again, focus again, and feedback again until a unanimous opinion is obtained. Purpose in evaluation: to establish evaluation indicators.

When modeling evaluation problems, three aspects often need to be considered:

  1. What is the goal of evaluation?
  2. What are the options to achieve the goal?
  3. What are the indicators/criteria for evaluation?
PYTHON代码
import numpy as np  # 导入所需包并将其命名为np
A = [[1,1,4,1/3,3],
     [1,1,4,1/3,3],
     [1/2,1/4,1,1/3,1/2],
     [3,3,3,1,3],
     [1/3,1/3,2,1/3,1]]


def ConsisTest(X):  # 函数接收一个如上述A似的矩阵
    # 计算权重
    
    # 方法一:算术平均法
    ## 第一步:将判断矩阵按照列归一化(每个元素除以其所在列的和)
    X = np.array(X)  # 将X转换为np.array对象
    sum_X = X.sum(axis=0)  # 计算X每列的和
    (n, n) = X.shape  # X为方阵,行和列相同,所以用一个n来接收
    sum_X = np.tile(sum_X, (n, 1))  # 将和向量重复n行组成新的矩阵
    stand_X = X / sum_X  # 标准化X(X中每个元素除以其所在列的和)

    ## 第二步:将归一化矩阵每一行求和
    sum_row = stand_X.sum(axis=1)

    ## 第三步:将相加后得到的向量中每个元素除以n即可得到权重向量
    print("算数平均法求权重的结果为:")
    print(sum_row / n)

    # 方法二:特征值法
    ## 第一步:找出矩阵X的最大特征值以及其对应的特征向量
    V, E = np.linalg.eig(X)  # V是特征值,E是特征值对应的特征向量
    max_value = np.max(V)  # 最大特征值
    # print("最大特征值是:",max_value)
    max_v_index = np.argmax(V)  # 返回最大特征值所在位置
    max_eiv = E[:, max_v_index]  # 最大特征值对应的特征向量

    ## 第二步:对求出的特征向量进行归一化处理即可得到权重
    stand_eiv = max_eiv / max_eiv.sum()
    print("特征值法求权重的结果为:")
    print(stand_eiv)
    print("———————————————————————————————")
    # 一致性检验
    ## 第一步:计算一致性指标CI
    CI = (max_value - n) / (n - 1)
    ## 第二步:查找对应的平均随机一致性指标RI
    RI = np.array([15, 0, 0, 0.52, 0.89, 1.12, 1.26, 1.36, 1.41, 1.46, 1.49, 1.52, 1.54, 1.56, 1.58, 1.59])
    ## 第三步:计算一致性比例CR
    CR = CI / RI[n]
    if CR < 0.1:
        print("CR=", CR, ",小于0.1,通过一致性检验")
    else:
        print("CR=", CR, ",大于等于0.1,没有通过一致性检验,请修改判断矩阵")
    return None
ConsisTest(A)

Interpretation of the paper:

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-t81i1naI-1691547591222) (D:\S\typora folder\img\image-20230806224641292.png)]

1.2 Entropy weight method

Introduction to entropy weight method:

​ The weights of the AHP are highly subjective, and in order to make the weights more objective, we use original data certain characteristics to determine the weight. The smaller the variance of a column of data, the smaller the degree of variability of the indicator, and the smaller the amount of information reflected, then the lower its weight should be at this time. The less the amount of information reflected in a column of data, the greater the information entropy . Therefore, the information entropy of the indicator is such a characteristic with excellent properties. Moreoverthe greater the information entropy, the lower the weight. (Objective = the data itself can tell us the weight)
​ The entropy weight method is just a method to determine the weight,< /span>. Generally used together with other methods (such as TOPSIS method)

Basic step
  1. Data normalization

Since each column of data may represent different categories and units of information, in order to facilitate comparison, we need to standardize the data.

Insert image description here

  • Dealing with the effects of different dimensions
  • can make the data non-negative (later calculation of probability needs to ensure that each weight is non-negative)
  1. Calculate information entropy

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-zkAjRf5L-1691547591223) (D:\S\typora folder\img\image-20230806193409827.png)]

  • The calculation of Pij ensures that the sum of the probabilities corresponding to each indicator is 1
  • Calculate the i item under the j indicator The proportion of samples and regarded as the probability used in relative entropy calculation (proportion of continuity)
  • For information entropy, the larger Ej is, the greater the information entropy is, and the less information is obtained from the jth index on the surface, The information utility value The larger dj = (1-Ej ). The greater the degree of dispersion.
  1. Calculate indicator weights

  • Calculate the information entropy of each indicator, calculate the information utility value, and normalize to obtain the entropy weight of each indicator
  1. Calculate overall score

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-RhnrEhgp-1691547591223) (D:\S\typora folder\img\image-20230806193912914.png)]

PYTHON代码
import pandas as pd
import numpy as np
import re
#定义文件读取方法
def read_data(file):
    file_path=file
    raw_data = pd.read_excel(file_path, header=0)
    #print(raw_data)
    return raw_data
 
#定义数据正向化、标准化方法
def data_normalization(data):
    data_nor=data.copy()
    columns_name=data_nor.columns.values
    for i in range((len(columns_name)-1)):
        name=columns_name[i+1]
        #print(name)
        #正向指标直接标准化
        if ('Positive' in name)==True:
            max=data_nor[columns_name[i+1]].max()
            min=data_nor[columns_name[i+1]].min()
            data_nor[columns_name[i+1]]=(data_nor[columns_name[i+1]]-min)/(max-min)
            #print(data_nor[columns_name[i+1]])
 
        #负向指标先正向化、在标准化
        if ('Negative' in name)==True:
            max0=data_nor[columns_name[i+1]].max()
            data_nor[columns_name[i+1]]=(max0-data_nor[columns_name[i+1]])#正向化
 
 
            max=data_nor[columns_name[i+1]].max()
            min=data_nor[columns_name[i+1]].min()
            data_nor[columns_name[i+1]]=(data_nor[columns_name[i+1]]-min)/(max-min)#标准化
            #print(data_nor[columns_name[i+1]])
 
        #适度指标先正向化、在标准化
        if ('Moderate' in name)==True:
            try:
                val_range= re.search(r'.*[\((](.*),(.*)[\))]',name)
                val_down= float(val_range.group(1))
                val_up= float(val_range.group(2))
                val_op=(val_up+val_down)/2
            except:
                val_range= re.search(r'.*[\((](.*)[\))]',name)
                val_op= float(val_range.group(1))
            #print(val_op)
            data_nor[columns_name[i + 1]] = 1-(abs(data_nor[columns_name[i + 1]]-val_op)/(abs(data_nor[columns_name[i + 1]]-val_op).max()))  #正向化
 
            max=data_nor[columns_name[i+1]].max()
            min=data_nor[columns_name[i+1]].min()
            data_nor[columns_name[i+1]]=(data_nor[columns_name[i+1]]-min)/(max-min)#标准化
            #print(data_nor[columns_name[i+1]])
 
    #print(data_nor)
    return data_nor
 
 
#定义计算熵权方法
def entropy_weight(data_nor):
    columns_name=data_nor.columns.values
    n=data_nor.shape[0]
    E=[]
    for i in columns_name[1:]:
 
        #计算信息熵
        #print(i)
        data_nor[i]=data_nor[i]/sum(data_nor[i])
 
        data_nor[i]=data_nor[i]*np.log(data_nor[i])
        data_nor[i]=data_nor[i].where(data_nor[i].notnull(),0)
        #print(data_nor[i])
        Ei=(-1)/(np.log(n))*sum(data_nor[i])
        E.append(Ei)
    #print(E)
    #计算权重
    W=[]
    for i in E:
        wi=(1-i)/((len(columns_name)-1)-sum(E))
        W.append(wi)
    #print(W)
    return W
 
#计算得分
def entropy_score(data,w):
    data_s=data.copy()
    columns_name=data_s.columns.values
    for i in range((len(columns_name)-1)):
        name=columns_name[i+1]
        data_s[name]=data_s[name]*w[i]
    return data_s
 
 
file='data.xls'#声明数据文件地址
data=read_data(file)#读取数据文件
data_nor=data_normalization(data)#数据标准化、正向化,生成标准化后的数据data_nor
W=entropy_weight(data_nor)#计算熵权权重
data_s=entropy_score(data,W)#计算赋权后的得分,使用原数据计算
data_nor_s=entropy_score(data_nor,W)
 
W.insert(0,'熵权法权重')#将结果保存为csv
W0=pd.DataFrame(W).T
data_s.to_csv('熵权法得分结果(原始数据).csv',index=0)
W0.to_csv('熵权法得分结果(原始数据).csv', mode='a', header=False,index=0)
data_nor_s.to_csv('熵权法得分结果(标准化数据).csv',index=0)
W0.to_csv('熵权法得分结果(标准化数据).csv', mode='a', header=False,index=0)

1.3 TOPSIS superior and inferior solution distance method

TOPSIS introduction:

TOPSIS 法(Technique for Order Preference by Similarity to Ideal Solution

It can be translated as the approximate ideal solution ranking method, which is often referred to as the distance method of superior and inferior solutions in China.

Both the analytic hierarchy process and the entropy weight method are methods for obtaining weights. After obtaining the weights, the score of each company is calculated directly through the weighted average, which does not fully utilize the data. The TOPSIS rule makes full use of the information of the original data, and its results can accurately reflect the gaps between various evaluation schemes.
Intuitive understanding is to select the maximum value (minimum value) among all indicators to form an optimal solution (worst solution). The solution that is closer to the optimal solution and farther from the worst solution is the optimal solution.

Extremely large indicators: The bigger and higher the better, also known as benefit indicators, which are generally good

Extremely small indicators: The smaller and fewer the better, also known as cost-based indicators, which are generally bad

Basic step
  1. Preliminary data processing:
  • Indicator forwarding: Very small indicators are converted into extremely large indicators max{Xi}-Xi
  • In order to eliminate the influence of different index dimensions, it is necessary to forward the matrix< /span>standardization processingCarry out
    Insert image description here
  1. Define maximum and minimum values:
    Insert image description here

  2. fixed distance:
    Insert image description here

  3. Calculate scores and normalize:
    Insert image description here

  • Through this method, we can calculate the comprehensive score of each sample, and then normalize the final score a>, from which we can getthe final ranking of each sample.
A few additional notes:

Weight:

  • First of allPay attention to the weight Wi in the formula, this is very important
  • The source of the weight can be obtained by the analytic hierarchy process. However, the entropy weight method is generally used because the analytic hierarchy process is too subjective.

The difference between normalization and standardization

Let’s talk about what it is first, then why, and then its application.

  • Normalization: is to combine the value features of a certain column in the training set (assuming it is the i-th column ) value is reduced to between 0 and 1 or -1 and 1. The method is as follows:
    Insert image description here

  • Standardization: is to compare the value features of a certain column in the training set (assumed to be the i-th column) The values ​​are scaled to a state wheremean is 0 and variance is 1. (There is also the standardization of matrices, The value of each vector is divided by the total length, such as the TOPSIS standardization method) as follows:
    Insert image description here

  • Further clarify the meaning: The same point between normalization and standardization is to a certain feature (column vertical)< a i=3> scaling instead of scaling the feature vector (row horizontal) of a certain sample. It is meaningless to horizontally scale feature vectors in machine learning, but in NLP, will be horizontally scaled because of the length of the sentence Unsure, the number of features is not necessarily aligned, which is commonly used in natural language processingLayerNormalization (layer normalization)

  • connections and effects

    • Essentially, they are performingfeature extraction, and the data are extracted by first shifting (numerator subtraction) and then scaling (denominator);
  • This is all tonarrow the scope. To facilitate subsequent data processing.

  • Speed ​​up gradient descent, loss functionconverge;—speed

  • Improve model accuracy–that is, classification accuracy. (Eliminate different dimensions to facilitate comprehensive index evaluation and improve classification accuracy)—quality

  • Prevent gradient explosion (Eliminate the output gap (0.8,999) caused by the too large data input gap (1 and 2000), which in turn causes the problem of backpropagation In the process, the gradient is too large (because the gradient calculation during the backpropagation process will use the input x of the previous corresponding layer), thus forming a gradient explosion) - stability

  • Comparative analysis of standardization and normalization:

    • Normalization: Mainly used in places where there is no distance calculation ( loses distribution and distance, retains weight information) - singular data, Small data scenario

    • Standardization: Mainly used in places where weight is not relevant ( retains distribution and distance, loses weight information, used at the beginning) —- Distance is needed to measure similarity, with outliers and noise

    • eg:

      For example, in three samples, the value of a certain feature is 1, 2, and 10000. Assuming that the value 10000 is an outlier, after using the normalization method, the normal 1 and 2 will be "squeezed" together. If unfortunately the classification labels of 1 and 2 are still opposite, then when we use gradient descent to train the classification model, the model will take longer to converge because it requires greater effort to separate the samples! Standardization does a good job in this regard, at least it does not "crowd" the samples together.

  • Which algorithms require normalization/standardization:

    • Sometimes, we mustfeatures between 0 and 1, in this case we can only use normalization (). The first step of the entropy weight method
  • Algorithms involving or implying distance calculationClassification and clustering, such as K-means ( Normalization), KNN (standardization), PCA (normalization), SVM (normalization), etc., generally need to perform normalization/standardization.

  • Gradient descent algorithm, the convergence speed of gradient descent depends on: the distance from the initial position of the parameter to the local minima, and the size of the learning rate eta, which is actually the calculation of the distance.

  • Use sigmoid etc.Activation function with saturation zone. If the input distribution range is very wide and the parameters are not properly adapted during initialization, it will be easy. Directly falling into the saturation zone, causing the gradient to disappear, so various BN, LN and other algorithms appear.

  • If the data is not stable and there are extreme maximum and minimum values, do not use normalization. Standardization can be used. As in the above example.

  • Which algorithms do not require normalization/standardization:

    • Features with values ​​​​of 0/1 will destroy sparsity if normalized;
    • Probabilistic models unrelated to distance calculations are not required, such as Naive Bayes;
    • Tree-based models that have nothing to do with distance calculations, such as decision trees, random forests, etc. The selection of nodes in the tree only focuses on where the current feature is better for classification, that is, it only cares about the relative size within the feature. It has nothing to do with the relative size of the features. The tree model does not care about the specific values ​​of the features, only cares about the distribution of feature values

The four most common indicators &&methods for converting to extremely large sizes:

Insert image description here

Insert image description here

Insert image description here

瀻结TOPSIS:

TOPSIS can be summarized by the following formulas:

Insert image description here
The basic process of the TOPSIS method is to first unify the original data matrix with the indicator type (general forward processing) to obtain the forwarded matrix , then perform standardization on the forwarding matrix to eliminate the influence of each index dimension, and find a limited solution The best plan and the worst plan in , and then calculate the distance between each evaluation object and the best plan and the worst plan respectively< a i=8>, Obtain the relative closeness of each evaluation object to the optimal solution , which is used as the basis for evaluating the merits. This method has no strict restrictions on data distribution and sample content, and data calculation is simple and easy.

Personal understanding: Find the optimal and worst values ​​of all factors to form a multi-dimensional The optimal vector and the worst vector, and then calculate the distance between the optimal value and the vector of the worst value for each sample, the further away is from the worst vector The higher the sample ranking (score).

论文解读

Insert image description here

Example
  • This one is relatively typical, including extremely large, extremely small, intermediate, and interval indicators.

Insert image description here

PYTHON code:
# 导入分析库
import pandas as pd
import numpy as np

##导入数据
df = pd.read_excel(r'D:\S\20条河流的水质情况数据.xls')
print(df.head(5))  # 查看头5条数据
# 极小型指标 -> 极大型指标
def Mintomax(datas):
    return np.max(datas) - datas

df['细菌总数(个/mL)'] = Mintomax(df['细菌总数(个/mL)'])  # 极小型指标 -> 极大型指标
df.head()  # 查看

# 中间型指标 -> 极大型指标
def Midtomax(datas, x_best):
    temp_datas = datas - x_best
    M = np.max(abs(temp_datas))
    answer_datas = 1 - abs(datas - x_best) / M
    return answer_datas
df['PH值'] = Midtomax(df['PH值'], 7)  # 中间型指标 -> 极大型指标 7为最佳值

# 区间型指标 -> 极大型指标
def Intertomax(datas, x_min, x_max):
    M = max(x_min - np.min(datas), np.max(datas) - x_max)
    answer_list = []
    for i in datas:
        if (i < x_min):
            answer_list.append(1 - (x_min - i) / M)
        elif (i > x_max):
            answer_list.append(1 - (i - x_max) / M)
        else:
            answer_list.append(1)
    return np.array(answer_list)
df['植物性营养物量(ppm)'] = Intertomax(df['植物性营养物量(ppm)'], 10, 20)  # 区间型指标 -> 极大型指标
# 正向化矩阵标准化(去除量纲影响)
def Standard(datas):
    k = np.power(np.sum(pow(datas, 2), axis=0), 0.5)
    for i in range(len(k)):
        datas[:, i] = datas[:, i] / k[i]
    return datas


label_need = df.keys()[1:]
data = df[label_need].values  # 刨除变量名后的数据值
sta_data = Standard(data)  # 正向化矩阵标准化(去除量纲影响)
# 正向化和标准化
print(sta_data)
# 10为下界,20为上界

# 计算得分并归一化
def Score(sta_data):
    z_max = np.amax(sta_data, axis=0)
    z_min = np.amin(sta_data, axis=0)
    # 计算每一个样本点与最大值的距离
    tmpmaxdist = np.power(np.sum(np.power((z_max - sta_data), 2), axis=1), 0.5)
    tmpmindist = np.power(np.sum(np.power((z_min - sta_data), 2), axis=1), 0.5)
    score = tmpmindist / (tmpmindist + tmpmaxdist)
    score = score / np.sum(score)  # 归一化处理
    return score


sco = Score(sta_data)  # 计算得分
print(sco)

1.4 References:

Mathematical Modeling Notes - Evaluation Model (1)
Evaluation Problems in Mathematical Modeling
AHP Code
Analytic hierarchy process, practical example
PYthon implements entropy weight
TOPSIS method - using original data for comprehensive evaluation
Normalization and standardization
Normalization and standardization of machine learning interviews
Standardization and normalization of machine learning data features
Standardization and normalization, do not confuse them together, thoroughly understand data transformation
Evaluation issues in mathematical modeling

Guess you like

Origin blog.csdn.net/m0_63669388/article/details/132182382