AI & IOT in Sport: Coding For Innovation - Modern AI in Python – SCOPES-DF

Lesson Details

Age Ranges *
18+,
Fab Tools *
Author
Additional Contributors

Author

Studio 5
Studio 5
Other
In line with the Ministry of Communications and Information Technology’s Digital Youth Strategy, STUDIO 5 is mainly aimed at nurturing youth as digital learners by sharpening their 21st century learning skills, as they develop in an all-pervasive digital environment. In… Read More

Summary

This workshop aims to teach participants Python coding and its fundamentals, using Python programming language. Which includes Python External Libraries for AI and Machine Learning, how to, install them, access their documentation for better understanding, check their functions and how/where to use them. In addition participants will have an “Open-Eye” on many different aspects of Python coding, and most of the area where Python excels.

What You'll Need

Projector/Screen, Laptop, Internet Access

 

Lesson Materials:

Presentation

Lesson Plan English

Lesson Plan Arabic

Lesson Materials

Learning Objectives

  • Using NTLK for AI analysis
  • Understanding AI/ML applications and regularization.
  • Implement and compare algorithms like intensity analyzer to get specific results.
  • Working with text data using Natural Language Processing (NLP).
  • Explore Generative AI and Large Language Models (LLMs) and prompt engineering. 
  • Understanding the responsible and ethical deployment of AI systems. 
  • What is AI / Modern AI
  • How to import and use AI libraries.
  • How to install external libraries and required files.
  • How to create and use Function to analyze given data
  • How to access library documentation
  • How to analyse/manipulate Data.
  • How to get results following user input.

 

Reflection

This session depends a lot on discussion and student input and work.

The Instructions

Presentation

A quick introduction about us and a way to break the Ice with the participant in order to engage with them in indirect way just to make a conversation and then a question to start the session.

Introduction & Icebreaking

Introduce yourself and Studio5. 

Ask about AI (Ice breaking).

 

 

Introduction to AI in Python

 

What is AI?

Artificial Intelligence (AI) is the ability of computer systems to perform tasks that usually require human intelligence, such as learning, problem-solving, understanding language, and making decisions, by processing data and recognizing patterns to adapt and improve performance without constant human intervention

 

ما هو الذكاء الاصطناعي؟

الذكاء الاصطناعي هو قدرة أنظمة الحاسوب على أداء مهام تتطلب عادةً ذكاءً بشريًا، مثل التعلم وحل المشكلات وفهم اللغة واتخاذ القرارات، وذلك من خلال معالجة البيانات والتعرف على الأنماط للتكيف وتحسين الأداء دون تدخل بشري مستمر.

 

Key aspects of AI:

  • Learning & Reasoning: 
  • AI systems learn from large datasets to identify patterns 
  • Make logical deductions
  • Perception: 
  • Enables machines to interpret sensory input,
  • Problem-Solving: 
  • Allows systems to find solutions to complex problems.
  • Adaptation: 
  • AI improves its performance over time as it’s exposed to more data

 

الجوانب الرئيسية للذكاء الاصطناعي:

  • التعلم والاستدلال:
  • تتعلم أنظمة الذكاء الاصطناعي من مجموعات البيانات الضخمة لتحديد الأنماط 
  • استخلاص النتائج المنطقية.
  • الإدراك:
  • يُمكّن الآلات من تفسير المدخلات الحسية.
  • حل المشكلات:
  • يُمكّن الأنظمة من إيجاد حلول للمشكلات المعقدة.
  • التكيف:
  • يُحسّن الذكاء الاصطناعي أداءه بمرور الوقت كلما تعرض لمزيد من البيانات.

 

 

 

 

 

Introduction to Modern AI in Python

 

What is Modern AI?

Modern AI refers to advanced computer systems, powered largely by Machine Learning (ML) and Deep Learning, that simulate human intelligence to learn from vast data, recognize patterns, solve problems, and perform tasks like understanding language (NLP), seeing (Computer Vision), and generating new content (Generative AI)

 

ما هو الذكاء الاصطناعي الحديث؟

يشير الذكاء الاصطناعي الحديث إلى أنظمة الكمبيوتر المتقدمة، التي تعمل بشكل كبير بواسطة التعلم الآلي والتعلم العميق، والتي تحاكي الذكاء البشري للتعلم من البيانات الضخمة، والتعرف على الأنماط، وحل المشكلات، وأداء مهام مثل فهم اللغة (معالجة اللغة الطبيعية)، والرؤية (رؤية الكمبيوتر)، وإنشاء محتوى جديد (الذكاء الاصطناعي التوليدي).

 

Key Aspects of Modern AI: 

  • Machine Learning (ML): 
  • Algorithms that analyze data, learn from it
  • Make predictions or decisions.
  • Deep Learning (DL):
  • A subset of ML, mimicking the human brain.
  • Natural Language Processing (NLP): 
  • Enables machines to understand, interpret
  • Generate human language.
  • Computer Vision: 
  • Allows AI to “see” and interpret visual information.
  • Generative AI: 
  • Creates new, original content (text, images, code).

 

أهم جوانب الذكاء الاصطناعي الحديث:

  • التعلم الآلي:
  • خوارزميات تحلل البيانات وتتعلم منها
  • تتنبأ بالنتائج أو تتخذ القرارات.
  • التعلم العميق:
  • فرع من فروع التعلم الآلي، يحاكي الدماغ البشري.
  • معالجة اللغة الطبيعية:
  • تمكّن الآلات من فهم اللغة البشرية وتفسيرها، وتوليدها.
  • رؤية الحاسوب:
  • تسمح للذكاء الاصطناعي برؤية المعلومات المرئية وتفسيرها.
  • الذكاء الاصطناعي التوليدي:
  • يُنشئ محتوى جديدًا وأصليًا (نصوص، صور، أكواد).

 

 

 

 

 

 

 

 

 

Step 1: Get Libraries and Lexicons

Step 2: User Data Process

Step 3: Display Results

 

الخطوة 1: احصل على المكتبات والمعاجم

الخطوة 2: معالجة بيانات المستخدم

الخطوة 3: عرض النتائج

 

NLTK Lexicon Download/Use – Python

تنزيل/استخدام معجم NLTK – بايثون

تثبيت المكتبات المطلوبة

 

Install the Required Libraries

استيراد المكتبات المطلوبة

Import the Required Libraries

تحميل ملف المعجم

Download the Lexicon File

استخدم وظائف محددة من ملف المعجم

Use Specific Functions and Functionalities from the Lexicon File

#install libraries

!pip install nltk scikit-learn

 

import nltk

nltk.download(‘vader_lexicon’)

from nltk.sentiment import SentimentIntensityAnalyzer

 

 

What is NLTK

 

The Natural Language Toolkit (NLTK) is a widely used, free, and open-source Python library for Natural Language Processing (NLP).

 

It provides a comprehensive suite of libraries, programs, and data sets for tasks such as text analysis, classification, tokenization, stemming, and tagging.

 

مجموعة أدوات اللغة الطبيعية (NLTK) هي مكتبة Python مجانية ومفتوحة المصدر ومستخدمة على نطاق واسع لمعالجة اللغات الطبيعية (NLP).

 

يوفر مجموعة شاملة من المكتبات والبرامج ومجموعات البيانات لمهام مثل تحليل النص والتصنيف والترميز والقطع ووضع العلامات.

 

 

 

 

NLTK Module Index

 

www.nltk.org/py-modindex.html

 

NLTK Module Index shows you the list of Functionalities and SUb-Functionalities of NLTK

 

يعرض لك فهرس وحدات NLTK قائمة الوظائف والوظائف الفرعية لـ NLTK

 

 

 

Nltk.sentiment.sentiment_analyzer 

Is the one we need and will be using

 

Nltk.sentiment.sentiment_analyzer

هو ما نحتاجه وسنستخدمه

 

Now, this code makes sense!

 

#install libraries

!pip install nltk scikit-learn

 

import nltk

nltk.download(‘vader_lexicon’)

from nltk.sentiment import SentimentIntensityAnalyzer

 

 

 

 

# Initialize the SentimentIntensityAnalyzer

sia = SentimentIntensityAnalyzer()

 

# Define a sentence for analysis

sentence = “I absolutely love learning AI with Python!”

 

Initialize the Analyzer

Create a New Object named “SIA” to use Functions and Sub-Functions of the Analyzer

Create a variable that holds the text we will be analyzing

 

تهيئة المحلل

أنشئ كائنًا جديدًا باسم “SIA” لاستخدام وظائف ووظائف فرعية للمحلل

أنشئ متغيرًا يحتوي على النص الذي سنقوم بتحليله.

 

 

# Get the sentiment polarity scores

scores = sia.polarity_scores(sentence)

 

# Print the results

print(f”Sentence: {sentence})

print(f”Sentiment Scores: {scores})

 

Store the List of Scores in a variable named “scores”

قم بتخزين قائمة الدرجات في متغير باسم “scores”.

 

Using “SIA” object created before, we will call the “polarity_scores()” function, giving it the Sentence we wrote, to get the Sentiment Score

 

باستخدام كائن “SIA” الذي تم إنشاؤه مسبقًا، سنستدعي الدالة “polarity_scores()”، ونمرر لها الجملة التي كتبناها، للحصول على درجة المشاعر.

 

 

Sentiment Scores: {‘neg’: 0.0, ‘neu’: 0.295, ‘pos’: 0.705, ‘compound’: 0.6989}

Sentiment Scores: {‘neg’: 0.0, ‘neu’: 1.0, ‘pos’: 0.0, ‘compound’: 0.0}

Sentiment Scores: {‘neg’: 0.682, ‘neu’: 0.318, ‘pos’: 0.0, ‘compound’: -0.6468}

 

Score is divided into 4 parts:

 

  • Negative
  • Neutral
  • Positive
  • Compound

 

We can take any of those values and do our further research and analysis.

 

In our case, we will take the COMPOUND value as an OVERALL result.

 

تنقسم النتيجة إلى 4 أجزاء

 

سلبي

محايد

إيجابي

مركب

 

يمكننا اختيار أيٍّ من هذه القيم وإجراء المزيد من البحث والتحليل

 

في حالتنا، سنعتمد القيمة المركبة كنتيجة إجمالية

 

 

 

# Determine if the sentiment is positive, negative, or neutral

 

if scores[‘compound’] >= 0.05:

   print(“Overall Sentiment: Positive”)

 

elif scores[‘compound’] <= –0.05:

   print(“Overall Sentiment: Negative”)

 

else:

   print(“Overall Sentiment: Neutral”)

 

This is where you can do whatever you want to do, according to business rules

هنا يمكنك أن تفعل ما تشاء، وفقًا لقواعد العمل.

 

 

 

All in All – Python

القراءة، المعالجة، الكتابة – بايثون

 

!pip install nltk scikit-learn

 

import nltk

nltk.download(‘vader_lexicon’)

from nltk.sentiment import SentimentIntensityAnalyzer

 

sia = SentimentIntensityAnalyzer()

 

sentence = “I absolutely love Running!”

 

scores = sia.polarity_scores(sentence)

 

print(scores)

 

if scores[‘compound’] >= 0.05:

   print(“Overall Sentiment: Positive”)

elif scores[‘compound’] <= –0.05:

   print(“Overall Sentiment: Negative”)

else:

   print(“Overall Sentiment: Neutral”)

 

 

 

 

 

Lesson Feedback

Contact us

Having trouble? Let us know by completing the form below. We'll do our best to get your issues resolved quickly.

"*" indicates required fields

This field is for validation purposes and should be left unchanged.
Name*
Email*
?