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
model_dataset["num_schools"] =model_dataset["num_schools"].fillna(0) | |
model_dataset["num_groups"] = model_dataset["num_groups"].fillna(0) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
shap.summary_plot(shap_values, x_test) |
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
shap.initjs() | |
shap.force_plot(explainer.expected_value, shap_values[1,:], x_test.iloc[20,:]) |
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
model_dataset = pd.merge(full_data,professionals_dataset,how='left', on=["professional_id" ]) |
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
explainer = shap.LinearExplainer(LR, x_train, feature_perturbation="interventional") | |
shap_values = explainer.shap_values(x_test) | |
shap.summary_plot(shap_values, x_train, plot_type="bar") |
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
x_train, x_test, y_train, y_test = train_test_split(resampled_data, target, test_size=0.2, random_state=42) | |
LR = LogisticRegression(max_iter = 10000) | |
LR.fit(x_train, y_train) | |
LR.score(x_test, y_test) |
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
positive = model_dataset[ model_dataset["q_answered?"] != 0] | |
negative = model_dataset[ model_dataset["q_answered?"] == 0] | |
negative_sample = negative.sample(5000) | |
resampled_data = pd.concat([positive,negative_sample ]) |
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
model_dataset["following_tags"]= model_dataset["following_tags"].fillna("Na") | |
model_dataset["prev_q_tags"]= model_dataset["prev_q_tags"].fillna("Na") | |
model_dataset["q_tags"]= model_dataset["q_tags"].fillna("Na") |
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
# creating a data for all the professionals | |
professionals_dataset = pd.DataFrame(columns = ["professional_id"]) | |
professionals_dataset["professional_id"] = professionals["professionals_id"] |
NewerOlder