Skip to content

Instantly share code, notes, and snippets.

@JulienPascal
Last active February 20, 2022 17:10
Show Gist options
  • Save JulienPascal/7ecb3d9fb38931c2aa6958675bca17f5 to your computer and use it in GitHub Desktop.
Save JulienPascal/7ecb3d9fb38931c2aa6958675bca17f5 to your computer and use it in GitHub Desktop.
LogisticRegression
df_nba = CSV.read("/home/julien/Documents/REPOSITORIES/LogisticRegression/data/shot_logs.csv");
names(df_nba)
df_nba = df_nba[[:SHOT_RESULT, :SHOT_CLOCK, :SHOT_DIST, :CLOSE_DEF_DIST]]
# Drop rows with missings:
df_nba = dropmissing(df_nba);
# Drop rows with NaN:
df_nba = df_nba[completecases(df_nba), :]
# Convert SHOT_RESULT to a binary variable (1 for success, 0 for missed)
df_nba[:, :SHOT_RESULT] = ifelse.(df_nba[:, :SHOT_RESULT] .== "made", 1.0, 0.0);
# Show the first few rows of df_nba:
first(df_nba, 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment