Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stackoverflow #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Salary.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@
"%matplotlib inline\n",
"\n",
"df = pd.read_csv('./survey_results_public.csv')\n",
"df.head()"
"df.head()\n",
"df.tail()"
]
},
{
Expand Down Expand Up @@ -5774,7 +5775,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
3 changes: 3 additions & 0 deletions Salary_ML.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def clean_data(df):
X = df
return X, y


def find_optimal_lm_mod(X, y, cutoffs, test_size = .30, random_state=42, plot=True):
'''
INPUT
Expand All @@ -54,6 +55,7 @@ def find_optimal_lm_mod(X, y, cutoffs, test_size = .30, random_state=42, plot=Tr
random_state - int, default 42, controls random state for train_test_split
plot - boolean, default 0.3, True to plot result


OUTPUT
r2_scores_test - list of floats of r2 scores on the test data
r2_scores_train - list of floats of r2 scores on the train data
Expand Down Expand Up @@ -110,6 +112,7 @@ def main():
X, y = clean_data(df)
#cutoffs here pertains to the number of missing values allowed in the used columns.
#Therefore, lower values for the cutoff provides more predictors in the model.
##################################
cutoffs = [5000, 3500, 2500, 1000, 100, 50, 30, 20, 10, 5]

r2_scores_test, r2_scores_train, lm_model, X_train, X_test, y_train, y_test = find_optimal_lm_mod(X, y, cutoffs, plot=False)
Expand Down
Loading