本文整理汇总了Python中pyearth.Earth.forward_trace方法的典型用法代码示例。如果您正苦于以下问题:Python Earth.forward_trace方法的具体用法?Python Earth.forward_trace怎么用?Python Earth.forward_trace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyearth.Earth
的用法示例。
在下文中一共展示了Earth.forward_trace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_pyearth
# 需要导入模块: from pyearth import Earth [as 别名]
# 或者: from pyearth.Earth import forward_trace [as 别名]
def run_pyearth(X, y, **kwargs):
'''Run with pyearth. Return prediction value, training time, and number of forward pass iterations.'''
model = Earth(**kwargs)
t0 = time.time()
model.fit(X, y)
t1 = time.time()
y_pred = model.predict(X)
forward_iterations = len(model.forward_trace()) - 1
return y_pred, t1 - t0, forward_iterations
示例2: test_untrained
# 需要导入模块: from pyearth import Earth [as 别名]
# 或者: from pyearth.Earth import forward_trace [as 别名]
def test_untrained():
model = Earth(**default_params)
assert_raises(NotFittedError, model.predict, X)
assert_raises(NotFittedError, model.transform, X)
assert_raises(NotFittedError, model.predict_deriv, X)
assert_raises(NotFittedError, model.score, X)
# the following should be changed to raise NotFittedError
assert_equal(model.forward_trace(), None)
assert_equal(model.pruning_trace(), None)
assert_equal(model.summary(), "Untrained Earth Model")
示例3: test_patsy_compatibility
# 需要导入模块: from pyearth import Earth [as 别名]
# 或者: from pyearth.Earth import forward_trace [as 别名]
def test_patsy_compatibility():
import pandas
import patsy
X_df = pandas.DataFrame(X)
y_df = pandas.DataFrame(y)
colnames = ['xx' + str(i) for i in range(X.shape[1])]
X_df.columns = colnames
X_df['y'] = y
y_df, X_df = patsy.dmatrices(
'y ~ xx0 + xx1 + xx2 + xx3 + xx4 + xx5 + xx6 + xx7 + xx8 + xx9 - 1',
data=X_df)
model = Earth(**default_params).fit(X_df, y_df)
assert_list_equal(
colnames, model.forward_trace()._getstate()['xlabels'])
示例4: test_untrained
# 需要导入模块: from pyearth import Earth [as 别名]
# 或者: from pyearth.Earth import forward_trace [as 别名]
def test_untrained():
# NotFittedError moved from utils.validation to exceptions
# some time after 0.17.1
try:
from sklearn.exceptions import NotFittedError
except ImportError:
from sklearn.utils.validation import NotFittedError
# Make sure calling methods that require a fitted Earth object
# raises the appropriate exception when using a not yet fitted
# Earth object
model = Earth(**default_params)
assert_raises(NotFittedError, model.predict, X)
assert_raises(NotFittedError, model.transform, X)
assert_raises(NotFittedError, model.predict_deriv, X)
assert_raises(NotFittedError, model.score, X)
# the following should be changed to raise NotFittedError
assert_equal(model.forward_trace(), None)
assert_equal(model.pruning_trace(), None)
assert_equal(model.summary(), "Untrained Earth Model")