python: implement planning and solving functions

Yuxian: Official account [Red Dust Lighthouse], CSDN content partner, CSDN rising star mentor, high-quality creator in the full stack field, 51CTO (Top celebrity + expert blogger), github open source enthusiast (go-zero source code secondary development, Game backend architecture https://github.com/Peakchen)

First, there are 11 columns of data in Excel, which are the scores of each sample for 10 indicators, and one column is the benchmark ranking. Now 10 weights are needed to make the sum of the product of the weight and the score under each indicator become a new column for the total score requirements for each sample. The maximum correlation between the total score ranking and the benchmark ranking requires that each weight be greater than 0 and less than 20%, and the sum of all weights is 1. It is best to use the scipy library

Detailed explanation of the principle:

The above problem is a multi-objective programming problem. The goal is to adjust the weights to maximize the correlation between the total score ranking of the sample and the benchmark ranking. This can be defined as an optimization problem. We use correlation as the objective function and optimize the weights to achieve maximum correlation.

Underlying architecture flow chart:

  1. Read data: Read sample scores and benchmark rankings from Excel files.
  2. Objective function definition: Create an objective function that calculates the total score for each sample and then calculates the correlation of the total score with the baseline ranking.
  3. Optimizer initialization: Initialize an optimizer, here use the function scipyin the library minimize.
  4. Optimization: by callingminimize</

Guess you like

Origin blog.csdn.net/feng1790291543/article/details/135462983