Пример #1
0
 def batch():
     print("Tesing the accuracy of LinearRegression(batch)...")
     # Train model
     reg = LinearRegression()
     reg.fit(X=X_train, y=y_train, lr=0.02, epochs=5000)
     # Model accuracy
     get_r2(reg, X_test, y_test)
Пример #2
0
 def stochastic():
     print("Tesing the accuracy of LinearRegression(stochastic)...")
     # Train model
     reg = LinearRegression()
     reg.fit(X=X_train, y=y_train, lr=0.001, epochs=1000,
             method="stochastic", sample_rate=0.5)
     # Model accuracy
     get_r2(reg, X_test, y_test)
Пример #3
0
def main():
    print("Tesing the accuracy of RegressionTree...")
    # Load data
    X, y = load_boston_house_prices()
    # Split data randomly, train set rate 70%
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=10)
    # Train model
    reg = RegressionTree()
    reg.fit(X=X_train, y=y_train, max_depth=4)
    # Show rules
    reg.print_rules()
    # Model accuracy
    get_r2(reg, X_test, y_test)
Пример #4
0
def main():
    print("Tesing the accuracy of GBDT regressor...")
    # Load data
    X, y = load_boston_house_prices()
    # Split data randomly, train set rate 70%
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=10)
    # Train model
    reg = GradientBoostingRegressor()
    reg.fit(X=X_train,
            y=y_train,
            n_estimators=4,
            lr=0.5,
            max_depth=2,
            min_samples_split=2)
    # Model accuracy
    get_r2(reg, X_test, y_test)
Пример #5
0
Файл: act.py Проект: berbuf/asct
 def __init__(self, batch_size, block_size, hidden_size, threshold,
              **kargs):
     nn.Module.__init__(self)
     B, M, H = batch_size, block_size, hidden_size
     self.p = nn.Linear(H, 1)
     self.p.bias.data.fill_(-1.)  # force initial low p
     self.sigma = nn.Sigmoid()
     self.threshold = threshold
     # global variables
     self.updates = 0
     #self.exit_ = torch.zeros(B, M, 1).float().cuda()
     self.run = torch.ones(B, M, 1).bool().cuda()
     # helper
     self.index_run = torch.arange(B * M).reshape(B, M, 1).cuda()
     self.align = torch.arange(M).cuda()
     # buffer
     self.unpack_h = torch.zeros(B, M, H).cuda()
     self.weighted_h = torch.zeros(B, M, H).cuda()
     self.acc_p = torch.zeros(B, M, 1).cuda()
     self.remainders = torch.zeros(B, M, 1).cuda()
     # power of 2
     self.r2 = get_r2(M).cuda()
Пример #6
0
Файл: asa.py Проект: berbuf/asct
 def __init__(self, M):
     nn.Module.__init__(self)
     self.x = (torch.arange(M) - M // 2).float().cuda()
     self.r2 = get_r2(M).float().cuda()
     self.M = M