4.11 Use the Conda Interpreter in a Notebook Paragraph

Oracle Machine Learning Notebooks provides a Conda interpreter to enable administrators to create conda environments with custom third-party Python and R libraries. Once created, you can download and activate Conda environments inside a notebook session also using the Conda interpreter.

An Oracle Machine Learning notebook supports multiple languages. For this, you must create a notebook with some paragraphs to run SQL queries, and other paragraphs to run PL/SQL scripts. To run a notebook in different scripting languages, you must first connect the notebook paragraphs with the respective interpreters such as SQL, PL/SQL, R, Python, or Conda.

This topic shows how to start working in the Conda environment:
  • Connect to the Conda interpreter
  • Download and activate the Conda environment
  • View the list of packages in the Conda environment
  • Run a Python function to import the Iris dataset, and use the seaborn package for visualization
  1. Type %conda at the beginning of the paragraph to connect to the Conda interpreter, and press Enter.
    %conda
  2. Next, download and activate the Conda environment. Type:
    download sbenv
    activate sbenv
    In this example, the Conda environment is downloaded and activated. The name of the Conda environment in this example is sbenv.Download and Activate the Conda Environment
  3. You can view all the packages that are present in the Conda environment. To view the list of packages, type list.
    List of packages in the seaborn library
  4. Here's an example that demonstrates how to use the seaborn library package for visualization. Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing attractive statistical graphics. This example
    • Imports Pandas and seaborn
    • Loads the Iris dataset
    • Plots the datapoints, that is, the three different species of the Iris flower - Setosa, Virginica, and Versicolor based on its dimensions. It creates a scatter plot
    Type:
    %python
    
    def sb_plot():
        import pandas as pd
        import seaborn as sb
        from matplotlib import pyplot as plt
        df = sb.load_dataset('iris')
        sb.set_style("ticks")
        sb.pairplot(df,hue = 'species',diag_kind = "kde",kind = "scatter",palette = "husl")
        plt.show()
    Commands
  5. Run the function in a Python paragraph.
    Type:
    %python 
    sb_plot()
    Visualization using Seaborn Python library