Posts

Showing posts with the label Programming

Checking Vowels in String

 Checking Vowels in String def CheckVovels(var): Vovels=['a','e','i','o','u','A','E','I','O','U'] count=0 for i in range(0,len(Vovels),1): if Vovels[i]==var: return True else: count=count+1 if count>0: return False text=input("Enter something about you:") List=text.split(); for i in range(0,len(List),1): if CheckVovels(List[i][0]): List[i]=List[i]+"hey" else: temp1=List[i]; temp2=List[i][0]; temp3=temp1.replace(temp2,''); List[i]=temp3 List[i]=List[i]+"hey" print(List)

Reflex Cleaning Agent

Reflex Cleaning Agent  percept=["dirty","dirty"] action=["Move Right","Move Left","Clean Dirt"] class Agent: def __init__(self): self.position=0 self.currentAction=0 self.runAgent() def runAgent(self): self.getAction(percept[0]) def getAction(self,cPercept): if(cPercept=="dirty"): self.currentAction=action[2] self.updateRooms() elif(cPercept=="clean"): if(self.position==0): self.currentAction=action[0] self.updatePosition() elif(self.position==1): self.currentAction=action[1] self.updatePosition() def updatePosition(self): if(self.currentAction==action[0]): self.position=1 self.getAction(percept[1]) elif(self.currentAction==action[1]): self.position=0 def updateRooms(self):

Principle Component Analysis (PCA) without using function

 PCA without using function import matplotlib.pyplot as plt from sklearn import datasets from sklearn.preprocessing import MinMaxScaler import numpy as np iris=datasets.load_iris() data=np.array(iris.data[:10,:2]) scaler=MinMaxScaler() scaler.fit(data) data=scaler.transform(data) print(data) irisDataset=data irisDataset_mean = irisDataset - np.mean(irisDataset , axis = 0) cov_mat = np.cov(irisDataset_mean , rowvar = False) eigen_values , eigen_vectors = np.linalg.eigh(cov_mat) sorted_index = np.argsort(eigen_values)[::-1] sorted_eigenvalue = eigen_values[sorted_index] sorted_eigenvectors = eigen_vectors[:,sorted_index] n_components = 2 eigenvector_subset = sorted_eigenvectors[:,0:n_components] irisDataset_reduced = np.dot(eigenvector_subset.transpose(),irisDataset_mean.transpose()).transpose() print(irisDataset_reduced) plt.plot(data[:,0],data[:,1]) plt.title('Before PCA') plt.show() plt.plot(irisDataset_reduced[:,0],irisDataset_reduced[:,1]) plt.title('After PCA') pl

PCA using build in function

 PCA using build in function import matplotlib.pyplot as plt from sklearn import datasets from sklearn.preprocessing import MinMaxScaler import numpy as np iris=datasets.load_iris() data=np.array(iris.data[:10,:2]) scaler=MinMaxScaler() scaler.fit(data) data=scaler.transform(data) print("old data ",data) plt.plot(data[:,0],data[:,1]) plt.title('Before PCA') plt.show() from sklearn.decomposition import PCA pca=PCA(n_components=2) pca.fit(data) newData=pca.transform(data) print(data.shape,newData.shape) print("new Data ",newData) plt.plot(data[:,0],data[:,1]) plt.title('After PCA') plt.show()

Principle Component Analysis (PCA)

 Principle Component Analysis (PCA) This is Machine Learning based algorithm lies under the Unsupervised Learning. This is the simplest code using python import matplotlib.pyplot as plt from sklearn import datasets import numpy as np iris=datasets.load_iris() data=np.array(iris.data[:10,:2]) xdata=data[:,0] ydata=data[:,1] n=len(xdata) print(n) x=np.mean(xdata) y=np.mean(ydata) c=np.cov(xdata,ydata) values, vector = np.linalg.eig(c) values[::-1].sort() vector_subset = vector[:,0:2] values_subset = np.dot(vector_subset.transpose(),values.transpose()).transpose() print("Vector Subset is ",vector_subset) print("Values Subset ",values_subset) plt.plot(values,vector[:,0]) plt.title('After PCA') plt.xlabel('PC1') plt.ylabel('PC2') plt.legend() plt.show() plt.plot(xdata,ydata) plt.title('Before PCA') plt.xlabel('PC1') plt.ylabel('PC2') plt.legend() plt.show()

AI Based Packman Game

 AI Based Packman Game This is completely scratch code for packman using very simple manner using python. We can also say that this is a Mini Project based on AI. Even I did not use the Numpy in this Code. actions=["Move Right","Move Left","Move Up","Move Down","Eat Food","Eat power pallet","Avoid Gost","Eat Ghost"] percepts=[['p','pp','f','pp'], ['f','g','f','pp'], ['pp','f','pp','g'], ['pp','f','g','f']] wlr1=[0,1] wlr2=[2,1] wlr3=[3,0] wll1=[0,2] wll2=[2,2] wll3=[3,1] wlr=[wlr1,wlr2,wlr3] wll=[wll1,wll2,wll3] m=len(percepts) n=len(percepts[0]) wlrm=len(wlr) wllm=len(wll) wlm=len(percepts[0]) class Agent(): def __init__(self): self.currentAction=0 self.r=0 self.c=0 self.power=False self.chwlr=False

K-Mean Clustering using Hamming Distance

 K-Mean Clustering using Hamming Distance I already uploaded the post for K-Mean Clustering but that was using Euclidean distance and now I made this algorithm using Hamming Distance. This is completely scratch code which I made using Numpy. This will be good if you understand the topic of k-mean clustering.  import numpy as np var=np.array([["small","green","Irregular","no"],["large","red","irregular","yes"],["large","red","circle","yes"], ["large","green","circle","no"],["large","green","irregular","no"],["small","red","circle","yes"], ["large","green","irregular","no"],["small","red","irrgular","no"],["small","green",&q

K-Mean Clustering

 K-Mean Clustering K-mean clustering is also one of the most popular algorithm of Machine Learning lies in unsupervised learning. It works by making clusters. You have to clear the concept about the k-mean clustering before understanding this code. Furthermore, this algorithm is in scratch format using simple Numpy and also we using matplotlib for plotting the data.  import numpy as np import matplotlib.pyplot as plt var=np.array([[1.0,1.0],[1.5,2.0],[3.0,4.0],[5.0,7.0],[3.5,5.0],[4.5,5.0],[3.5,4.5]]) if len(var)>1: centroid1=var[0] centroid2=var[1] x=y=0 plot1=np.array([centroid1]) plot2=np.array([centroid2]) x+=1 y+=1 for i in range(2,len(var)): ed1=np.sqrt(((centroid1[0]-var[i][0])**2)+((centroid1[1]-var[i][1])**2)) ed2=np.sqrt(((centroid2[0]-var[i][0])**2)+((centroid2[1]-var[i][1])**2)) if(ed1>ed2): centroid2[0]=(centroid2[0]+var[i][0])/2 centroid2[1]=(centroid2[1]+var[i][1])/2 plot

Constraint Satisfaction Problem

 Constraint Satisfaction Problem  This is one of the most popular Machine Learning based algorithm and code for this is given below in python using Numpy in scratch format. import numpy as np rooms={'A':'','B':'A','C':'B','D':'','E':'','F':'D'} person={'x':['P'],'y':['P'],'z':['P'],'a':['Q'],'b':['Q'],'s':['R']} contory=['P','Q','R'] hotelLiving={'A':[],'B':[],'C':[],'D':[],'E':[],'F':[]} count=0 for i in hotelLiving: for j in person: for z in rooms: if(rooms[z]==''): for a in hotelLiving: if hotelLiving[a]==[j]: count+=1 break if count==0: if hotelLiving[z]==[]:

HTML Feedback Form

 HTML Feedback Form Here is the code to create the feedback form using html simple tags. I know here are too much new tags but they are actually too useful and simple to use. You should only need to understand how to use and decide where to use. Here in simple words the only tag which is used is the input type and remaining part is actually the decision. You need to learn the input tag only and remaining tags we discussed before. So you should test this code by your self also try to understand that how they are working. To make the lists I already shared the code before in other coding Blog.  <html> <head> <title> Make it easy </title> <body> <font size =" 6 "> <b> <h> Feedback Form </b> </h> </font> <form> <b> Name </b> </br> <input type =" text " name =" name "> <br> <b> Email </b> <br> <input type =" text &q

HTML creating table

  HTML Creating Table Here is the totally new thing for the beginner. Actually Making a table in html is little bit tricky so here is the code. You cannot understand this unless you try this table by yourself. You should add your own way for making a table.  In the code below there are some tags which all are necessary for the construction of the table such as table for creating table, tr for rows, th for columns, colspan to remove the column or number of column where a column should span and border to create border. <html> <head> <Title> Creating Table </Title> </head> <body> <center> <h> <hr> <font size =" 5 "> Task 1 <hr> </font> </h> <table border =" 5 "> <tr> <th colspan =" 2 "> Table Title </th> </tr> <tr> <th> Column1 </th> <th> Column2 </th> </tr> <tr> <td> Date1 <

HTML bolt and heading tags

  So there are two new tags which are bolt and h1 tag. h1 tag is the tag to show the heading of the content and we uses B tag to make bolt to the text. These tags help to enhance the beauty of the page. <html> <head> <title> Main Heading... </title> </head> <body> <h1> Peragraph </h1> this is the peragraph to learn the html. <br> <B> So we will </B> make a peragraph. </body> </html>

HTML CV

  HTML CV So this is the CV which is made up of simple html tags and also there are some new tags here. Also I know this code is not too accurate but this is the simple enough code for a beginner to understand. Here the important tag is image source and syntax for the tag is given below with the green color text and its is uses to add the picture on the webpage. Also Here I use the center tag to place the content in center you can check the output by place the code in Notepad with .html format after this you can see by open this.   <html> <head> <title> CV(Curriculum vitae) </title> </head> <body> <center> <b> <i> <font size =" 8 "> <hr> <u> Aslam Ali CV </u> <hr> </font> </i> </b> </center> <img src =" Here add the picture location " style =" width:200px " ;"height:200px"; > <style="float:left&quo

HTML add Hyperlink

  HTML add Hyperlink So here I am going to add a new tag which is how to add the hyperlink. Here I want to share a tag which I did not tell you in previous html code so that tag is <br> which is uses to break the line and now we can start with our topic so the tag which I want to tell you is <a href="add link here"> Here you can add the name </a> So, by using this tag we can add the hyperlink to our page in very easy manner. Also here I used the tag to increase the font size which I were tell you in my previous post. <html> <head> <title> add hyperlink </title> </head> <body> i am going to add hyperlink <br> <b> In HTML </b> <font size =" 7 "> Hyperlink <br> </font> <a href =" https://www.google.com/?as_qdr=all "> google </a> </body> </html>

HTML Create List and Order type

  Create List and Order type Here we will learn how to create the list as you can see below here are some new tags which I added to create the list for anything but I made a list of fruits as you can see. So the tags to create the lists are li and to add the numbering I add the tag order list type(ol type) you can change the order type for example if you will write a inside this tag then you list numbering will be like a b c etc So In this way you can use these tags <html> <head> <title> LIST of Fruits </title> <body> <b> Creating list </b> <br> <p> This is the list of fruits </p> <ol type =" 1 "> <li> banana </li> <li> apple </li> <li> mango </li> </body> </html>

Code snippet for blogger or Wordpress

  Code snippet for blogger or WordPress  Here you can see the code snippet, used to write the code and the interference for this code snippet is like the same as below. So you can use this by simply turn the editor from text format to code format after turning this you will paste the same code as below and again now you can turn the code format to text format and now you can write the code inside it. <pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code style="color: black; overflow-wrap: normal; word-wrap: normal;"> <your code="" here=""> </your></code> </pre>

HTML Change font size

  Change font size Here I will change my font size below easily as you can see a new tag here below in the code which is to change the font size and the tag name is itself <font size="Desired size"> after opening the tag you should write the text which you want to increase the size after this you can close the tag now. You are able to change the size in html. <html> <head> <title> Change font size </title> </head> <body> i am going to increase the font size in <font size =" 8 "> HTML </font> <br> We had changed the font size </body> </html>

HTML Break line and change font style

  Break line and Change Font style Here I am changing my font style as you can see here below there are some new tags below one for breaking the line and other for changing the font style so to break the line there is <br> and to change the font style here is <i>.  <html> <head> <title> Change font style </title> </head> <body> i am going to change the font style <br> <b> In HTML </b> <br> <i> FONT STYLE </i> </body> </html>

HTML Basic Code

  HTML Basics First of all I will tell you the best compiler to use the html. Notepad is good but for any huge projects you need a compiler. So you can use bracket as a compiler for html which is available free online. You can download this from google easily by writing this. Bracket software free download. Here we will learn How to code by using html language. So in the code which is given below I add some tags which are necessary to make a html page. So the first tag is html which defines the language by using this tag our browser can find the format for our language after this there is a head tag which is also an important part for html here we define the heading or any CSS or Classes etc. But below I define the title of the page which is Abdul Wahab Raza. After closing the head tag I am defining the body part which don't need any definition.  By practice this code you can understand better.  <HTML> <Head> <Title> Abdul Wahab Raza </Title

Advanced Airline Management system using data structures and OOP in c++

Image
  Information about Management system: Introduction: This project is about the airline management system and now I will make a simple introduction to this project which is that what is an airline management system to talk about this firstly I will tell that what is management system so management system is something like a program which manage the record of the company or organization. It helps to calculate, manage, or make record the data by different operations. So, I will make a management system of airline tickets that if a customer reserve a ticket than the data of this customer will store inside the program and in this way, we can make a record and this record can help us to check that which customer reserve the ticket from our organization or company and this can save a lot of the time of us. And the main point is the whole project is based on the binary search tree (BST) because is algorithm faster than most of the algorithms. And how this algorithm works and the answer