Beispiel #1
0
def test_cboss_on_power_demand():
    # load power demand data
    X_train, y_train = load_italy_power_demand(split="train", return_X_y=True)
    X_test, y_test = load_italy_power_demand(split="test", return_X_y=True)
    indices = np.random.RandomState(0).permutation(100)

    # train cBOSS
    cboss = ContractableBOSS(n_parameter_samples=50,
                             max_ensemble_size=10,
                             random_state=0)
    cboss.fit(X_train, y_train)

    score = cboss.score(X_test.iloc[indices], y_test[indices])
    assert score >= 0.9
def build_classifiers():
    """Examples of building a classifier.

    1. Directly from 2D numpy arrays.
    2. Directly from 3D numpy arrays.
    3. From a nested pandas.
    4. From a baked in dataset.
    5. From any UCR/UEA dataset downloaded from timeseriesclassification.com.
    """
    # Create an array
    # Random forest, rocket and HC2.
    randf = RandomForestClassifier()
    trainX, train_y, testX, test_y = make_toy_2d_problem()
    X = trainX.reshape(trainX.shape[0], 1, trainX.shape[1])
    train_y = pd.Series(train_y)
    test_y = pd.Series(test_y)
    # randf.fit(trainX, train_y)
    cls1 = ContractableBOSS(time_limit_in_minutes=1)
    # cls2 = BOSSEnsemble()
    cls1.fit(trainX, train_y)
    print(" CBOSS acc = ", cls1.score(testX, test_y))