MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / main

Function main

machine_learning/xgboost_regressor.py:40–59  ·  view source on GitHub ↗

The URL for this algorithm https://xgboost.readthedocs.io/en/stable/ California house price dataset is used to demonstrate the algorithm. Expected error values: Mean Absolute Error: 0.30957163379906033 Mean Square Error: 0.22611560196662744

()

Source from the content-addressed store, hash-verified

38
39
40def main() -> None:
41 """
42 The URL for this algorithm
43 https://xgboost.readthedocs.io/en/stable/
44 California house price dataset is used to demonstrate the algorithm.
45
46 Expected error values:
47 Mean Absolute Error: 0.30957163379906033
48 Mean Square Error: 0.22611560196662744
49 """
50 # Load California house price dataset
51 california = fetch_california_housing()
52 data, target = data_handling(california)
53 x_train, x_test, y_train, y_test = train_test_split(
54 data, target, test_size=0.25, random_state=1
55 )
56 predictions = xgboost(x_train, y_train, x_test)
57 # Error printing
58 print(f"Mean Absolute Error: {mean_absolute_error(y_test, predictions)}")
59 print(f"Mean Square Error: {mean_squared_error(y_test, predictions)}")
60
61
62if __name__ == "__main__":

Callers 1

Calls 4

xgboostFunction · 0.90
mean_squared_errorFunction · 0.85
data_handlingFunction · 0.70
mean_absolute_errorFunction · 0.70

Tested by

no test coverage detected