0% found this document useful (0 votes)
4 views

al ml python

The document discusses the vision and mission of Sumukha InfoTech, emphasizing the importance of practical education and software development. It introduces machine learning and its implementation using Python, detailing libraries such as scikit-learn and TensorFlow, and provides a KNN classification algorithm example using the Iris dataset. The conclusion highlights Python's significance in AI and machine learning, asserting its role in transforming data into actionable insights.

Uploaded by

Sareena K
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

al ml python

The document discusses the vision and mission of Sumukha InfoTech, emphasizing the importance of practical education and software development. It introduces machine learning and its implementation using Python, detailing libraries such as scikit-learn and TensorFlow, and provides a KNN classification algorithm example using the Iris dataset. The conclusion highlights Python's significance in AI and machine learning, asserting its role in transforming data into actionable insights.

Uploaded by

Sareena K
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

CHAPTER 1
ABOUT THE ORGANIZATION

Started on 08/08/2018, Sumukha InfoTech’s vision is to contribute to the society in a


bigger way.
Education isn’t just about going to school / college and securing high marks. It’s something
beyond marks and competition.
“Education is what remains after one has forgotten what he had learnt in his schooling.” –
Albert Einstein.
It's about application of your knowledge / idea that actually matters, and not just having idea!
Here at Sumukha we just don’t tell you, we demonstrate you how things work. The video’s are
shot real time while we build our applications. We bring to you the latest and the best in the
industry, so that YOU as an individual can perform better in the areas of application
development.
Vision: Help improve the quality of life’s of people through our software products and through
our social service activities.
Mission: To deliver quality product and services and to build trust and good relation with
clients and society.
Values: Stick on to our ethics of being transparent and to provide maximum value to our
clients.
Entrepreneurship:
The vision of the founders is to enable people stand on their own and work towards their vision
of making this world a better place for everyone from their skills. This could be accomplished
by our individual skills and the freedom to follow our heart.
We at Sumukha have a community of energetic, enthusiastic people who would love to make
a difference. Who would love to work out of passion. A day at work is satisfying, if we made
something that would matter and not just which would bring us profits.
Our Works:
We are a team constantly learning and contributing to the software development world.
Our real time projects have been running successfully and getting good feedback from clients.
Our interest and expertise in computer networks and distributed computing as a whole has
made us come up with sophisticated and highly useful.

Dept. of CSE, GEC Haveri 2023-24 Page 1


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

CHAPTER 2
INTRODUCTION TO AL & ML WITH PYTHON

2.1 Definition
Machine Learning : Machine learning is a type of artificial intelligence (AI) that provides
computers with the ability to learn without being explicitly programmed. Machine learning
focuses on the development of Computer Programs that can change when exposed to new
data. In this article, we’ll see basics of Machine Learning, and implementation of a simple
machine-learning algorithm using python.
Machine learning is a method of teaching computers to learn from data, without being
explicitly programmed. Python is a popular programming language for machine learning
because it has a large number of powerful libraries and frameworks that make it easy to
implement machine learning algorithms.
To get started with machine learning using Python, you will need to have a basic
understanding of Python programming and some knowledge of mathematical concepts such
as probability, statistics, and linear algebra.
There are several libraries and frameworks in Python that can be used for machine learning,
including:
scikit-learn: This library provides a wide range of machine learning algorithms, including
supervised and unsupervised learning, and it is built on top of other libraries such as NumPy
and SciPy.
TensorFlow: This library is an open-source machine learning framework developed by
Google, it is widely used for deep learning and other complex machine learning tasks.
Keras: A high-level neural networks API, written in Python and capable of running on top
of TensorFlow, CNTK, or Theano.
PyTorch: An open-source machine learning library for Python, based on Torch library. It
provides a seamless integration of computation graph and PyTorch tensors.
Theano: A numerical computation library for Python that allows you to efficiently define,
optimize, and evaluate mathematical expressions involving multi-dimensional arrays.
Pandas: A library that provides fast and flexible data structures and data analysis tools for
the Python programming language.

Dept. of CSE, GEC Haveri 2023-24 Page 2


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

2.2 Setting up the environment


Python community has developed many modules to help programmers implement machine
learning. In this article, we will be using numpy, scipy and scikit-learn modules. We can
install them using cmd command:
pip install numpy scipy scikit-learn

A better option would be downloading miniconda or anaconda packages for python, which
come prebundled with these packages. Follow the instructions given here to use anaconda.

2.2.1 Machine Learning overview

Machine learning involves a computer to be trained using a given data set, and use
this training to predict the properties of a given new data. For example, we can train a
computer by feeding it 1000 images of cats and 1000 more images which are not of a cat,
and tell each time to the computer whether a picture is cat or not. Then if we show the
computer a new image, then from the above training, the computer should be able to tell
whether this new image is a cat or not.

The process of training and prediction involves the use of specialized algorithms. We feed
the training data to an algorithm, and the algorithm uses this training data to give predictions
on a new test data. One such algorithm is K-Nearest-Neighbor classification (KNN
classification). It takes a test data, and finds k nearest data values to this data from test data
set. Then it selects the neighbor of maximum frequency and gives its properties as the
prediction result. For example if the training set is:

petal_size flower_type
1 a
2 b
1 a
2 b
3 c
4 d
3 c
2 b
5 a

Now we want to predict flower type for petal of size 2.5 cm. So if we decide no. of neighbors
(K)=3, we see that the 3 nearest neighbors of 2.5 are 1, 2 and 3. Their frequencies are 2, 3
and 2 respectively. Therefore the neighbor of maximum frequency is 2 and flower type
corresponding to it is b. So for a petal of size 2.5, the prediction will be flower type b.

Dept. of CSE, GEC Haveri 2023-24 Page 3


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

2.2.2 Implementing KNN- classification algorithm using Python on IRIS dataset

Here is a python script which demonstrates knn classification algorithm. Here we use the
famous iris flower dataset to train the computer, and then give a new value to the computer
to make predictions about it. The data set consists of 50 samples from each of three species
of Iris (Iris setosa, Iris virginica and Iris versicolor). Four features are measured from each
sample: The length and Width of Sepals & Petals, in centimeters.

We train our program using this dataset, and then use this training to predict species of a iris
flower with given measurements.

EX: 1

# Python program to demonstrate


# KNN classification algorithm
# on IRIS dataset

from sklearn.datasets import load_iris


from sklearn.neighbors import KNeighborsClassifier
import numpy as np
from sklearn.model_selection import train_test_split

iris_dataset=load_iris()

X_train, X_test, y_train, y_test = train_test_split(iris_dataset["data"], iris_dataset["target"],


random_state=0)

kn = KNeighborsClassifier(n_neighbors=1)
kn.fit(X_train, y_train)

x_new = np.array([[5, 2.9, 1, 0.2]])


prediction = kn.predict(x_new)

print("Predicted target value: {}\n".format(prediction))


print("Predicted feature name: {}\n".format
(iris_dataset["target_names"][prediction]))
print("Test score: {:.2f}".format(kn.score(X_test, y_test)))

Output:
Predicted target name: [0]
Predicted feature name: ['setosa']
Test score: 0.97

Dept. of CSE, GEC Haveri 2023-24 Page 4


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

2.2.3 Explanation of the program

Training the Dataset


 The first line imports iris data set which is already predefined in sklearn module.
Iris data set is basically a table which contains information about various varieties
of iris flowers.
 We import kNeighborsClassifier algorithm and train_test_split class from sklearn
and numpy module for use in this program.
 Then we encapsulate load_iris() method in iris_dataset variable. Further we divide
the dataset into training data and test data using train_test_split method. The X
prefix in variable denotes the feature values (eg. petal length etc) and y prefix
denotes target values (eg. 0 for setosa, 1 for virginica and 2 for versicolor).
 This method divides dataset into training and test data randomly in ratio of 75:25.
Then we encapsulate KNeighborsClassifier method in kn variable while keeping
value of k=1. This method contains K Nearest Neighbor algorithm in it.
 In the next line, we fit our training data into this algorithm so that computer can
get trained using this data. Now the training part is complete.
Testing the Dataset
 Now we have dimensions of a new flower in a numpy array called x_new and we
want to predict the species of this flower. We do this using the predict method
which takes this array as input and spits out predicted target value as output.
 So the predicted target value comes out to be 0 which stands for setosa. So this
flower has good chances to be of setosa species.
 Finally we find the test score which is the ratio of no. of predictions found correct
and total predictions made. We do this using the score method which basically
compares the actual values of the test set with the predicted values.

Dept. of CSE, GEC Haveri 2023-24 Page 5


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

CHAPTER 3
ASSIGNMENTS

3.1 Calci demo:

Output:

Dept. of CSE, GEC Haveri 2023-24 Page 6


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

3.2 Winprime demo:

Output :

Dept. of CSE, GEC Haveri 2023-24 Page 7


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

3.3 Window demo :

Output :

Dept. of CSE, GEC Haveri 2023-24 Page 8


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

3.4 Animated demo :

Output:

Dept. of CSE, GEC Haveri 2023-24 Page 9


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

CHAPTER 4
REFLECTION

4.1 Weatheraui.py :

import requests
apikey="2bd7c775ee9ce7b80a2712abcdd5361b"
import joblib
import numpy as np

def fetch_weather(cityname):

url=f"https://api.openweathermap.org/data/2.5/weather?q={cityname}&appid={
apikey}"

response=requests.get(url)#get -> show the result just like enter

print(response)

if response.status_code==200:

print("Done successfull")

# print( response.json() )

result=response.json()#json-> used to #convert web response to python


dictionary form

x=result['main']

temp=x['temp']-273.15
pressure=x['pressure']
humidity=x['humidity']

model=joblib.load("knncropmodel.pkl")#knncropmodel-> algorithm load by


calling joblib

testdata=np.array([[temp,humidity]])
pred=model.predict(testdata)

msg=f"Weahter info is..\ntemp:{temp} degree cel\nPressure :


{pressure}\nHumidity : {humidity}\nRecomended crop is : {pred[0]}"

else:
msg="Some thing went wrong !"

return msg

Dept. of CSE, GEC Haveri 2023-24 Page 10


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

4.2 Weathergui.py :

import tkinter as tk

from weatherapi import fetch_weather


from tkinter.messagebox import showinfo

def fetchinfo():
print("you clicked")
cityname=strt1.get()

result=fetch_weather(cityname)
showinfo("wether report",result)

window=tk.Tk()#tk->package and Tk->class

window.geometry('500x500')#def size by dimensions

window.title("Weather App")

lbl1=tk.Label(window,text="Enter city name",bg="cyan").place(x=50,y=100)#tk ->


library, lbl->object of class Label

strt1=tk.StringVar()#to get inpput given->stringvar

t1=tk.Entry(window,textvariable=strt1).place(x=150,y=100)#textvariable-
>property, strt1->value, entry used to get value when we click on window

b1=tk.Button(window,text="Fetch weather
info",command=fetchinfo).place(x=280,y=100)#command will define the class and
used chick tyhe button then fetch the info by fetch weather info

window.config(bg="cyan")#changes the background color


window.mainloop()#display on box and keeps window active

4.3 App.py
#import app1
#print(f"value of __name__ in app.py is : {__name__}")

from flask import Flask,render_template,request#class , function , object and


flask->library
import numpy as np
import joblib

model=joblib.load("knnmodel.pkl")

Dept. of CSE, GEC Haveri 2023-24 Page 11


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

app=Flask(__name__)

@app.route('/')
def index():
return render_template('cropform.html')

@app.route('/predict',methods=['GET','POST'])
def prediction():

testdata=[float(x) for x in request.form.values()]

print(testdata)

td=np.array([testdata])

pred=model.predict(td)

result=f"Predicted crop is : {pred[0]}"

return render_template('cropform.html',res=result)

if __name__=='__main__':

app.run(debug=True)
output :

Dept. of CSE, GEC Haveri 2023-24 Page 12


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

Conclusion

Python’s dominance in AI and Machine Learning is no accident. Its ease of use, versatility, and
vast ecosystem of powerful libraries and frameworks make it the ideal language for building
intelligent systems. Whether it’s computer vision, natural language processing, or predictive
analytics, Python enables developers to turn complex algorithms into practical solutions.

As the field of AI and Machine Learning continues to evolve, Python will undoubtedly remain
at the forefront of innovation. If you aspire to make an impact in these cutting-edge
technologies, mastering Python is a crucial step in your journey. So, whether you’re a seasoned
developer or just stepping into the realm of AI and Machine Learning, Python is your ultimate
companion for shaping the future through innovation and intelligent technology.

In a world where data is the new currency and intelligence is the driving force, Python stands
as the bridge that transforms raw information into actionable insights. As you embark on your
AI and Machine Learning endeavours, remember that Python is not just a programming
language; it’s a gateway to unlocking the potential of artificial intelligence and reshaping the
landscape of innovation. So, seize the opportunity, harness the power of Python, and join the
revolution of building intelligent systems that redefine what’s possible.

Dept. of CSE, GEC Haveri 2023-24 Page 13


REPORT ON ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING WITH PYTHON

Bibliography

1. AgroConsultant: Intelligent Crop Recommendation System Using Machine Learning Algorithms.


Zeel Doshi , Subhash Nadkarni , Rashi Agrawal, Prof. Neepa Shah.

2. Crop Recommendation System for Precision Agriculture S.Pudumalar*, E.Ramanujam*, R.Harine


Rajashree, C.Kavya, T.Kiruthika, J.Nisha.

3. Tom M. Mitchell, Machine Learning, India Edition 2013, McGraw Hill Educa- tion.

4. Kagglehttps://www.kaggle.com/notebook

5. www.sumukhainfotech.com

Dept. of CSE, GEC Haveri 2023-24 Page 14

You might also like