Skip to content

Commit

Permalink
r2 score
Browse files Browse the repository at this point in the history
  • Loading branch information
sayan1999 committed Apr 23, 2024
1 parent 7de2377 commit bb5fe1c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pinned: false
- **Live score scraping:** Stays up-to-date with real-time match data.
- **Intelligent prediction:** Leverages a Random Forest model for comprehensive analysis.
- **Factors beyond run rate:** Considers wickets left, last 5 overs, and more for precise predictions.
- **Comprehensive metrics:** Track MSE scores of 11.68 for T20 and 20.44 for ODI formats.
- **Comprehensive metrics:** Track MSE: 11.68, R2: 80% for T20 and MSE: 20.44, R2: 85% for ODI formats.

## Get Started

Expand Down
8 changes: 8 additions & 0 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import warnings, random
from sklearn.metrics import mean_absolute_error as mae
from sklearn.metrics import mean_squared_error as mse
from sklearn.metrics import r2_score
import statistics

# from sklearn import tree
Expand Down Expand Up @@ -145,6 +146,9 @@ def compare_util(model, fname, x_train, x_test, y_train, y_test, balls_left):
print(
f"Model: Train MSE: {mse(h_train_data, y_train_data, squared=False)}, Test MSE: {mse(h_test_data, y_test_data, squared=False)}"
)
print(
f"Model: Train R2: {r2_score(y_train_data, h_train_data)}, Test R2: {r2_score(y_test_data, h_test_data)}"
)


def compare(model, fname, x_train, x_test, y_train, y_test):
Expand Down Expand Up @@ -217,6 +221,10 @@ def train(fname, max_depth=-1):
f"Train MSE: {mse(model.predict(x_train)*x_train['balls_left']/6, y_train*x_train['balls_left']/6, squared=False)}, Test MSE: {mse(model.predict(x_test)*x_test['balls_left']/6, y_test*x_test['balls_left']/6, squared=False)}"
)

print(
f"Train R2: {r2_score(y_train*x_train['balls_left']/6, model.predict(x_train)*x_train['balls_left']/6)}, Test R2: {r2_score(y_test*x_test['balls_left']/6, model.predict(x_test)*x_test['balls_left']/6)}"
)

compare(model, fname, x_train, x_test, y_train, y_test)

evaluate(model, featuresdf, x_test, os.path.basename(fname))
Expand Down
Binary file modified model/odifeatures.feather.joblib
Binary file not shown.
Binary file modified model/t20features.feather.joblib
Binary file not shown.

0 comments on commit bb5fe1c

Please sign in to comment.