本文整理汇总了Python中tpot.TPOTClassifier.export方法的典型用法代码示例。如果您正苦于以下问题:Python TPOTClassifier.export方法的具体用法?Python TPOTClassifier.export怎么用?Python TPOTClassifier.export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tpot.TPOTClassifier
的用法示例。
在下文中一共展示了TPOTClassifier.export方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_export
# 需要导入模块: from tpot import TPOTClassifier [as 别名]
# 或者: from tpot.TPOTClassifier import export [as 别名]
def test_export():
"""Assert that TPOT's export function throws a ValueError when no optimized pipeline exists"""
tpot_obj = TPOTClassifier()
try:
tpot_obj.export("test_export.py")
assert False # Should be unreachable
except ValueError:
pass
示例2: test_export
# 需要导入模块: from tpot import TPOTClassifier [as 别名]
# 或者: from tpot.TPOTClassifier import export [as 别名]
def test_export():
"""Assert that TPOT's export function throws a RuntimeError when no optimized pipeline exists."""
tpot_obj = TPOTClassifier()
assert_raises(RuntimeError, tpot_obj.export, "test_export.py")
pipeline_string = (
'KNeighborsClassifier(CombineDFs('
'DecisionTreeClassifier(input_matrix, DecisionTreeClassifier__criterion=gini, '
'DecisionTreeClassifier__max_depth=8,DecisionTreeClassifier__min_samples_leaf=5,'
'DecisionTreeClassifier__min_samples_split=5), ZeroCount(input_matrix))'
'KNeighborsClassifier__n_neighbors=10, '
'KNeighborsClassifier__p=1,KNeighborsClassifier__weights=uniform'
)
pipeline = creator.Individual.from_string(pipeline_string, tpot_obj._pset)
tpot_obj._optimized_pipeline = pipeline
tpot_obj.export("test_export.py")
assert path.isfile("test_export.py")
remove("test_export.py") # clean up exported file
示例3: load_digits
# 需要导入模块: from tpot import TPOTClassifier [as 别名]
# 或者: from tpot.TPOTClassifier import export [as 别名]
from tpot import TPOTClassifier
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
digits = load_digits()
X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target,
train_size = 0.75, test_size = 0.25)
tpot = TPOTClassifier(generations = 5, population_size = 20, verbosity = 2)
tpot.fit(X_train, y_train)
print(tpot.score(X_test, y_test))
tpot.export('tpot_mnist_pipeline.py')
示例4: generate_model
# 需要导入模块: from tpot import TPOTClassifier [as 别名]
# 或者: from tpot.TPOTClassifier import export [as 别名]
def generate_model(generations, train_X, train_y):
tpot_generator = TPOTClassifier(generations=generations, verbosity=2)
tpot_generator.fit(train_X, train_y)
tpot_generator.export('tpot_model' + generations + '.py')
示例5: data
# 需要导入模块: from tpot import TPOTClassifier [as 别名]
# 或者: from tpot.TPOTClassifier import export [as 别名]
HPI = HPI.join(benchmark['United States'])
# all in percentage change since the start of the data (1975-01-01)
HPI.dropna(inplace=True)
housing_pct = HPI.pct_change()
housing_pct.replace([np.inf, -np.inf], np.nan, inplace=True)
housing_pct['US_HPI_future'] = housing_pct['United States'].shift(-1)
housing_pct.dropna(inplace=True)
def create_labels(cur_hpi, fut_hpi):
if fut_hpi > cur_hpi:
return 1
else:
return 0
housing_pct['label'] = list(map(create_labels, housing_pct['United States'], housing_pct['US_HPI_future']))
# housing_pct['ma_apply_example'] = housing_pct['M30'].rolling(window=10).apply(moving_average)
# print(housing_pct.tail())
X = np.array(housing_pct.drop(['label', 'US_HPI_future'], 1))
y = np.array(housing_pct['label'])
X_train, X_test, y_train, y_test = train_test_split(X,y, test_size=0.25)
tpot = TPOTClassifier(generations=10, population_size=20, verbosity=2)
tpot.fit(X_train, y_train)
print(tpot.score(X_test, y_test))
tpot.export('HPI_tpot_pipeline.py')
示例6: train_test_split
# 需要导入模块: from tpot import TPOTClassifier [as 别名]
# 或者: from tpot.TPOTClassifier import export [as 别名]
#features = data
#tpot_data=pd.DataFrame({'class':label},columns=['class'])
#training_features, testing_features, training_classes, testing_classes = \
# train_test_split(features, tpot_data['class'], random_state=42)
data,label,idx_row = np.concatenate(samples),np.concatenate(label),np.arange(0,len(label),1)
print('shuffle')
for ii in range(100):
shuffle(idx_row)
data,label = data[idx_row,:],label[idx_row]
X_train, X_test, y_train, y_test = train_test_split(data,label,train_size=0.80)
print('model selection')
tpot = TPOTClassifier(generations=10, population_size=25,
verbosity=2,random_state=373849,num_cv_folds=5,scoring='roc_auc' )
tpot.fit(X_train,y_train)
tpot.score(X_test,y_test)
tpot.export('%s%s_tpot_exported_pipeline.py'%(folder,type_) )
print('finished model selection')
"""
from sklearn.ensemble import VotingClassifier
from sklearn.feature_selection import SelectFwe, f_classif
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.pipeline import make_pipeline, make_union
from sklearn.preprocessing import FunctionTransformer
from sklearn.model_selection import KFold
exported_pipeline = make_pipeline(
make_union(
FunctionTransformer(lambda X: X),
FunctionTransformer(lambda X: X)
),
SelectFwe(alpha=0.05, score_func=f_classif),
开发者ID:adowaconan,项目名称:modification-pipelines,代码行数:33,代码来源:validation+11+-+cross+validation+part+1-+find+best+model.py
示例7: list
# 需要导入模块: from tpot import TPOTClassifier [as 别名]
# 或者: from tpot.TPOTClassifier import export [as 别名]
# Add origin encoding
for origin_column in list(origin_dummies):
sample_df[ origin_column ] = origin_dummies[ origin_column ]
X_train, X_test, y_train, y_test = train_test_split( sample_df, labels,train_size=0.7)
le = preprocessing.LabelEncoder()
tpot = TPOTClassifier(generations=7, population_size=15, verbosity=2)
tpot.fit(X_train, y_train)
print(tpot.score(X_test, y_test))
tpot.export('tpot_cars_pipeline.py')
#tpot = TPOTClassifier(generations=5, population_size=20, verbosity=2)
#Best pipeline: GradientBoostingClassifier(RobustScaler(input_matrix), GradientBoostingClassifier__learning_rate=1.0, GradientBoostingClassifier__max_depth=5, GradientBoostingClassifier__max_features=0.25, GradientBoostingClassifier__min_samples_leaf=DEFAULT, GradientBoostingClassifier__min_samples_split=17, GradientBoostingClassifier__n_estimators=100, GradientBoostingClassifier__subsample=0.7)
# 0.770491803279
#tpot = TPOTClassifier(generations=5, population_size=50, verbosity=2)
#Best pipeline: ExtraTreesClassifier(input_matrix, ExtraTreesClassifier__bootstrap=False, ExtraTreesClassifier__criterion=DEFAULT, ExtraTreesClassifier__max_features=0.45, ExtraTreesClassifier__min_samples_leaf=1, ExtraTreesClassifier__min_samples_split=7, ExtraTreesClassifier__n_estimators=DEFAULT)
#0.762295081967
#Sin MPG
#tpot = TPOTClassifier(generations=5, population_size=20, verbosity=2)
#Best pipeline: ExtraTreesClassifier(input_matrix, ExtraTreesClassifier__bootstrap=DEFAULT, ExtraTreesClassifier__criterion=gini, ExtraTreesClassifier__max_features=0.45, ExtraTreesClassifier__min_samples_leaf=1, ExtraTreesClassifier__min_samples_split=6, ExtraTreesClassifier__n_estimators=DEFAULT)
#0.754098360656
# All features set