我正在使用gplearn库(遗传编程)从给定数据集生成新规则。目前,我有11行数据,其中包含24列(功能),我将其作为SymbolicRegressor方法的输入来获取新规则。但是,我只得到一条规则。一般情况下,如果我提供11行数据作为输入,那么我不会得到11个新规则。如果我做错了什么是正确的做法?
import numpy as np
import pandas as pd
from sklearn import preprocessing
from sklearn.model_selection import GridSearchCV
from sklearn.ensemble import ExtraTreesRegressor
from gplearn.genetic import SymbolicRegressor
data = pd.read_csv("D:/Subjects/Thesis/snort_rules/ransomware_dataset.csv")
x_train = data.iloc[:,0:23]
y_train = data.iloc[:,:-1]
gp = SymbolicRegressor(population_size=11,
generations=2, stopping_criteria=0.01,
p_crossover=0.8, p_subtree_mutation=0.1,
p_hoist_mutation=0.05, p_point_mutation=0.05,
max_samples=0.9, verbose=1,
parsimony_coefficient=0.01, random_state=0)
gp.fit(x_train, y_train)
print(gp._program)
输出结果为:
X7 /(X15 *( - X16 * X20 - X19 + X2))