17 Kasım 2022 Perşembe

Creating tables for model comparison

In this post, I will compile codes to compare different models' results. The post will hopefully lengthen as I add new ones..

Here is the first one comparing a decision tree, rf, and other tuned regressors:

The code creates this table:
Code:

models_test_comp_df = pd.concat(
    [
        dt_regressor_perf_test.T,
        regressor_perf_test.T,
        bagging_estimator_perf_test.T,
        dtree_tuned_regressor_perf_test.T,
        bagging_tuned_regressor_perf_test.T,
        rf_tuned_regressor_perf_test.T
    ],
    axis=1,
)
models_test_comp_df.columns = [
    "Decision tree regressor",
    "Random Forest regressor",
    "Bagging regressor",
    "Tuned Decision Tree regressor",
    "Tuned Bagging Tree regressor",
    "Tuned Random Forest Regressor"]
print("Test performance comparison:")
models_test_comp_df


A second code to retrieve a table for a similar comparison: (table not included this time)


# defining list of models you have trained
models = [lr, dtree, ridge_model, dtree_tuned, rf_model, rf_model_tuned]
# defining empty lists to add train and test results
r2_train = []
r2_test = []
rmse_train= []
rmse_test= []
# looping through all the models to get the rmse and r2 scores
for model in models:
    # accuracy score
    j = get_model_score(model,False)
    r2_train.append(j[0])
    r2_test.append(j[1])
    rmse_train.append(j[2])
    rmse_test.append(j[3])
-------
comparison_frame = pd.DataFrame({'Model':['Linear Regression','Decision Tree','Ridge Model','Tuned Decision Tree','Random Forest','Tuned Random Forest'], 
                                          'Train_r2': r2_train,'Test_r2': r2_test,
                                          'Train_RMSE':rmse_train,'Test_RMSE':rmse_test}) 
comparison_frame

4 Kasım 2022 Cuma

Three SQL Game Web Sites

1. SQL Murder Mystery: Using SQL knowledge to find a killer in SQL city. https://mystery.knightlab.com 

2. SQL Police Department: You are joining SQLPD, and solving crimes while learning SQL. https://sqlpd.com

3. Schemaverse: A space-based strategy game implemented entirely within a PostgreSQL database. You will be commanding your fleet and competing against other players using raw SQL commands. https://schemaverse.com

2 Kasım 2022 Çarşamba

How XGBoost works

A nice diagram to understand how XGBoost works:

17 Ağustos 2022 Çarşamba

Perfect visualizations of Joins in SQL

Here they are..





SQL Cheatsheet

 A nice SQL cheatsheet from here:



What did Acemoglu get wrong

Here's an excellent podcast for those interested in development economics and the drivers of economic growth: (Daron Acemoglu interviewed with Alice Evans)

https://open.spotify.com/episode/76fLUVwGM4glpRQ0dwhf58?si=8KuXHzP_TcmtnYbxnF6QfQ&nd=1

Downloading Youtube videos and converting docs to pdf with Python

 Here's a tweet (and the video) showing how to download a Youtube video in mp3 format with Python. You can follow Python coding channel to see such videos.


Another video here shows how to download videos (not just in mp3 format) with the same library:


Lastly, this video shows you how to convert a .docx file to a pdf: