Python வழி Machine Learning தமிழில் – Collection

அனைவருக்கும் வணக்கம் இந்த post இல் python இல் உள்ள Collections பற்றி பார்போம். python இல் நான்கு வகையான collections உள்ளது.

  1. List
  2. Tuple
  3. Set
  4. Dictionary

நாம் இந்த நான்கு collections பற்றியும் கீழே விரிவாக பார்போம்.

List

list என்பது python இல் உள்ள ஒரு வகை collection ஆகும் இது வரிசையாகவும் மற்றும்  மாற்றக்கூடியதாகவும் இருக்கும். list இன் உதாரணம் கீழே கொடுக்கப்பட்டுள்ளது.

list ஐ குறிப்பதற்கு ” [ ] ” square brackets பயன்படுத்தபடும்.

thislist = ["apple", "banana", "cherry"]
print(thislist)

இந்த உதாரணத்திற்கு output கீழே உள்ளது போல இருக்கும்

['apple', 'banana', 'cherry']

நாம் இப்பொழுது data வை எப்படி access செய்வது என்பதை பார்க்கலாம்.

index and range of indexes

ஒரு element ஐ index பயன்படுத்தி வெளியே எடுப்பதற்க்கு கீழே ஒரு உதாரணம் கொடுக்கப்பட்டுள்ளது.

thislist = ["apple", "banana", "cherry"]
print(thislist[1])

இந்த program banana என்ற output ஐ கொடுக்கும்.

நாம் இப்பொழுது range of indexes program ஐ பார்க்கலாம்.

thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(thislist[2:5])

இந்த program [‘cherry’, ‘orange’, ‘kiwi’] என்ற output ஐ கொடுக்கும்.

நான் இந்த post இல் machine learning சம்மந்தமுள்ள  முக்கியமான தலைப்புகளை மட்டுமே குறிப்பிடுகிறேன். நீங்கள் python முழுமையாக படிக்க ஆசைப்பட்டால் வேறு இணையதளங்களை பார்க்கவும்.

Tuple

நாம் இப்பொழுது tuple பற்றி பார்க்கலாம். list மற்றும் tuple இவை இரண்டும் ஒரு இடத்தில் வேறுபடுகிறது அவை tuple இல் data வரிசையாக இருக்காது.

tuple ஐ குறிப்பதற்கு ” ( ) ” curve brackets பயன்படுத்தபடும்.

tuple இன் உதாரணம் கீழே கொடுக்கப்பட்டுள்ளது.

thistuple = ("apple", "banana", "cherry")
print(thistuple)

இந்த உதாரணத்திற்கு output கீழே உள்ளது போல இருக்கும்

(‘apple’, ‘banana’, ‘cherry’)

நாம் மேலே குறிப்பிட்டுள்ள data வை வெளியே எடுக்கும் முறைகள் tuple லுக்கும் பொருந்தும்.

Sets

நாம் அடுத்து sets பற்றி பார்க்கலாம்.

set என்பது வரிசையில்லாமலும்(unordered) மற்றும் குறிப்பு(index) இல்லாமலும் இருக்கும்.

set  ஐ குறிப்பதற்கு ” { } ” curly brackets பயன்படுத்தபடும்.

Set இன் உதாரணம் கீழே கொடுக்கப்பட்டுள்ளது

thisset = {"apple", "banana", "cherry"}
print(thisset) 

இந்த உதாரணத்திற்கு output list மற்றும் tuple இன் output போல இருக்கும்.

Sets இல் குறிப்பு(index ) இல்லாததால் நாம் data வை வெளியே எடுக்க loop செய்து வெளியே எடுக்க வேண்டும். நாம் ஒரு உதாரணத்தை பார்ப்போம்.

thisset = {"apple", "banana", "cherry"}

for x in thisset:
  print(x) 

இந்த உதாரணத்திற்கு output கீழே கொடுக்கப்பட்டுள்ளது

cherry
apple
banana

Dictionary

நாம் இந்த post இல் கடைசியாக பார்க்கபோவது dictionary. dictionary இல் data வரிசையில்லாமலும், குறிப்புடனும் (indexed) இருக்கும்.

Dictionary  ஐ குறிப்பதற்கு ” { } ” curly brackets பயன்படுத்தபடும். ஆனால் dictionary இல் key மற்றும் values இருக்கும்.

Dictionary  இன் உதாரணம் கீழே கொடுக்கப்பட்டுள்ளது

thisdict =	{
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
print(thisdict)

இந்த உதாரணத்திற்கு output கீழே கொடுக்கப்பட்டுள்ளது

{‘brand’: ‘Ford’, ‘model’: ‘Mustang’, ‘year’: 1964}

நாம் இப்பொழுது Dictionary இல் உள்ள Data வை எப்படி வெளியே எடுப்பது என்பதை பார்க்கலாம்.

நாம் Dictionary இல் இருந்து data வை key பயன்படுத்தி எடுக்கலாம். இதற்கு உதாரணம் கீழே கொடுக்கப்பட்டுள்ளது

x = thisdict["model"]

இந்த உதாரணத்திற்கு output கீழே கொடுக்கப்பட்டுள்ளது

“Mustang”

நாம் Dictionary இல் இருந்து Data வை எப்படி பாற்றுவது என்பதை பார்க்கலாம். இதற்கு உதாரணம் கீழே கொடுக்கப்பட்டுள்ளது

thisdict["year"] = 2018

இப்பொழுது year, 2018 என்று மாறியிருக்கும்.

நாம் இதில் இதற்குமேல் கவனம் செலுத்த தேவையில்லை ஏன் என்றால் நாம் machine learning program களில் numPy மற்றும் pandas dataframe பயன்படுத்துவோம் ஆனால் python collection பற்றி ஒரு அடிப்படை புரிதல் முக்கியம் அதனால் இந்த post முக்கியம் என்று நான் கருதிக்கிறேன். சரி நாம் அடுத்த post இல் numPy பற்றி பார்போம்.

வணக்கம் நண்பர்களே.

Python வழி machine learning தமிழில்: Variables and Datatypes

நாம் இந்த post இல் python இல் உள்ள variables and datatypes பற்றி பார்ப் போம். 

பொருளடக்கம் 

1. Variables & Datatypes 

2. Basic program

Variables & Datatypes 

ஒரு programming language இல் ஒரு program ஐ உருவாக்குவதற்கு  உதவுவது Variables ஆகும். Variables, data வை memory இல் வைத்துக்கொள்ளும். Python இல் variables மற்ற programming language களை விட வித்தியாசமாக இருக்கும்.  எப்படி என்றால்  python இல் variable declaration செய்யும் பொழுது datatype ஐ குறிப்பிட வேண்டிய அவசியமில்லை.  உதாரணத்திற்கு c ++ இல் variable declare செய்யும்போது கீழே உள்ளது போல declare செய்வோம்.

int a = 10;

ஆனால் python இல்

a = 10

என்று declare செய்வோம். மற்றொரு வித்தியாசம் என்னவென்று பார்த்தால் நாம் python program இல் “;” use செய்ய மாட்டோம்.

நாம் மேலும் சில உதாரணங்களை கீழே பார்ப்போம்.

x = 5         # assign variable x the value 5
y = x + 10     # assign variable y the value of x plus 10
z = y         # assign variable z the value of y

மற்ற programming language களில் உள்ளது போல python variables case sensitive ஆகும். மற்றும் variables களில் எழுத்துகள், எண்கள் மற்றும் ( _ ) கலந்து இருக்கலாம். ஆனால் variable கள் எண்களில் தொடங்கக்கூடாது.


python ஒரு dynamically typed programming மொழி ஆகும்.  அதனால் இது datatype ஐ variable இல் store ஆகும் value வை வைத்து முடிவு செய்து கொள்ளும்.


நாம் கீழே python எப்படி Datatype ஐ முடிவு செய்கிறது என்று பார்ப் போம்.

x = 1
print(type(x)) # outputs: <class 'int'>

x = 1.0
print(type(x)) # outputs: <class 'float'>

முதல் வரியில்


x=1


என்று இருக்கிறது. இது ஒரு integer value ஆகும் .அதனால் python


<class ‘int’>


என்ற output ஐ வெளியிடுகிறது.


இரண்டாவது variable ஒரு decimal value ஆகும்.  அதனால் python

<class ‘float’>

என்ற output ஐ வெளியிடுகிறது.
இந்த முறை மற்ற Data type களுக்கும் பொருந்தும்.

Basic program

நண்பர்களே, நாம் இப்பொழுது ஒரு variables and datatypes இன் basic program ஐ பார்க்கலாம்

x=10
y=x+12
print(y)
print("Data type of variable x and y" + str(type(x)) + str(type(y)))

d=1.2
print(d)
print("Data type of variable d is " + str(type(d)))

s = 'Arvin Education'
print(s)
print("Data type of variable s is " + str(type(s)))

இதன் output கீழே உள்ளது போல் இருக்கும்.

22
Data type of variable x and y<class 'int'><class 'int'>
1.2
Data type of variable d is <class 'float'>
Arvin Education
Data type of variable s is <class 'str'>

நண்பர்களே, நாம் அடுத்த பதிவில் python இல் உள்ள Control Statement பற்றி பார்ப்போம்.

நன்றி.  அடுத்த பதிவில் பார்க்கலாம்.

Jupyter notebook மற்றும் Python இல் machine learning படிக்க தொடங்குவதற்கு இந்த post ஐ படிக்கவும்

Machine learning ஐ படிக்க தொடங்குவதற்கு முதலில் நாம் Jupyter notebook ஐ தெரிந்துக் கொள்ள வேண்டும். நீங்கள் இதை Arvin Education YouTube Channel வாயிலாகவும் தெரிந்து கொள்ளலாம்.

Jupyter notebook என்றால் என்ன ?

Jupyter notebook என்பது ஒரு Open source web application ஆகும். இது code, narrations மற்றும் equations எழுதுவதற்கும் மற்றும் visualizations செய்வதற்கும் பயன்படுகிறது.

இப்பொழுது Jupyter notebook ஐ எப்படி Start செய்வது என்பதை பார்க்கலாம்.

முதலில் Start button ஐ அழுத்தி Anaconda3 (64-bit) > Anaconda Navigator (Anaconda3) என்ற Option ஐ கீழே உள்ள Screenshot போல Select செய்யுங்கள்.

Anaconda Navigator Open ஆனவுடன் அதில் கீழே உள்ள Screenshot போல Launch button ஐ Click செய்யுங்கள். இப்பொழுது Jupyter notebook start ஆகி விடும்.

Jupyter notebook start ஆனவுடன் கீழே உள்ள Screenshot போல இருக்கும்.

இது Jupyter notebook இன் File explorer section.இதில் உங்களுக்கு பிடித்த Folder ஐ Select செய்து கொள்ளவும்.அதன் பிறகு New button ஐ Click செய்து python 3 என்ற option ஐ Select செய்யவும்.

இப்பொழுது ஒரு புது Notebook உருவாகிவிடும். அது கீழே உள்ள Screenshot போல இருக்கும்.

மேலே உள்ள screenshot இல் Jupyter interface பற்றி தெளிவாக ஆங்கிலத்தில் குறிப்பிடப்பட்டுள்ளது. இதில் உள்ள Shortcut களும் ஆங்கிலத்தில் குறிப்பிடப்பட்டுள்ளது. 

நாம் இப்பொழுது ஒரு Basic Python program ஐ பார்ப்போம். கீழே உள்ள Code ஐ Copy செய்து Cell இல் Paste செய்யுங்கள். 

print('hello world')

நமக்கு கீழே உள்ள Screenshot போல output கிடைக்கும்.

சரி நண்பர்களே அடுத்த post இல் variables, functions, machine learning specific packages numPy, Pandas, Sklearn, Tensorflow, Kares, பற்றி பார்போம்.

நீங்கள் இந்த post ஐ ஆங்கிலத்தில் படிக்க விரும்பினால் கீழே உள்ள Link ஐ Click செய்யவும்.

நன்றி நண்பர்களே 

இந்த Post இல் பிழை இருந்தால் மன்னிக்கவும்.