0% found this document useful (0 votes)
20 views14 pages

AI Development Using Python

Uploaded by

hemaparvathi143
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views14 pages

AI Development Using Python

Uploaded by

hemaparvathi143
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ARTIFICIAL INTELLIGENCE WITH PYTHON

NAME: [Link]
COURSE: ARTIFICIAL INTELLIGENCE WITH PYTHON
COURSE COORDINATOR: SONAM DANGI
INSTITUTE: SAI VIDYA INSTITUTE OF
TECHNOLOGY

Abstract:
Artificial Intelligence (AI) has emerged as a transformative technology,
revolutionizing various industries and reshaping the way we approach problem-
solving. This abstract provides a comprehensive overview of the intersection
between Artificial Intelligence and the Python programming language,
showcasing the synergy that has propelled the development of intelligent
systems and applications.

The journey begins with an exploration of the fundamental concepts underlying


AI, including machine learning, deep learning, natural language processing, and
computer vision. The abstract delves into how Python, with its simplicity,
versatility, and rich ecosystem of libraries, has become the language of choice
for AI practitioners and researchers.

The abstract highlights key Python libraries and frameworks such as


TensorFlow, PyTorch, and scikit-learn, illustrating their roles in implementing
various AI algorithms and models. Practical examples demonstrate how Python
facilitates the training and deployment of machine learning models, enabling
users to solve complex problems in diverse domains.

Furthermore, the abstract addresses the role of Python in developing AI-driven


applications, emphasizing its significance in creating intelligent chatbots,
recommendation systems, and image recognition applications. It explores the
seamless integration of Python with popular web frameworks, facilitating the
deployment of AI solutions in real-world scenarios.

Ethical considerations and responsible AI practices are paramount, and the


abstract touches upon how Python, with its emphasis on readability and
transparency, aligns with ethical AI development. It also discusses the
importance of interpretability in AI models and how Python aids in creating
explainable and understandable solutions.

In conclusion, this abstract encapsulates the symbiotic relationship between


Artificial Intelligence and Python, illustrating how Python's simplicity, robust
libraries, and community support make it an ideal language for developing
intelligent systems. As AI continues to evolve, the Python programming
language stands as a powerful tool, empowering developers and researchers to
unlock the full potential of artificial intelligence.

Introduction
Artificial Intelligence (AI) represents a paradigm shift in the way we
conceptualize and approach problem-solving across various domains. As an
interdisciplinary field, AI encompasses a broad spectrum of techniques, ranging
from traditional rule-based systems to advanced machine learning algorithms
and neural networks. At the heart of this technological revolution lies Python, a
versatile and user-friendly programming language that has become synonymous
with AI development.

This introduction provides a glimpse into the symbiotic relationship between


Artificial Intelligence and Python, elucidating how Python's simplicity,
extensive libraries, and robust frameworks have positioned it as the language of
choice for AI practitioners. The journey through this exploration begins by
unraveling the fundamental concepts that constitute AI and its diverse
applications. From machine learning and deep learning to natural language
processing and computer vision, Python serves as the common thread weaving
through these intricate domains.

Python's prominence in the AI landscape is not merely coincidental but rather a


result of its ability to seamlessly integrate with cutting-edge AI libraries and
frameworks. TensorFlow, PyTorch, and scikit-learn are just a few examples of
the powerful tools that leverage Python's syntax and functionality to enable the
development of sophisticated AI models. This introduction highlights the
practical aspects of utilizing Python for AI, showcasing how it empowers
developers to train, validate, and deploy machine learning models with relative
ease.

Moreover, the discussion extends beyond the realm of model development,


shedding light on Python's role in crafting AI-driven applications. From
intelligent chatbots to recommendation systems and image recognition, Python's
adaptability and efficiency play a pivotal role in transforming theoretical AI
concepts into tangible solutions. The integration of Python with popular web
frameworks further facilitates the deployment of AI applications in real-world
scenarios, bridging the gap between theory and practical implementation.

As we navigate the landscape of AI, ethical considerations and responsible


development practices come to the forefront. Python's emphasis on readability
and transparency aligns seamlessly with the principles of ethical AI, and this
introduction touches upon the importance of creating interpretable and
understandable AI models.

CODE
NOTE: CODE MUST BE TYPED IN JUPITER NOTEBOOK AND EACH STEP SHOULD HAVE TO HAVE ITS INDUVIDUAL
BLOCK OF CODE FOR BEST RESULTS

STEP 1:
IMPORTING MODULES
import tensorflow as tf
from tensorflow import keras
import [Link] as plt
import numpy as np
import pandas as pd

STEP 2:
GETTING DATA FROM KERAS DATASET: i.e. [Link]
fashion=[Link].fashion_mnist
(X_train, y_train),(X_test, y_test)= fashion.load_data()

OUTPUT:
Downloading data from [Link]
29515/29515 [==============================] - 0s 3us/step
Downloading data from [Link]
26421880/26421880 [==============================] - 27s 1us/step
Downloading data from [Link]
5148/5148 [==============================] - 0s 0s/step
Downloading data from [Link]
4422102/4422102 [==============================] - 4s 1us/step

STEP 3:
VALUES OF THE X_train and X_test are converted into ‘float32’,and
divided by 255 to get exact values i.e. 0’s and 1’s.

X_train=X_train.astype('float32')/255
X_test=X_test.astype('float32')/255

AFTER THIS STEP LET’S TAKE A LOOK AT THE y_test

y_test=array([9, 2, 1, ..., 8, 1, 5], dtype=uint8)

Therefore we have the exact integer values

STEP 4:
CREATE AN ARRAY WITH THE LIST OF ELEMENTS
AVAILABLE ON THE [Link]

class_names = ["T-shirt/top",
"Trouser",
"Pullover",
"Dress",
"Coat",
"Sandal",
"Shirt",
"Sneaker",
"Bag",
"Ankle boot"
]

LETS CHECK WHETHER THE ARRAY AS IMPLIMENTED OR NOT

class_names[y_train[0]]
OUTPUT:
'Ankle boot'

AS THE ARRAY IS IMPLEMENTED LETS GET TO THE OTHER STEPS

STEP 5:
TO SHOW THE IMAGE THAT THE y_train CONTAINS

[Link](X_train[0],cmap='grey')
class_names[y_train[0]]
OUTPUT:
‘ANKLE BOOT’
STEP 6:
THE MOST IMPORTANT STEP IS TO CRAETE HIDDEN LAYERS
IN THE MODULE
LAYER1-INPUT LAYER
LAYER2-CONNECTING LAYERS
LAYER3-OUTPUT LAYER

SNN=[Link]()
[Link]([Link](input_shape=[28,28]))
[Link]([Link](300,activation='relu'))
[Link]([Link](100,activation='relu'))
[Link]([Link](10,activation='softmax'))

AFTER RUNNING THE ABOVE CODE FOR CHECKING THE


ACTIATION LAYERS
[Link]()

OUTPUT:
Model: "sequential"
________________________________________________________________
_
Layer (type) Output Shape Param #
=========================================================
========
flatten (Flatten) (None, 784) 0

dense (Dense) (None, 300) 235500

dense_1 (Dense) (None, 100) 30100

dense_2 (Dense) (None, 10) 1010

=========================================================
========
Total params: 266610 (1.02 MB)
Trainable params: 266610 (1.02 MB)
Non-trainable params: 0 (0.00 Byte)

STEP 7:
THE MODULE IS COMPILED USING LOSS OF SCC i.e. SPARSE
CATEGORICAL CROSSENTROPY
OPTIMIZER=’SGD’
METRICS=’ACCURACY’
NOTE: IF THE ACCURACY RETURNED IS LESS USE OTHER OPTIMIZERS
LIKE ADAM, RMSdrop

[Link](loss="sparse_categorical_crossentropy",optimizer="sgd",metr
ics=["accuracy"])

STEP 8:
THE MODULE VALUES ARE THEN FITTED INTO THE OBJECTS
“HISTORY” CREATED BY USER
history=[Link](X_train,y_train,epochs=30)

OUTPUT:

Epoch 1/30

1875/1875 [==============================] - 22s 7ms/step - loss:


0.6866 - accuracy: 0.7726

Epoch 2/30

1875/1875 [==============================] - 17s 9ms/step - loss:


0.4763 - accuracy: 0.8349

Epoch 3/30

1875/1875 [==============================] - 15s 8ms/step - loss:


0.4343 - accuracy: 0.8489

Epoch 4/30

1875/1875 [==============================] - 16s 9ms/step - loss:


0.4071 - accuracy: 0.8564

Epoch 5/30

1875/1875 [==============================] - 13s 7ms/step - loss:


0.3872 - accuracy: 0.8642

Epoch 6/30

1875/1875 [==============================] - 13s 7ms/step - loss:


0.3710 - accuracy: 0.8694
Epoch 7/30

1875/1875 [==============================] - 14s 7ms/step - loss:


0.3581 - accuracy: 0.8729

Epoch 8/30

1875/1875 [==============================] - 13s 7ms/step - loss:


0.3463 - accuracy: 0.8769

Epoch 9/30

1875/1875 [==============================] - 13s 7ms/step - loss:


0.3363 - accuracy: 0.8802

Epoch 10/30

1875/1875 [==============================] - 14s 7ms/step - loss:


0.3265 - accuracy: 0.8832

Epoch 11/30

1875/1875 [==============================] - 15s 8ms/step - loss:


0.3187 - accuracy: 0.8861

Epoch 12/30

1875/1875 [==============================] - 12s 7ms/step - loss:


0.3101 - accuracy: 0.8894

Epoch 13/30

1875/1875 [==============================] - 12s 7ms/step - loss:


0.3034 - accuracy: 0.8916

Epoch 14/30

1875/1875 [==============================] - 11s 6ms/step - loss:


0.2971 - accuracy: 0.8931

Epoch 15/30

1875/1875 [==============================] - 12s 6ms/step - loss:


0.2910 - accuracy: 0.8959

Epoch 16/30

1875/1875 [==============================] - 13s 7ms/step - loss:


0.2839 - accuracy: 0.8978

Epoch 17/30

1875/1875 [==============================] - 12s 6ms/step - loss:


0.2782 - accuracy: 0.8993

Epoch 18/30
1875/1875 [==============================] - 11s 6ms/step - loss:
0.2732 - accuracy: 0.9012

Epoch 19/30

1875/1875 [==============================] - 12s 6ms/step - loss:


0.2676 - accuracy: 0.9031

Epoch 20/30

1875/1875 [==============================] - 11s 6ms/step - loss:


0.2627 - accuracy: 0.9052

Epoch 21/30

1875/1875 [==============================] - 11s 6ms/step - loss:


0.2572 - accuracy: 0.9075

Epoch 22/30

1875/1875 [==============================] - 11s 6ms/step - loss:


0.2539 - accuracy: 0.9082

Epoch 23/30

1875/1875 [==============================] - 12s 6ms/step - loss:


0.2484 - accuracy: 0.9103

Epoch 24/30

1875/1875 [==============================] - 12s 6ms/step - loss:


0.2445 - accuracy: 0.9121

Epoch 25/30

1875/1875 [==============================] - 11s 6ms/step - loss:


0.2402 - accuracy: 0.9130

Epoch 2/30

1875/1875 [==============================] - 12s 6ms/step - loss:


0.2364 - accuracy: 0.9152

Epoch 27/30

1875/1875 [==============================] - 11s 6ms/step - loss:


0.2330 - accuracy: 0.9155

Epoch 28/30

1875/1875 [==============================] - 12s 6ms/step - loss:


0.2296 - accuracy: 0.9175

Epoch 29/30
1875/1875 [==============================] - 11s 6ms/step - loss:
0.2241 - accuracy: 0.9202

Epoch 30/30

1875/1875 [==============================] - 12s 6ms/step - loss:


0.2212 - accuracy: 0.9195

AS I WAS RETURNED WITH THE HIGHEST ACCURACY OF 91%


THE MODULE WORKS FINE>>>>>
STEP 9:
EVALUATING THE MODULE X_train,y_train

[Link](X_train,y_train)

STEP 10:
AS THE MODULE VALUES ARE DECIMALS WE CONERT IT INTO
WHOLE NUMBERS USING THE FUNTION OF NUMPY i.e. argmax()

predict_class=[Link](predict_y,axis=1)
OUTPUT:
array([9, 2, 1, ..., 8, 1, 5], dtype=int64)

STEP 11:
FOR INPUT GETTING RANDOM VALUES AND THE OUTPUT IS
ACCURATE OF 91 percentage
from random import randrange
item=randrange(10000)
[Link](X_test[item],cmap='grey')
print("The predicted class is "+ str(class_names[predict_class[item]]))

THE COMPILER PICS A RANDOM ALUE FOR THE ITEM AND SHOWS
THE FASHION ITEM

OUTPUT:
The predicted class is Coat

 SCREENSHOT OF THE OUTPUT:


CONCLUSION
In the dynamic landscape of Artificial Intelligence, Python has emerged not only as a facilitator but as
a driving force behind the transformative advancements in the field. Through this exploration, we
have witnessed the symbiotic relationship between AI and Python, understanding how the language's
simplicity, versatility, and robust ecosystem have propelled the development of intelligent systems
and applications.

Python's role in AI extends beyond mere syntax and convenience; it encapsulates the essence of
accessibility, enabling both seasoned professionals and aspiring developers to engage with complex
AI concepts effortlessly. From foundational principles like machine learning to cutting-edge
technologies such as deep learning, Python serves as a common language that unifies diverse
methodologies, making AI development more inclusive and collaborative.

The practical dimension of Python in AI implementation is evident in its seamless integration with
powerful libraries and frameworks. TensorFlow and PyTorch empower developers to design and train
intricate neural networks, while scikit-learn simplifies the application of machine learning algorithms.
This ease of use not only expedites the development process but also encourages experimentation and
innovation, fostering a vibrant AI community.

The versatility of Python is further highlighted in the creation of AI-driven applications. Whether it's
crafting intelligent chatbots, building recommendation systems, or deploying image recognition
solutions, Python's adaptability facilitates the translation of theoretical AI concepts into real-world
applications. The integration of Python with web frameworks extends the reach of these applications,
ensuring their impact in diverse sectors.

Ethical considerations are paramount in the development of AI, and Python's emphasis on readability
and transparency aligns with the principles of responsible AI. The quest for interpretability and
explain ability in AI models finds resonance in Python's design philosophy, addressing the ethical
challenges associated with the deployment of intelligent systems.

As we conclude this exploration, it becomes evident that the synergy between Artificial Intelligence
and Python is not just a technical marriage; it symbolizes a democratization of AI, where the power to
innovate and solve complex problems is placed in the hands of a broad and diverse community.
Python's continued evolution alongside the advancements in AI reaffirms its status as a cornerstone in
the ongoing narrative of intelligent technologies.

In the ever-evolving landscape of technology, the journey of AI using Python is not reaching a
destination but rather opening doors to new possibilities. The story of AI and Python is one of
collaboration, empowerment, and limitless potential, promising an exciting future where the
boundaries of artificial intelligence continue to be pushed, guided by the simplicity and dynamism of
the Python programming language.

Common questions

Powered by AI

Key ethical considerations in developing AI applications using Python include the emphasis on creating interpretable and understandable AI models. Python's readability and transparency align with ethical AI principles, facilitating responsible development. Ensuring that AI systems are explainable helps address ethical challenges associated with deploying intelligent solutions. These practices underscore the importance of responsible and transparent AI development .

Python facilitates ethical AI practices by promoting readability and transparency in its code, which are essential for creating interpretable AI models. This transparency allows developers to build solutions that are understandable and align with ethical AI principles, such as accountability and fairness. Additionally, Python's community and documentation emphasize the importance of responsible AI development, ensuring that practitioners adhere to ethical guidelines while crafting intelligent systems .

Python supports the implementation of machine learning models for real-world applications through its integration with powerful libraries and frameworks like TensorFlow, PyTorch, and scikit-learn. These tools enable developers to build, train, and deploy models effectively. Python's adaptability and simplicity ensure that theoretical AI concepts can be easily translated into practical solutions, such as intelligent chatbots, recommendation systems, and image recognition applications. The language's seamless integration with web frameworks further facilitates the deployment of these models in diverse industries .

Python facilitates the integration of AI libraries and frameworks, such as TensorFlow, PyTorch, and scikit-learn, through its user-friendly syntax and functionality. This enables developers to construct sophisticated AI models. Python's simplicity, extensive libraries, and robust frameworks allow seamless development, training, and deployment of machine learning models. The language's adaptability is crucial in transforming complex AI concepts into real-world applications, making it a preferred choice among AI practitioners .

Python is frequently chosen for AI-driven applications, such as chatbots and recommendation systems, due to its simplicity, versatility, and rich ecosystem of libraries. The language's ability to seamlessly integrate with powerful AI frameworks makes it ideal for developing and deploying intelligent applications. Its adaptability allows developers to turn theoretical AI concepts into practical, real-world solutions effectively and efficiently .

Python enhances AI model interpretability and explainability by emphasizing readability and transparency in its code. This aligns well with the principles of ethical AI, which prioritize creating understandable and interpretable models. Python's design philosophy, combined with its robust library ecosystem, enables developers to implement solutions that are not only effective but also explainable, addressing key ethical considerations in AI deployment .

Python contributes to the democratization of artificial intelligence by lowering the barrier to entry for both seasoned professionals and aspiring developers. Its simplicity, versatility, and extensive ecosystem enable a wide range of users to engage with complex AI concepts effortlessly. The availability of powerful libraries, such as TensorFlow and PyTorch, facilitates the design and training of neural networks, while scikit-learn simplifies machine learning algorithm applications. This accessibility fosters collaboration and innovation, empowering a diverse community to participate in AI development .

Python plays a significant role in bridging theoretical AI concepts with practical solutions by providing an intuitive and powerful platform for developing intelligent systems. Its simple syntax, coupled with a wide range of AI libraries and frameworks, allows developers to effectively implement complex AI ideas. This enables the translation of research advancements into applications like chatbots, recommendation systems, and image recognition software. Python's adaptability and efficiency facilitate the deployment of AI models in real-world contexts, ensuring that theoretical innovations can be transformed into usable technologies .

Python's integration with web frameworks enhances the deployment of AI applications by allowing for seamless incorporation of AI models into web services. This integration bridges the gap between theoretical AI concepts and practical implementation, facilitating the creation of applications that can be easily deployed in real-world scenarios. The accessibility of Python, combined with the capabilities of its web frameworks, ensures that AI applications can reach a broader audience and have a significant impact across diverse industries .

Python's ecosystem provides several advantages to AI practitioners and researchers, including a vast array of libraries and frameworks like TensorFlow, PyTorch, and scikit-learn, which streamline the development of AI models. This ecosystem supports advanced machine learning, deep learning, and natural language processing applications. Python's emphasis on simplicity and readability fosters easy experimentation and collaboration among the AI community, encouraging innovation and the development of accessible and efficient AI solutions .

You might also like