Ejemplo n.º 1
0
 def batch():
     print("Tesing the performance of LinearRegression(batch)...")
     # Train model
     reg = LinearRegression()
     reg.fit(X=X_train, y=y_train, lr=0.02, epochs=5000)
     # Model evaluation
     get_r2(reg, X_test, y_test)
 def batch():
     print("Tesing the performance of LinearRegression(batch)...")
     # Train model
     reg = LinearRegression()
     reg.fit(data=data_train, label=label_train, learning_rate=0.1, epochs=1000)
     # Model evaluation
     get_r2(reg, data_test, label_test)
     print(reg)
 def stochastic():
     print("Tesing the performance of LinearRegression(stochastic)...")
     # Train model
     reg = LinearRegression()
     reg.fit(data=data_train, label=label_train, learning_rate=0.05, epochs=50,
             method="stochastic", sample_rate=0.6)
     # Model evaluation
     get_r2(reg, data_test, label_test)
     print(reg)
def main():
    print("Tesing the performance of KNN regressor...")
    # Load data
    X, y = load_boston_house_prices()
    X = min_max_scale(X)
    # 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 = KNeighborsRegressor()
    reg.fit(X=X_train, y=y_train, k_neighbors=3)
    # Model evaluation
    get_r2(reg, X_test, y_test)
Ejemplo n.º 5
0
 def stochastic():
     print("Tesing the performance 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 evaluation
     get_r2(reg, X_test, y_test)
Ejemplo n.º 6
0
def main():
    print("Tesing the performance 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=5)
    # Show rules
    reg.rules
    # Model evaluation
    get_r2(reg, X_test, y_test)
Ejemplo n.º 7
0
def main():
    print("Tesing the performance of Ridge Regressor(stochastic)...")
    # Load data
    X, y = load_boston_house_prices()
    X = min_max_scale(X)
    # 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 = Ridge()
    reg.fit(X=X_train, y=y_train, lr=0.001, epochs=1000,
            method="stochastic", sample_rate=0.5, alpha=1e-7)
    # Model evaluation
    get_r2(reg, X_test, y_test)
Ejemplo n.º 8
0
def main():
    print("Tesing the performance 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=3,
            min_samples_split=2)
    # Model evaluation
    get_r2(reg, X_test, y_test)
Ejemplo n.º 9
0
def main():
    """Tesing the performance of RegressionTree
    """
    print("Tesing the performance of RegressionTree...")
    # Load data
    data, label = load_boston_house_prices()
    # Split data randomly, train set rate 70%
    data_train, data_test, label_train, label_test = train_test_split(
        data, label, random_state=200)
    # Train model
    reg = RegressionTree()
    reg.fit(data=data_train, label=label_train, max_depth=5)
    # Show rules
    print(reg)
    # Model evaluation
    get_r2(reg, data_test, label_test)
Ejemplo n.º 10
0
def main():
    """Tesing the performance of MLP.
    """
    print("Tesing the performance of MLP....")
    # Load data
    data, label = load_boston_house_prices()
    data = min_max_scale(data)
    # Split data randomly, train set rate 70%
    data_train, data_test, label_train, label_test = train_test_split(
        data, label, random_state=20)
    # Train model
    reg = MLP()
    reg.fit(data=data_train, label=label_train, n_hidden=8,
            epochs=500, batch_size=8, learning_rate=0.0008)
    # Model evaluation
    get_r2(reg, data_test, label_test)
    print(reg)