-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all implementations and wrapping it up
- Loading branch information
ReyazBeigh
committed
Jul 30, 2021
1 parent
5c060af
commit 8e9f266
Showing
16 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
from sklearn.metrics import mean_absolute_error | ||
import define_model_2 as mlb_model_cals | ||
import a2_define_model as mlb_model_cals | ||
|
||
prediction_on_all_data = mlb_model_cals.mlb_model.predict(mlb_model_cals.X) | ||
|
||
mean_absolute_error = mean_absolute_error(mlb_model_cals.y, prediction_on_all_data) | ||
|
||
print("Mean Absolute Error: " + str(mean_absolute_error)) | ||
print("Mean Absolute Error, validated on the training data and the price values that we already have: " + str(mean_absolute_error)) | ||
|
||
print(__file__ + " DONE ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
import a4_split_test_data as splitted_data | ||
from sklearn.metrics import mean_absolute_error | ||
from sklearn.tree import DecisionTreeRegressor | ||
|
||
def get_mae(max_leaf_nodes, train_X, val_X, train_y, val_y): | ||
model = DecisionTreeRegressor(max_leaf_nodes=max_leaf_nodes, random_state=0) | ||
model.fit(train_X, train_y) | ||
preds_val = model.predict(val_X) | ||
mae = mean_absolute_error(val_y, preds_val) | ||
return(mae) | ||
|
||
#find the best value for max_leaf_nodes | ||
possible_best_nodes = [5, 10, 20, 30, 50, 100, 200,500,1000,2000,5000] | ||
|
||
optimal_node = possible_best_nodes[0] | ||
|
||
temp_mea = None | ||
|
||
for leaf in possible_best_nodes: | ||
mae = get_mae(leaf, splitted_data.train_X, splitted_data.test_X, splitted_data.train_y, splitted_data.test_y) | ||
if temp_mea == None or temp_mea > mae: | ||
temp_mea = mae | ||
optimal_node = leaf | ||
|
||
optimal_model = DecisionTreeRegressor(max_leaf_nodes=optimal_node, random_state=0) | ||
optimal_model.fit(splitted_data.train_X, splitted_data.train_y) | ||
preds_val = optimal_model.predict(splitted_data.test_X) | ||
mae = mean_absolute_error(splitted_data.test_y, preds_val) | ||
|
||
print("MEA after OPTIMISATION [in the middle of underfitting and overfitting]-> " + str(mae)) | ||
|
||
print(__file__+" DONE") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from sklearn.ensemble import RandomForestRegressor | ||
from sklearn.metrics import mean_absolute_error | ||
import a4_split_test_data as splitted_data | ||
|
||
forest_model = RandomForestRegressor(random_state=0) | ||
forest_model.fit(splitted_data.train_X, splitted_data.train_y) | ||
prediction = forest_model.predict(splitted_data.test_X) | ||
mea = mean_absolute_error(splitted_data.test_y, prediction) | ||
print( " MEA from Random Forest Model, should be better from other 2 approaches "+str(mea)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import a2_define_model | ||
import a3_validation | ||
import a4_split_test_data | ||
import a5_under_over_fit | ||
import a6_random_forest |
Empty file.
Empty file.