1. A method for photovoltaic array fault diagnosis based on a random forest algorithm, comprising:determining typical operating states of a photovoltaic array during operation, the photovoltaic array comprising n branches, each branch comprising m photovoltaic modules, wherein m and n are positive integers, m?4 and n?4;

acquiring circuit parameter groups corresponding to each branch and a trunk in the photovoltaic array, respectively, when the photovoltaic array is in each typical operating state, each circuit parameter group comprising k circuit parameters, wherein k is a positive integer;

constructing a p-dimensional fault feature vector according to the acquired n+1 circuit parameter groups, where p=k*(n+1);

constructing a data sample set of the photovoltaic array according to the fault feature vector, and dividing the data sample set into a training sample set and a test sample set;

constructing a photovoltaic array fault diagnosis model based on the random forest algorithm by using the training sample set, and testing the photovoltaic array fault diagnosis model by using the test sample set, the photovoltaic array fault diagnosis model comprising s decision trees, wherein s?2, and s is a positive integer;

diagnosing a photovoltaic array to be diagnosed by using the tested photovoltaic array fault diagnosis model to obtain voting results of the s decision trees for each typical operating state; and

obtaining a fault diagnosis result of the photovoltaic array to be diagnosed according to the voting results for each typical operating state, the fault diagnosis result being used to indicate an operating state of each branch in the photovoltaic array;

wherein when n=2 and m=3, the typical operating states of the photovoltaic array comprise five categories, and a total of twelve subcategories, which are as follows:a first category is a normal operating state, and the first category comprises one subcategory, which is a state when each photovoltaic module in each branch of the photovoltaic array is in normal operation;

a second category is a short-circuit fault state, and the second category comprises three subcategories, which are a state when one photovoltaic module in one branch of the photovoltaic array is short-circuited, a state when two photovoltaic modules in one branch of the photovoltaic array are short-circuited, and a state when one photovoltaic module in each of two branches of the photovoltaic array is short-circuited, respectively;

a third category is an open-circuit fault state, and the third category comprises one subcategory, which is a state when one branch of the photovoltaic array is open-circuited;

a fourth category is a shadow fault state, and the fourth category comprises three subcategories, which are a state when one photovoltaic module in one branch of the photovoltaic array has a shadow, a state when one photovoltaic module in each of two branches of the photovoltaic array has a shadow, a state when one photovoltaic module in one branch of the photovoltaic array has a shadow and two photovoltaic modules in the other branch have shadows, and a state when two photovoltaic modules in each of two branches of the photovoltaic array have shadows, respectively; and

a fifth category is a hybrid fault state, and the fifth category comprises four subcategories, which are a state when one branch of the photovoltaic array is open-circuited and one photovoltaic module in the other branch has a shadow, a state when one photovoltaic module in one branch of the photovoltaic array is short-circuited and one photovoltaic module in the other branch has a shadow, a state when one photovoltaic module is short-circuited and one photovoltaic module has a shadow in each of two branches of the photovoltaic array, and a state when one photovoltaic module is short-circuited and two photovoltaic modules have shadows in each of two branches of the photovoltaic array, respectively.