Galle, LK--:--5/6 sites live

Google Colaboratory Basics

මේකෙන් තමයි අනිත් සියල්ල ධාවනය කරන්නේ — ML කේත ලියන්න කලින්, cells run කරන්නෙ කොහොමද, වැඩේ නැති වෙන්නෙ නැතුව save කරන්නෙ කොහොමද කියලා දැනගන්න ඕන.

This is the notebook you'll run everything else in — so before touching any ML code, you need to know how to move around it, run cells, and not lose your work.

1 May 20263 min readSelf Guide · Stage 13#Python & Data Basics#Python Fundamentals#Machine learning

Lesson 1 of 64 · Part 1 · Python & Data Basics · Python Fundamentals · bilingual notes (English + සිංහල)

Why this matters. This is the notebook you'll run everything else in — so before touching any ML code, you need to know how to move around it, run cells, and not lose your work.

සිංහලෙන්: මේකෙන් තමයි අනිත් සියල්ල ධාවනය කරන්නේ — ML කේත ලියන්න කලින්, cells run කරන්නෙ කොහොමද, වැඩේ නැති වෙන්නෙ නැතුව save කරන්නෙ කොහොමද කියලා දැනගන්න ඕන.

What you'll use this for. Every single lesson after this one assumes you already know these basics — skip this and small things (a stuck cell, a lost file) will slow you down for weeks.

සිංහලෙන්: මින් පස්සේ තියෙන හැම පාඩමකම, ඔයා මේ මූලික දේවල් දන්නවා කියලා හිතාගෙනයි කරන්නෙ — මේක මගහැරියොත් පොඩි දේවල් (cell එකක් නවතිනවා, ගොනුවක් නැති වෙනවා) සති ගණනක් වේලාව නාස්ති කරයි.

Key principles

  • Cells run in order, not by position. A cell only knows about variables from cells that have already been run — scroll order on screen doesn't matter, run order does.
    Cells ධාවනය වෙන්නෙ පිළිවෙලට, තියෙන තැනට නෙවෙයි
  • Save to Drive, not just your browser. Colab keeps a copy in your Google Drive. Closing the tab is safe; losing your Google account access is not.
    Drive එකට save කරන්න, browser එකට විතරක් නෙවෙයි

Walkthrough

System Specifications

ExamplePython
!cat /proc/cpuinfo

Output

Output
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 63
model name	: Intel(R) Xeon(R) CPU @ 2.30GHz
stepping	: 0
microcode	: 0x1
cpu MHz		: 2299.998
cache size	: 46080 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
… (35 more lines)
ExamplePython
!cat /proc/meminfo

Output

Output
MemTotal:       13305332 kB
MemFree:        10739068 kB
MemAvailable:   12518448 kB
Buffers:           83580 kB
Cached:          1841060 kB
SwapCached:            0 kB
Active:           984448 kB
Inactive:        1350192 kB
Active(anon):     382636 kB
Inactive(anon):      416 kB
Active(file):     601812 kB
Inactive(file):  1349776 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:               760 kB
Writeback:             0 kB
… (32 more lines)

Installing Libraries

ExamplePython
!pip install pandas

Output

Output
Requirement already satisfied: pandas in /usr/local/lib/python3.7/dist-packages (1.1.5)
Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.7/dist-packages (from pandas) (2018.9)
Requirement already satisfied: numpy>=1.15.4 in /usr/local/lib/python3.7/dist-packages (from pandas) (1.19.5)
Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas) (2.8.1)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
ExamplePython
import pandas as pd
ExamplePython
df = pd.read_csv('/content/BostonHousing.csv')
ExamplePython
df.head()
crimzninduschasnoxrmage…
00.0063218.02.3100.5386.57565.2…
10.027310.07.0700.4696.42178.9…
20.027290.07.0700.4697.18561.1…
30.032370.02.1800.4586.99845.8…
40.069050.02.1800.4587.14754.2…
ExamplePython
print('Machine Learning')

Output

Output
Machine Learning
ExamplePython
!ls

Output

Output
BostonHousing.csv  sample_data

Keep going: ← Course overview · Lesson 2 → · Track it in the Self Guide