import numpy as npimport pandas as pdfrom sklearn.ensemble import RandomForestClassifierfrom sklearn.linear_model import LogisticRegressionfrom sklearn.model_selection import train_test_splitfrom sklearn.pipeline import make_pipeline, make_unionfrom sklearn.preprocessing import PolynomialFeaturesfrom tpot.builtins import StackingEstimatorfrom tpot.export_utils import set_param_recursive# NOTE: Make sure that the outcome column is labeled 'target' in the data filetpot_data = pd.read_csv('PATH/TO/DATA/FILE', sep='COLUMN_SEPARATOR', dtype=np.float64)features = tpot_data.drop('target', axis=1)training_features, testing_features, training_target, testing_target = \ train_test_split(features, tpot_data['target'], random_state=42)# Average CV score on the training set was: 0.9799428471757372exported_pipeline = make_pipeline( PolynomialFeatures(degree=2, include_bias=False, interaction_only=False), StackingEstimator(estimator=LogisticRegression(C=0.1, dual=False, penalty="l1")), RandomForestClassifier(bootstrap=True, criterion='entropy', max_features=0.35000000000000003, min_samples_leaf=20, min_samples_split=19, n_estimators=100))# Fix random state for all the steps in exported pipelineset_param_recursive(exported_pipeline.steps, 'random_state', 42)exported_pipeline.fit(training_features, training_target)results = exported_pipeline.predict(testing_features)
import numpy as npimport pandas as pdfrom sklearn.ensemble import ExtraTreesRegressorfrom sklearn.model_selection import train_test_splitfrom sklearn.pipeline import make_pipelinefrom sklearn.preprocessing import PolynomialFeaturesfrom tpot.export_utils import set_param_recursive# NOTE: Make sure that the outcome column is labeled 'target' in the data filetpot_data = pd.read_csv('PATH/TO/DATA/FILE', sep='COLUMN_SEPARATOR', dtype=np.float64)features = tpot_data.drop('target', axis=1)training_features, testing_features, training_target, testing_target = \ train_test_split(features, tpot_data['target'], random_state=42)# Average CV score on the training set was: -10.812040755234403exported_pipeline = make_pipeline( PolynomialFeatures(degree=2, include_bias=False, interaction_only=False), ExtraTreesRegressor(bootstrap=False, max_features=0.5, min_samples_leaf=2, min_samples_split=3, n_estimators=100))# Fix random state for all the steps in exported pipelineset_param_recursive(exported_pipeline.steps, 'random_state', 42)exported_pipeline.fit(training_features, training_target)results = exported_pipeline.predict(testing_features)
使用以下方式安装Ray:pip install ray 官方链接 https://github.com/ray-project/ray
SMAC3
SMAC是用于算法配置的工具,可以跨一组实例优化任意算法的参数。这还包括ML算法的超参数优化。主要核心包括贝叶斯优化和积极的竞速机制,可有效地确定两种配置中哪一种的性能更好。 有关其主要思想的详细说明,请参阅 Hutter, F. and Hoos, H. H. and Leyton-Brown, K.Sequential Model-Based Optimization for General Algorithm ConfigurationIn: Proceedings of the conference on Learning and Intelligent OptimizatioN (LION 5) SMAC v3是用Python3编写的,并经过了Python3.6和python3.6的持续测试。它的随机森林用C++编写。