<jupyter_start><jupyter_text>Getting Partial Dependence Plot  ScopeThe scope of this notebook is to provide instructions on how to get the Partial Dependence Plot of a specific model using the Python API. BackgroundPartial dependence conveys how changes to the value of each feature change model predictions if everything else remained unchanged. You can find the partial dependence plot in the "Feature Effects" tab interface. Requirements- Python version 3.7.3-  DataRobot API version 2.19.0. Small adjustments might be needed depending on the Python version and DataRobot API version you are using.Full documentation of the Python package can be found here: https://datarobot-public-api-client.readthedocs-hosted.com/en/It is assumed you already have a DataRobot Project object and a DataRobot Model object.  Import Libraries<jupyter_code>import datarobot as dr
import seaborn as sns
sns.set()
import matplotlib.pyplot as plt
import pandas as pd<jupyter_output><empty_output><jupyter_text>Requesting Feature Effects (Partial Dependence)<jupyter_code>feature_effects = model.request_feature_effect()
feature_effects.wait_for_completion() #Wait till feature effects computes<jupyter_output><empty_output><jupyter_text>Plot Partial Dependence for a Specific Feature<jupyter_code>def plot_partial_dependence_column(feature_effects, column):
     
    temp_pd = list(feature_effects.get_result())
    for item in temp_pd:
        if item['feature_name'] == column:
            partial_dependence_data = item['partial_dependence']['data']
            partial_dependence_data_df = pd.DataFrame(partial_dependence_data) #Save results into a pandas dataframe
            partial_dependence_data_df.columns = ['target_probability','value']
    plt.figure(figsize=(16, 6))
    ax = sns.lineplot(x="value", y="target_probability", data=partial_dependence_data_df)#.set_title('Partial Dependence plot for %s'%column)
    return partial_dependence_data_df
    
plot_partial_dependence_column(feature_effects,'admission_type_id') #Fill in your own column<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06805019305019305, 'fraction_numerical': 0.004826254826254826, 'mean_word_length': 5.841584158415841, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '433401', 'license': 'Apache-2.0', 'n_tokens_mistral': 603, 'n_tokens_neox': 564, 'n_words': 186, 'path': 'Model Evaluation/Python/Getting Partial Dependence Plot.ipynb', 'repo_name': 'datarobot-community/api-samples-for-data-scientists', 'size': '2072'}