Posts

K Means_Clustering

  #!/usr/bin/env python # coding: utf-8 # In[3]: import pandas as pd import numpy as np import matplotlib.pyplot as plt df = pd.read_csv( r "C: \U sers \91 887 \O neDrive\Desktop \M achine_Learning\week4_Mall_Customers.csv" ) x = df.iloc[:, [ 3 , 4 ]].values # In[4]: from sklearn.cluster import KMeans wcss_list = [] for i in range ( 1 , 11 ):     kmeans = KMeans( n_clusters = i, init = 'k-means++' , random_state = 42 )     kmeans.fit(x)     wcss_list.append(kmeans.inertia_) plt.plot( range ( 1 , 11 ), wcss_list) plt.title( 'The Elobw Method Graph' ) plt.xlabel( 'Number of clusters(k)' ) plt.ylabel( 'wcss_list' ) plt.show() # In[ ]:

AgglomarativeCliutering

  #!/usr/bin/env python # coding: utf-8 # In[11]: import pandas as pd import numpy as np import matplotlib.pyplot as plt df = pd.read_csv( r "C: \U sers \91 887 \O neDrive\Desktop \M achine_Learning\week4_Mall_Customers.csv" ) x = df.iloc[:,[ 3 , 4 ]].values # In[12]: from sklearn.cluster import AgglomerativeClustering hc = AgglomerativeClustering( n_clusters = 5 , affinity = 'euclidean' , linkage = 'ward' ) y_pred = hc.fit_predict(x) # In[13]: plt.scatter(x[y_pred == 0 , 0 ], x[y_pred == 0 , 1 ], s = 100 , c = 'blue' , label = 'Cluster 1' ) plt.scatter(x[y_pred == 1 , 0 ], x[y_pred == 1 , 1 ], s = 100 , c = 'green' , label = 'Cluster 2' ) plt.scatter(x[y_pred == 2 , 0 ], x[y_pred == 2 , 1 ], s = 100 , c = 'red' , label = 'Cluster 3' ) plt.scatter(x[y_pred == 3 , 0 ], x[y_pred == 3 , 1 ], s = 100 , c = 'cyan' , label = 'Cluster 4' ) plt.scatter(x[y_pred ==...

1.Import and Export(How to read csv file using manualvfunction)

#!/usr/bin/env python # coding: utf-8 # In[5]: # Week1: Write a python program to import and export data from/to CSV file ######################################################################### ## (1) How to Read CSV File using Manual Function import pandas as pd def load_csv ( filepath ):     data = []     col = []     checkcol = False     with open (filepath) as f:         for val in f.readlines():             val = val.strip()             val = val.split( ',' )             if checkcol is False :                 col = val                 checkcol = True             else :                 data.append(val)     df = pd.DataFrame( data = data, columns = col)   ...

Multinomial_Regression

  #!/usr/bin/env python # coding: utf-8 # In[39]: #import the necessary libraries from sklearn import datasets from sklearn.linear_model import LogisticRegression from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.metrics import accuracy_score # In[40]: #load the digit datasets digits = datasets.load_digits() # In[41]: #defining feature matrix x and response vecoor y X = digits.data y = digits.target print (X) print (y) # In[48]: #split the test train data X_train,X_test,y_train,y_test = train_test_split(X,y, test_size = 0.2 , random_state = 1 ) print (y_test) # In[49]: #standradize features using standardscaler scaler = StandardScaler() scaler.fit(X_train) X_train_scaled = scaler.transform(X_train) X_test_scaled = scaler.transform(X_test) # In[50]: #create the logistic regression model model = LogisticRegression() # In[51]: #train the model on scaled training data model.fit(X_train_scaled,y_train) # In[52]: ...

Binomial_Regression

  #!/usr/bin/env python # coding: utf-8 # In[16]: #import the necessary libraries from sklearn.datasets import load_breast_cancer from sklearn.linear_model import LogisticRegression from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.metrics import accuracy_score # In[2]: #load breast cancer dataset X,y = load_breast_cancer( return_X_y = True ) # In[3]: #split the test train data X_train,X_test,y_train,y_test = train_test_split(X,y, test_size = 0.20 , random_state = 42 ) print (y_test) # In[5]: #standardize features using standardscaler scaler = StandardScaler() scaler.fit(X_train) X_train_scaled = scaler.transform(X_train) X_test_scaled = scaler.transform(X_test) # In[6]: #create the logistic regression model model = LogisticRegression() # In[7]: #train the model on scaled training data model.fit(X_train_scaled,y_train) # In[18]: #make predidction on the sclaed testing data y_pred = model.predict(X_test_scale...

Multiple_Linear_Regression

  #!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np import matplotlib.pyplot as plt import pandas as pd # In[2]: myfile = "D:\Sunny115\week2_50_Startups.csv" dataset = pd.read_csv(myfile) X = dataset.iloc[:,: - 1 ].values y = dataset.iloc[:, - 1 ].values # In[6]: #encoding categorical data from sklearn.compose import ColumnTransformer from sklearn.preprocessing import OneHotEncoder ct = ColumnTransformer( transformers = [( 'encoder' ,OneHotEncoder(),[ 3 ])], remainder = 'passthrough' ) X = np.array(ct.fit_transform(X)) # In[8]: print (X) # In[13]: #splitting the dataset from sklearn.model_selection import train_test_split X_train,X_test,y_train,y_test = train_test_split(X,y, test_size = 0.2 , random_state = 0 ) # In[14]: from sklearn.linear_model import LinearRegression regressor = LinearRegression() regressor.fit(X_train,y_train) # In[15]: y_pred = regressor.predict(X_test) print (y_test) print (y_pred) # In[16]: from sklearn.me...

Simple_Linear_Regression

  #!/usr/bin/env python # coding: utf-8 # In[3]: #importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # In[4]: myfile = "D:\Sunny115\week2_Salary_Data.csv" dataset = pd.read_csv(myfile) X = dataset.iloc[:,: - 1 ].values y = dataset.iloc[:, - 1 ].values # In[5]: from sklearn.model_selection import train_test_split X_train,X_test,y_train,y_test = train_test_split(X,y, test_size = 1 / 3 , random_state = 0 ) # In[6]: from sklearn.linear_model import LinearRegression regressor = LinearRegression() regressor.fit(X_train,y_train) # In[7]: print (X_train) # In[9]: y_pred = regressor.predict(X_test) print (y_test) print (y_pred) # In[10]: from sklearn.metrics import r2_score r2_score(y_test,y_pred) # In[13]: #Visulising the training set results plt.scatter(X_train,y_train, color = 'blue' ) plt.plot(X_train,regressor.predict(X_train), color = 'green' ) plt.title( 'Salary vs Expereince (training set)' ) plt.x...

Last_Question_graph(5)

  #!/usr/bin/env python # coding: utf-8 # In[13]: import numpy as np import matplotlib.pyplot as plt data = { 'KNN' : 0.95 , 'Naivebayes' : 0.9125 , 'DecisionTree' : 0.92 , 'Randomforest' : 0.9125 , 'SVM' : 0.9125 } courses = list (data.keys()) values = list (data.values()) fig = plt.figure( figsize = ( 10 , 5 )) plt.bar(courses, values, color = 'red' , width = 0.2 ) plt.xlabel( "Different classifier" ) plt.ylabel( "Accuracy_score" ) plt.title( "classifdier and their accuracy score" ) plt.show() # In[ ]:

Random_ForestClassifier

  #!/usr/bin/env python # coding: utf-8 # In[113]: import numpy as np import matplotlib.pyplot as plt import pandas as pd # In[114]: #mydatafile="Desktop\Machine_Learning\week3_Social_Network_Ads.csv" mydatafile = r "C: \U sers \91 887 \O neDrive\Desktop \M achine_Learning\week3_Social_Network_Ads.csv" dataset = pd.read_csv(mydatafile) X = dataset.iloc[:, : - 1 ].values y = dataset.iloc[:, - 1 ].values # In[115]: from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.20 , random_state = 0 ) # In[116]: from sklearn.preprocessing import StandardScaler sc = StandardScaler() X_train = sc.fit_transform(X_train) X_test = sc.transform(X_test) # In[117]: print (X_test) # In[118]: print (X_train) # In[119]: from sklearn.ensemble import RandomForestClassifier   classifier = RandomForestClassifier( n_estimators = 10 , criterion = "entropy" )   classifier.fit(X_train, y_tra...

Gaussian_NB

  #!/usr/bin/env python # coding: utf-8 # In[56]: import numpy as np import matplotlib.pyplot as plt import pandas as pd # In[57]: #mydatafile="Desktop\Machine_Learning\week3_Social_Network_Ads.csv" mydatafile = r "C: \U sers \91 887 \O neDrive\Desktop \M achine_Learning\week3_Social_Network_Ads.csv" dataset = pd.read_csv(mydatafile) X = dataset.iloc[:, : - 1 ].values y = dataset.iloc[:, - 1 ].values # In[58]: from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.20 , random_state = 0 ) # In[59]: from sklearn.preprocessing import StandardScaler sc = StandardScaler() X_train = sc.fit_transform(X_train) X_test = sc.transform(X_test) # In[60]: print (X_test) # In[61]: print (X_train) # In[62]: from sklearn.naive_bayes import GaussianNB classifier = GaussianNB() classifier.fit(X_train, y_train) # In[63]: print (classifier.predict(sc.transform([[ 30 , 87000 ]]))) # In[64]: y_p...

Decision_Tree_Classifier

  #!/usr/bin/env python # coding: utf-8 # In[47]: import numpy as np import matplotlib.pyplot as plt import pandas as pd # In[48]: #mydatafile="Desktop\Machine_Learning\week3_Social_Network_Ads.csv" mydatafile = r "C: \U sers \91 887 \O neDrive\Desktop \M achine_Learning\week3_Social_Network_Ads.csv" dataset = pd.read_csv(mydatafile) X = dataset.iloc[:, : - 1 ].values y = dataset.iloc[:, - 1 ].values # In[49]: from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.20 , random_state = 0 ) # In[50]: from sklearn.preprocessing import StandardScaler sc = StandardScaler() X_train = sc.fit_transform(X_train) X_test = sc.transform(X_test) # In[51]: print (X_test) # In[52]: print (X_train) # In[53]: from sklearn.tree import DecisionTreeClassifier classifier = DecisionTreeClassifier( criterion = 'entropy' , random_state = 0 ) classifier.fit(X_train, y_train) # In[54]: p...

SVC_Support _vector_Machine

  #!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np import matplotlib.pyplot as plt import pandas as pd # In[2]: #mydatafile="Desktop\Machine_Learning\week3_Social_Network_Ads.csv" mydatafile = r "C: \U sers \91 887 \O neDrive\Desktop \M achine_Learning\week3_Social_Network_Ads.csv" dataset = pd.read_csv(mydatafile) X = dataset.iloc[:, : - 1 ].values y = dataset.iloc[:, - 1 ].values # In[3]: from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.20 , random_state = 0 ) # In[4]: from sklearn.preprocessing import StandardScaler sc = StandardScaler() X_train = sc.fit_transform(X_train) X_test = sc.transform(X_test) # In[6]: print (X_test) # In[7]: print (X_train) # In[15]: from sklearn.svm import SVC classifier = SVC( kernel = 'linear' , random_state = 0 ) classifier.fit(X_train, y_train) # In[16]: #print(classifier.predict(sc.transform([[30,87000]...

K-NeighbourClassifier

  #!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np import matplotlib.pyplot as plt import pandas as pd # In[2]: #mydatafile="Desktop\Machine_Learning\week3_Social_Network_Ads.csv" mydatafile = r "C: \U sers \91 887 \O neDrive\Desktop \M achine_Learning\week3_Social_Network_Ads.csv" dataset = pd.read_csv(mydatafile) X = dataset.iloc[:, : - 1 ].values y = dataset.iloc[:, - 1 ].values # In[3]: from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.20 , random_state = 0 ) # In[4]: from sklearn.preprocessing import StandardScaler sc = StandardScaler() X_train = sc.fit_transform(X_train) X_test = sc.transform(X_test) # In[6]: print (X_test) # In[7]: print (X_train) # In[8]: from sklearn.neighbors import KNeighborsClassifier classifier = KNeighborsClassifier( n_neighbors = 5 , metric = 'minkowski' , p = 2 ) classifier.fit(X_train, y_train) # In[13]:...

Logistic Regresion Using external Dataset

  #!/usr/bin/env python # coding: utf-8 # In[ ]: import numpy as np import matplotlib.pyplot as plt import pandas as pd # In[ ]: #mydatafile="Desktop\Machine_Learning\week3_Social_Network_Ads.csv" mydatafile = r "C: \U sers \91 887 \O neDrive\Desktop \M achine_Learning\week3_Social_Network_Ads.csv" dataset = pd.read_csv(mydatafile) X = dataset.iloc[:, : - 1 ].values y = dataset.iloc[:, - 1 ].values # In[ ]: from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25 , random_state = 0 ) # In[ ]: print (X_train) # In[ ]: from sklearn.preprocessing import StandardScaler sc = StandardScaler() X_train = sc.fit_transform(X_train) X_test = sc.transform(X_test) # In[ ]: print (X_test) # In[ ]: print (X_train) # In[ ]: print (y_test) # In[ ]: print (y_train) # In[ ]: from sklearn.linear_model import LogisticRegression classifier = LogisticRegression( random_state = 0 ) classifier....

Quick Selection tool, and different type of tools

 Quick Selection tool The Quick Selection tool simply paints an area of an image and the tool automatically finds the edges. You can add or subtract areas of the selection until you get the exact area you want. The image of the sand dollar in the 03Working.psd file has clearly defined edges, making it an ideal candidate for the Quick Selection tool. 1. Select the Zoom tool in the Tools panel, and zoom in so that you can see the sand dollar well. 2. Select the Quick Selection tool ( ) in the Tools panel. 3. Select Auto-Enhance in the options bar. When Auto-Enhance are selected, the Quick Selection tool creates better quality selections, with edges that are truer to the object. 4. Click on an off-white area near the outside edge of the sand dollar. Moving a selected area 1. If the sand dollar is not still selected, repeat the previous exercise to select it. 2. Zoom out so you can see both the shadowbox and the sand dollar. 3. Select the Move tool ( ) Notice that the sand dollar remai...

PHOTO ( CHINESE LADKA)

 Lab 7 Adding point type Horizontal or vertical type can be created anywhere in an image. One can enter point type (a single letter, word, or line) or paragraph type. 1. In the Layers panel, select the Background layer. 2. Select the Horizontal Type tool (T), and, in the options bar, do the following: • Choose a serif typeface, such as Minion Pro Regular, from the Font Family popup menu. • Type 144 pt for the Size, and press Enter or Return. • Click the Center Text button. 3. In the Character panel, change the Tracking value to 100. 4. Click on the center guide you added to set an insertion point, and type DIGITAL in all capital letters. Then click the Commit Any Current Edits button ( ) in the options bar. 5. Select the Horizontal Type tool (T), and select the “DIGITAL” text. 6. Open the Font Family pop-up menu in the options bar. Move the cursor over the fonts, either with the mouse or using arrow keys. When the cursor is over a font name, Photoshop applies that font to the selec...

Shape Tweening

 Shape Tweening Create a new movie and draw a red circle in frame 1 using the Oval tool. 1. Click on frame 15 and create a new keyframe by pressing F6. 2. In keyframe 15, draw a large filled square on top of the circle. 3. In the timeline click anywhere between 1 to 15, and select Insert > Create Shape Tween. See Note (4). 4. Test the movie to see the circle tween to the square. 5. To tween the square smoothly back to the circle, click on frame 1, and copy to clipboard by choosing Edit > Copy. 6. Click on frame 30 and press F6 to insert a keyframe. 7. Press DEL to delete the square. 8. Choose Edit > Paste in Place, to put the copied circle in exactly the same place in frame 30 as it was in frame 1. 9. Apply a shape tween between 15 and 30. 10. Test the movie. Save as Ex2.FLA and Ex2.SWF. Note : (4) Shape tweens are reflected in the Timeline by a solid arrow over olive colored frames

Image of a flower and we have to edit and write Happy birthday Etc

Lab No 1 Image of a flower and we have to edit and write Happy birthday Etc  Adjust Image Brightness and Contrast values. 1. In the Layers panel, make sure the working layer is selected. 2. In the Adjustments panel, click the Brightness/Contrast icon to add a Brightness/Contrast adjustment layer. Properties panel is opened that display the Brightness/Contrast settings. 3. In the Properties panel, move the Brightness slider to 98 and the Contrast slider to 18. 4. For adjusting brightness/contrast in the layer panel, use a new layer, so that you can return to the original one. Layering is one of the fundamental and most powerful features in Photoshop. Photoshop includes many kinds of layers some of which contain images, text or solid colors and others. 5. Click the double arrows at the top of the Properties panel to close it. 6. Choose File > Save As, type filename with extension .psd, and click OK or Save. 7. Click OK in the Photoshop Format Options dialog box. Saving the fil...