Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 3
0
def main():
    print("Tesing the accuracy of KNN 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 = KNeighborsRegressor()
    reg.fit(X=X_train, y=y_train, k_neighbors=3)
    # Model accuracy
    get_r2(reg, X_test, y_test)
Ejemplo n.º 4
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=5)
    # Show rules
    reg.rules
    # Model accuracy
    get_r2(reg, X_test, y_test)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
def main():
    print("Tesing the accuracy 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 accuracy
    get_r2(reg, X_test, y_test)