<jupyter_start><jupyter_text>Starting a Project with Selected Blueprints**Author**: <NAME>**Label**: Modeling Options ScopeThe scope of this notebook is to provide instructions on how to initiate a DataRobot project manually where the user has the option to choose which models/blueprints he wants to initiate. The procedure below should work for any type of problem you are trying to solve (regression, classification, time series, etc). 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  Import Libraries<jupyter_code>import datarobot as dr
import pandas as pd
import numpy as np
import time<jupyter_output><empty_output><jupyter_text>Import DatasetWe will be loading the breast cancer dataset. A very simple binary classification dataset that is available through sk-learn.<jupyter_code>from sklearn.datasets import load_breast_cancer
data = load_breast_cancer()

df = pd.DataFrame(np.c_[data['data'], data['target']],
                  columns= np.append(data['feature_names'], ['target']))
df.head()<jupyter_output><empty_output><jupyter_text>Connect to DataRobotConnect to DataRobot using your credentials and your endpoint. Change input below accordingly.<jupyter_code>dr.Client(token='YOUR_API_KEY', 
          endpoint='YOUR_DATAROBOT_HOSTNAME')<jupyter_output><empty_output><jupyter_text>Initiate projectWe will be initiating the project using autopilot_on = False. This way DataRobot will not start building models until we specify which ones we want to build<jupyter_code>project = dr.Project.start(project_name='MyBinaryClassificationProject',
                        sourcedata= df,
                        autopilot_on = False,
                        target='target')<jupyter_output><empty_output><jupyter_text>Find all of the blueprintsWe can use the get_blueprints method to see all of the blueprints DataRobot generated.<jupyter_code>blueprints = project.get_blueprints()

#Now that we have the Blueprints, we can search for a specific blueprint. 
#For example all models that have "Gradient" in their name

models_to_run = []
for blueprint in blueprints:
    if 'Gradient' in blueprint.model_type:
        models_to_run.append(blueprint)
        
models_to_run<jupyter_output><empty_output><jupyter_text>Lets now initiate these modelsWe can use the train method to initiate modeling for a specific blueprint. By default, the feature list used will be the informative features  list produced by DataRobot but you can define your own feature list and pass it on the featurelist_id variable.<jupyter_code>for model in models_to_run:
    project.train(model, sample_pct = 80, featurelist_id=None)<jupyter_output><empty_output><jupyter_text>Waiting for job completionWe can use the get_all_jobs method to wait for the models to finish running<jupyter_code>while len(project.get_all_jobs()) > 0:
    time.sleep(1)
    pass<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06724581724581724, 'fraction_numerical': 0.0035392535392535394, 'mean_word_length': 5.132149901380671, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 31, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '155421', 'license': 'Apache-2.0', 'n_tokens_mistral': 896, 'n_tokens_neox': 861, 'n_words': 313, 'path': 'Initiating Projects/Python/Starting a Project with Selected Blueprints.ipynb', 'repo_name': 'ahjota/examples-for-data-scientists', 'size': '3122'}