示例#1
0
def test_template_estimator(data):
    est = TemplateEstimator()
    assert est.demo_param == 'demo_param'

    est.fit(*data)
    assert hasattr(est, 'is_fitted_')

    X = data[0]
    y_pred = est.predict(X)
    assert_array_equal(y_pred, np.ones(X.shape[0], dtype=np.int64))
示例#2
0
"""
===========================
Plotting Template Estimator
===========================

An example plot of TemplateEstimator
"""
import numpy as np
from skltemplate import TemplateEstimator
from matplotlib import pyplot as plt

X = np.arange(100).reshape(100, 1)
y = np.zeros((100, ))
estimator = TemplateEstimator()
estimator.fit(X, y)
plt.plot(estimator.predict(X))
plt.show()
def test_demo():
    X = np.random.random((100, 10))
    estimator = TemplateEstimator()
    estimator.fit(X, X[:, 0])
    assert_almost_equal(estimator.predict(X), X[:, 0]**2)