1 of 6

ניתוח נתונים ולמידת מכונה

אמית רננים – חלופה ליחידה 3

סביבת העבודה

Google Colab

2 of 6

What is Google Colab?

  • Free cloud-based integrated development environment for Python
    • Runs entirely in the cloud, no local setup required
    • Accessible from any device with a web browser
  • Collaborative platform for data science and machine learning
  • Pre-installed with popular data science libraries
    • NumPy, Pandas, Matplotlib, and more readily available
  • Accessible using the link: http://colab.research.google.com
  • Limitations:
    • Requires Internet connection
    • May sometimes run slowly (server load dependent)

2

3 of 6

Basic Operations

  • Create a new notebook:
    • Click on "New Notebook" or "File" > "New Notebook“
    • Choose from available templates or start from scratch
  • Open an existing notebook:
    • Access from Google Drive or GitHub
    • Upload local .ipynb file
  • Code cells:
    • Write and execute Python code interactively
    • Run cells individually or in sequence
    • Output displayed directly below the cell
  • Text cells:
    • Add explanations and documentation using Markdown
    • Support for formatting, equations, and HTML
  • Cell execution:
    • Use "Shift + Enter" or the play button to run cells
    • "Runtime" menu for running all cells or restarting the kernel

3

4 of 6

Working with Files

  • Upload local files to Colab:
    • Use the file upload widget in the left sidebar
    • Access uploaded files using Python's file handling methods
  • Mount Google Drive for persistent storage:
    • Connect your Google Drive to Colab for file access
  • Access files from GitHub repositories:
    • Clone repositories directly into Colab
      • Use “!git clone” command in a code cell

4

5 of 6

Installing Libraries

In case a required library is not yet installed:

  • Use !pip install for package management:
    • Prefix commands with '!' to run shell commands
    • Example: “!pip install pandas”
  • Pre-installed data science libraries:
    • NumPy, Pandas, Matplotlib, Scikit-learn, TensorFlow, etc.
    • Check versions with “!pip list”
  • Restart runtime after installing new packages:
    • Ensure new installations take effect
    • Use "Runtime" > "Restart runtime" menu option
  • Managing package versions:
    • Specify versions during installation (use requirements.txt for reproducibility)

5

6 of 6

Best Practices

  • Save your work frequently:
    • Use "File" > "Save" or Ctrl+S (Cmd+S on Mac)
    • Enable autosave in Colab settings
  • Use markdown cells for documentation:
    • Explain your code and thought process
    • Include headers, lists, and code snippets in markdown
  • Be mindful: Colab disconnects after 90 minutes of inactivity
  • To include Right-to-left Hebrew text in a Colab text cell, include the following at the top of the text cell:

<div dir="rtl" lang="he" xml:lang="he">

6