├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── PULL_REQUEST_TEMPLATE.md ├── CONTRIBUTIONS.md ├── ChatBot ├── ChatBot_using_Bard.py └── Instructions_to_use_it.md ├── Clustering ├── elbow_method.py ├── kmeans.py └── single-linkage.py ├── CodeOfConduct.md ├── Dimension Reduction └── pca.py ├── Discriminant Analysis ├── LDA └── LDA.py ├── License.md ├── Numpy Basics └── Numpy.py ├── PythonCodes ├── Clock.py ├── JsonToCSV.py ├── OTPverification.py ├── PasswordStrengthChecker.py ├── TicTacToe.py ├── TicTacToe2.py ├── basic.py └── stopwatchGUI.py ├── README.md ├── Security.md ├── Visualization Codes ├── 001_getting_started.py ├── Axis.py ├── Bar.py ├── Data.py ├── Data2.py ├── Data3.py ├── Figure.py ├── Graph.py ├── Histogram.py ├── Normal.py ├── PCA1.py ├── Perceptron_Trick.py ├── PieChart.py ├── Plot.py ├── Scatter2.py ├── Subplot.py ├── VISUALIZATION.md ├── Visualization.py ├── Visualization2.py ├── Voltage-vs-Current-Graph.py ├── Ylabel.py ├── distribution.py ├── enhance.jpg ├── enhance_histogram.py ├── scatter.py └── scatterplot.py ├── datasets └── dataset.csv ├── output_plots ├── Axis.jpg ├── Bar.jpg ├── Figure_1.png ├── Figure_2.png ├── Figure_3.png ├── Graph.jpg ├── Histogram equalisation.png ├── Histogram.jpg ├── Normal.jpg ├── PCA1.jpg ├── PieChart.jpg ├── Plot.jpg ├── Scatter.jpg ├── Scatter2.jpg ├── Subplot.jpg ├── Visualization.jpg ├── Visualization2.jpg ├── Volatge-vs-Current.png ├── Ylabel.jpg └── result.jpg ├── pca.py ├── regression ├── multipleregression.py └── regression.py └── tkinter ├── adding_buttons.py ├── first_gui_program.py └── gui tic tac toe.py /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐛 Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | 7 | --- 8 | 9 | # 🐛Describe the bug 10 | 11 | 12 | 13 | # 📌 Expected behavior 14 | 15 | 16 | # 📷 Screenshots 17 | 18 | 19 | 20 | **Additional context(if any)** 21 | 22 | # 🏆Are you contributing under any open-source program ? 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: ✨ Feature request 3 | about: Add features to the website 4 | title: Feature_Request 5 | labels: enhancement, feature request 6 | 7 | --- 8 | 9 | # ✨ Describe the feature you are requesting 10 | 11 | 12 | 13 | # 📷 Screenshots 14 | 15 | 16 | 17 | **Additional context(if any)** 18 | 19 | # 🏆Are you contributing under any open-source program ? 20 | 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # PULL REQUEST 2 | 3 | Title : 4 | 5 | Closes # 6 | 7 | 8 | 9 | # 📌 Description 10 | 11 | 12 | 13 | # 📷 Screenshots 14 | 15 | 16 | 17 | **Additional context(if any)** 18 | 19 | # 🏆Are you contributing under any open-source program ? 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /CONTRIBUTIONS.md: -------------------------------------------------------------------------------- 1 |

Data Visualization in Python

2 | 3 | 4 | ## About the Repository 5 | 6 | Welcome to Data Visualization in Python! This repository aims to provide a comprehensive collection of Python libraries and techniques, useful for mechine learning enthusiasts and budding data scientists. 7 | 8 | 9 | ## Key Features 10 | 11 | - Diverse Collection of Plotting/Optimisation Problems
12 | - Examples of multiple frequently used functions and techniques
13 | - Detailed Comments for Code Explanation
14 | - Active Participation in Hacktoberfest 2023
15 | 16 | 17 | 18 | ## Contribution Guidelines 19 | 20 | We're excited to have you join us in this journey of learning and contributing to open source. Follow these steps to get started: 21 | 22 | 1. **Fork this repository**: Click the "Fork" button at the top-right of this page to create your copy of the repository. 23 | 2. **Clone the repository**: Clone the repository to your local machine using the following command: 24 | ```sh 25 | git clone https://github.com/YourUsername/Data-Visualization-in-Python.git 26 | ``` 27 | 3. **Choose a topic**: Browse through the available topics in the repository. Each topic is in its respective directory. 28 | 4. **Create a branch**: Create a new branch for your contribution. For example, if you're working on the creating a scatterplot, create a branch like this: 29 | ```sh 30 | git checkout -b scatterplt-contribution 31 | ``` 32 | 5. **Make your changes**: Solve a problem, add a new one, improve documentation, or help with code reviews. You can find problems and tasks in the respective topic directory. 33 | 6. **Commit your changes**: After making your changes, commit them with a clear and concise message: 34 | ```sh 35 | git commit -m "Added the code to create desired scatterplot" 36 | ``` 37 | 7. **Push to your fork**: Push your changes to your forked repository: 38 | ```sh 39 | git push origin scatterplt-contribution 40 | ``` 41 | 8. **Create a Pull Request (PR)**: Go back to the main repository on GitHub and create a new Pull Request from your branch. Provide a clear description of your contribution. 42 | 9. **Get your PR reviewed**: Wait for the maintainers to review your PR. You may need to make additional changes based on their feedback. 43 | 10. **Be Responsible**: Please adhere to our code of conduct and respect the guidelines outlined in our contributing guidelines. 44 | 45 | 46 | 47 | ## Contributing Rules 48 | 49 | 1. Contribute standard codes. 50 | 2. Use proper file extensions for your file. 51 | 3. Only one file per PR is allowed on this repository , web folder has an exclusion on this but you should mention the files in the issue you are creating. 52 | 4. **Plagiarism is depreciated**. 53 | 54 | 55 | 56 | 57 | 58 | ### **Happy Contributing! ❤️** -------------------------------------------------------------------------------- /ChatBot/ChatBot_using_Bard.py: -------------------------------------------------------------------------------- 1 | from bardapi import Bard 2 | import os 3 | import time 4 | 5 | os.environ['_BARD_API_KEY']="Insert-Key-Here" 6 | 7 | input_text = "Tell me about Hacktoberfest 2023" 8 | print(Bard().get_answer(input_text)['content']) -------------------------------------------------------------------------------- /ChatBot/Instructions_to_use_it.md: -------------------------------------------------------------------------------- 1 | Packages needed to be installed: 2 | 1. bardapi 3 | 2. bard 4 | 5 | How to install the above packages: 6 | Simply type " pip install "package name" " in commnad prompt or powershell window 7 | 8 | Step to get the Bard Api token: 9 | 1. Go to https://bard.google.com/ 10 | 2. Then right click anywhere on the chat window 11 | 3. Click on Inspect 12 | 4. After Inspect window opens, click on Application tab 13 | 5. Search for __Secure-1PSID under Storage --> Cookies --> https://bard.google.com 14 | 6. From there you will get the API key. 15 | -------------------------------------------------------------------------------- /Clustering/elbow_method.py: -------------------------------------------------------------------------------- 1 | # K-means clustering 2 | # It is a clustering method that subdivides a single cluster or a collection of data points into k differnet clusters or groups 3 | # It is an unsupervised learing algorithm that groups the unlabelled dataset into different clusters. Here, k defines the number of pre defined clusters that needs to b e created in the process 4 | # for eg,: if k = 2, there will be 2 clusters, if k = 3, there will be 3 clusters and so on. 5 | # It is an iterative algorithm that divides the unlabelled dataset into k different clusters in such a way that each data set belongs to only one group that has similar properties. 6 | 7 | #Elbow Method : Choosing the right number of clusters is an important part of this algorithm, an ideal way to figure out the right no of clusters is to calculate is the Within Cluster Sum of Squares (WCSS). 8 | # a commonly used method for finding the optimal value of K is elbow method. 9 | # in this method, we are actually varying the number pof clusters (k), generally from 1 to 10. For each value of K we are calculating WCSS. 10 | # WCSS is the sum of sqaured distance between each point & the centroid in a cluster. 11 | # When w eplot the WCSS value with the K value, the plot looks like an elbow. As the number of clusters increases, the WCSS value wil start to decrease. 12 | 13 | from pandas import DataFrame 14 | import matplotlib.pyplot as plt 15 | from sklearn.cluster import KMeans 16 | import numpy as np 17 | Data = { 'x' : [185,170,168,179,182,188,180,180,183,180,180,177], 18 | 'y' : [72,56,60,68,72,77,71,70,84,88,67,76] 19 | } 20 | Data 21 | df = DataFrame(Data,columns=['x','y']) 22 | 23 | print("Shape of data frame",df.shape) 24 | 25 | wcss = [] #initialize empty list to store the WCSS Value. 26 | 27 | for i in range(1,13): #Each iteration corresponds to a differemnt number of clusters (k) 28 | km = KMeans(n_clusters=i) 29 | km.fit_predict(df) #fits model into data(df) 30 | wcss.append(km.inertia_) 31 | plt.plot(wcss) 32 | plt.xlabel('Number of cluster') 33 | plt.ylabel('WCSS') 34 | plt.title("Elbow point graph for optimal value of k") 35 | plt.show() 36 | 37 | 38 | my_centroids = np.array([[185,75],[170,56],[168,60]]) 39 | kmeans = KMeans(n_clusters = 3, init= my_centroids).fit(df) 40 | 41 | centroids = kmeans.cluster_centers_ 42 | print(centroids) 43 | 44 | X = df.iloc[:,:].values 45 | 46 | y_means = kmeans.fit_predict(X) 47 | y_means 48 | #scatter plot for data poinrs in cluster 1 49 | plt.scatter(X[y_means == 0,0], X[y_means==0,1],s=60,c='blue',label='Cluster 1') 50 | plt.scatter(X[y_means == 1,0], X[y_means==1,1],s=60,c='chocolate',label='Cluster 2') 51 | plt.scatter(X[y_means == 2,0], X[y_means==2,1],s=60,c='pink',label='Cluster 3') 52 | 53 | plt.scatter(centroids [:,0],centroids [:,1], c = 'black',s=100,marker='+',label ='centroids ') 54 | plt.legend(loc = 'lower right') 55 | plt.show() 56 | -------------------------------------------------------------------------------- /Clustering/kmeans.py: -------------------------------------------------------------------------------- 1 | # K-means clustering 2 | # It is a clustering method that subdivides a single cluster or a collection of data points into k differnet clusters or groups 3 | # It is an unsupervised learing algorithm that groups the unlabelled dataset into different clusters. Here, k defines the number of pre defined clusters that needs to b e created in the process 4 | # for eg,: if k = 2, there will be 2 clusters, if k = 3, there will be 3 clusters and so on. 5 | # It is an iterative algorithm that divides the unlabelled dataset into k different clusters in such a way that each data set belongs to only one group that has similar properties. 6 | 7 | from pandas import DataFrame 8 | import matplotlib.pyplot as plt 9 | from sklearn.cluster import KMeans 10 | import numpy as np 11 | 12 | Data = { 'x' : [185,170,168,179,182,188,180,180,183,180,180,177], 13 | 'y' : [72,56,60,68,72,77,71,70,84,88,67,76] 14 | } 15 | 16 | df = DataFrame(Data,columns=['x','y']) 17 | wcss = [] #initialize empty list to store the WCSS Value. 18 | 19 | for i in range(1,13): #Each iteration corresponds to a differemnt number of clusters (k) 20 | km = KMeans(n_clusters=i) 21 | km.fit_predict(df) #fits model into data(df) 22 | wcss.append(km.inertia_) 23 | plt.plot(wcss) 24 | plt.xlabel('Number of cluster') 25 | plt.ylabel('WCSS') 26 | 27 | my_centroids = np.array([[185,75],[170,56],[168,60]]) 28 | kmeans = KMeans(n_clusters = 3, init= my_centroids).fit(df) 29 | centroids = kmeans.cluster_centers_ 30 | print(centroids) 31 | 32 | X = df.iloc[:,:].values 33 | y_means = kmeans.fit_predict(X) 34 | 35 | plt.scatter(X[y_means == 0,0], X[y_means==0,1],s=60,c='blue',label='Cluster 1') 36 | plt.scatter(X[y_means == 1,0], X[y_means==1,1],s=60,c='chocolate',label='Cluster 2') 37 | plt.scatter(X[y_means == 2,0], X[y_means==2,1],s=60,c='pink',label='Cluster 3') 38 | 39 | plt.scatter(centroids [:,0],centroids [:,1], c = 'black',s=100,marker='+',label ='centroids ') 40 | plt.legend(loc = 'lower right') 41 | plt.show() 42 | -------------------------------------------------------------------------------- /Clustering/single-linkage.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from scipy.cluster.hierarchy import linkage, dendrogram 4 | 5 | # Sample data (2D points) 6 | data = np.array([ 7 | [1.0, 2.0], 8 | [1.5, 1.8], 9 | [5.0, 8.0], 10 | [8.0, 8.0], 11 | [1.0, 0.6], 12 | [9.0, 11.0], 13 | [8.0, 2.0], 14 | [10.0, 2.0], 15 | [9.0, 3.0] 16 | ]) 17 | 18 | # Perform single linkage clustering 19 | linked = linkage(data, method='single') 20 | 21 | # Plot dendrogram 22 | plt.figure(figsize=(10, 7)) 23 | dendrogram(linked, labels=range(1, len(data) + 1), leaf_rotation=90, leaf_font_size=10) 24 | plt.title('Single Linkage Hierarchical Clustering') 25 | plt.xlabel('Data Points') 26 | plt.ylabel('Distance') 27 | plt.show() 28 | -------------------------------------------------------------------------------- /CodeOfConduct.md: -------------------------------------------------------------------------------- 1 | # Code Of Conduct 2 | 3 | Thank You for showing interest in this repo. 4 | 5 | If you wish to contribute to this repo, 6 | please read the code of conduct as given below, 7 | so as to ensure efficient collaboration. 8 | 9 | ## Be respectful to others 10 | 11 | * Contributors must be respectful to others. 12 | * Avoid personal attacks, insults 13 | * DO NOT discriminate on the basis of caste, race, gender,religion or sexual orientation. 14 | 15 | ## Respect Maintainer's decision 16 | 17 | * If your PR does not follow the repo's guidelines or is outdated, 18 | the project maintainer has the right to decline the merge request. 19 | In such a case, contributors must not argue with the maintainer 20 | 21 | * You may politely request the Maintainer if he/she would like some changes made to the commits. 22 | * The decision of the project maintainer is final and binding 23 | 24 | ## Documentation 25 | 26 | * Name variables meaningfully 27 | * Write the docstring for each function 28 | * Use meaningful commit messages 29 | * When submitting a PR, mention what your code does and what changes you have made 30 | * Do not include API keys in your PR, make sure to clearly state it as comments 31 | 32 | ## Testing 33 | 34 | * Before submitting a PR, make sure to test it 35 | * If your code has dependencies, make sure to include them clearly in appropriate places. 36 | 37 | ### Any kind of Harassment or bullying will not be tolerated. Legal action may also be taken against you. 38 | 39 | ## Please adhere to the Code Of Conduct to ensure effective collaboration 40 | # Thanks -------------------------------------------------------------------------------- /Dimension Reduction/pca.py: -------------------------------------------------------------------------------- 1 | #PCA - PRINCIPAL COMPONENT ANALYSIS is dimestionality reduction method that is often used to reduce the dimensionality of large data sets by trnasforming 2 | # a large set of variables into a smaller one that still contains most of the information in the large set 3 | #in this technique the variablrs are trnasformed into a new set of variables, which are linear comnbination of original variables. This new set of variables are know as principal components. 4 | # The first principl component captures the most variation in data, but the second pricpal component captures the maximum variance, that is orthogonal to the first principal componenet and so on. 5 | 6 | import numpy as np 7 | import pandas as pd 8 | import matplotlib.pyplot as plt 9 | from sklearn.decomposition import PCA 10 | from sklearn.preprocessing import StandardScaler 11 | 12 | df = pd.read_csv('iris.csv') 13 | df.Species.replace({'Iris-setosa':0,'Iris-versicolor':1,'Iris-virginica':2},inplace= True) 14 | df.head() 15 | 16 | features = ['SepalLengthCm','SepalWidthCm','PetalLengthCm','PetalWidthCm'] 17 | x = df.loc[:, features].values 18 | y = df.loc[:,['Species']].values 19 | 20 | x = StandardScaler().fit_transform(x) 21 | pd.DataFrame(data=x,columns=features).head() 22 | 23 | pca = PCA() 24 | X_new = pca.fit_transform(x) 25 | explained_variance = pca.explained_variance_ratio_ #VARIANCE 26 | 27 | pca = PCA(n_components=2) 28 | principalComponent = pca.fit_transform(x) 29 | principalDF = pd.DataFrame(data= principalComponent, columns=['PC1','PC2']) 30 | -------------------------------------------------------------------------------- /Discriminant Analysis: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /LDA/LDA.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pandas as pd 3 | from sklearn.metrics import confusion_matrix 4 | from sklearn.metrics import accuracy_score 5 | df = pd.read_csv("iris.csv") 6 | X = df.iloc[:,0:4].values 7 | y = df.iloc[:,4].values 8 | from sklearn.model_selection import train_test_split 9 | X_train, X_test, y_train, y_test = train_test_split(X,y,test_size = 0.2, random_state = 0) 10 | from sklearn.preprocessing import StandardScaler 11 | scaler = StandardScaler() 12 | X_train = scaler.fit_transform(X_train) 13 | X_test = scaler.transform(X_test) 14 | from sklearn.discriminant_analysis import LinearDiscriminantAnalysis 15 | lda = LinearDiscriminantAnalysis(n_components = 1) 16 | X_train_lda = lda.fit_transform(X_train, y_train) 17 | X_test_lda = lda.transform(X_test) 18 | from sklearn.ensemble import RandomForestClassifier 19 | classifier = RandomForestClassifier(max_depth = 2, random_state = 0) 20 | classifier.fit(X_train_lda,y_train) 21 | y_pred = classifier.predict(X_test_lda) 22 | conf_matrix = confusion_matrix(y_test,y_pred) 23 | accuracy = accuracy_score(y_test,y_pred) 24 | print("Confusion_matrix:\n",conf_matrix) 25 | print("Accuracy:",accuracy) 26 | -------------------------------------------------------------------------------- /License.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Debaditya Som 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Numpy Basics/Numpy.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | #np works as an alias for numpy 3 | 4 | myarr = np.array([[3,4,5,6]] , np.int8) 5 | #here datatype in the np.array is integer 6 | print(myarr) 7 | myarr[0,1] 8 | myarr.shape 9 | 10 | #matrix multiplication 11 | 12 | #method 1 13 | res1 = a@b 14 | print("res1\n",res1) 15 | print() 16 | 17 | #method 2 18 | res2 = a.dot(b) 19 | print("res2\n", res2) 20 | print() 21 | 22 | #method 3 23 | res3 = np.dot(a,b) 24 | print("res3\n", res3) 25 | print() 26 | -------------------------------------------------------------------------------- /PythonCodes/Clock.py: -------------------------------------------------------------------------------- 1 | from tkinter import * # import everything from tkinter module 2 | from time import strftime # import strftime from time module for getting the time 3 | # importing done, now the main work: 4 | 5 | root = Tk() # create a GUI with tkinter 6 | root.title('Clock_Python') # title of the window 7 | lbl = Label(root, font = ('callibri', 45, 'bold'), #specify the font, font size, and others like bold,italics,underlined,etc.. 8 | background = 'black', # background color 9 | foreground = 'white') # foreground color 10 | def time(): # call this function to display the time 11 | string = strftime('%H:%M:%S %p') # specify the format of the time 12 | lbl.config(text = string) # get the time in the specified format 13 | lbl.after(1000, time) 14 | 15 | lbl.pack(anchor = 'center') # centre align the text 16 | time() # show the time 17 | mainloop() # loop the program 18 | 19 | # now you can make it a standalone desktop app (.exe) with pyinstaller or auto-py-to-exe -------------------------------------------------------------------------------- /PythonCodes/JsonToCSV.py: -------------------------------------------------------------------------------- 1 | import json 2 | import csv 3 | 4 | ## specify file paths , along with extension 5 | input_json_file='input.json' 6 | csv_file = 'output.csv' 7 | # Load JSON data from a file 8 | with open(input_json_file) as json_file: 9 | data = json.load(json_file) 10 | # Open the CSV file in write mode 11 | with open(csv_file, 'w', newline='') as csvfile: 12 | # Create a CSV writer, write the header row and data rows 13 | writer = csv.writer(csvfile) 14 | writer.writerow(data[0].keys()) 15 | for item in data: 16 | writer.writerow(item.values()) 17 | print("Conversion successfull. The output file is saved as : "+ csv_file) 18 | 19 | # why is this useful? Usually ML models are trained on CSV files but maybe your data is taken from MongoDB, that stores data in JSON like format. 20 | # this script comes in handy -------------------------------------------------------------------------------- /PythonCodes/OTPverification.py: -------------------------------------------------------------------------------- 1 | import os 2 | import math 3 | import random 4 | import smtplib 5 | digits="0123456789" 6 | OTP="" 7 | for i in range(6): 8 | OTP+=digits[math.floor(random.random()*10)] 9 | otp = OTP + " is your OTP" 10 | msg= otp 11 | s = smtplib.SMTP('smtp.gmail.com', 587) 12 | s.starttls() 13 | s.login("Your Gmail Account", "You app password") 14 | emailid = input("Enter your email: ") 15 | s.sendmail('&&&&&&&&&&&',emailid,msg) 16 | a = input("Enter Your OTP >>: ") 17 | if a == OTP: 18 | print("Verified") 19 | else: 20 | print("Please Check your OTP again") 21 | -------------------------------------------------------------------------------- /PythonCodes/PasswordStrengthChecker.py: -------------------------------------------------------------------------------- 1 | import string 2 | import getpass 3 | 4 | def check_password_strength(password): 5 | strength = 0 6 | remarks = [] 7 | 8 | if len(password) < 8: 9 | remarks.append("Password is too short. It should be at least 8 characters long.") 10 | if any(c in string.ascii_lowercase for c in password): 11 | strength += 1 12 | if any(c in string.ascii_uppercase for c in password): 13 | strength += 1 14 | if any(c in string.digits for c in password): 15 | strength += 1 16 | if any(c in string.punctuation for c in password): 17 | strength += 1 18 | 19 | if strength == 1: 20 | remarks.append("That's a weak password. Consider using a mix of character types.") 21 | elif strength == 2: 22 | remarks.append("Your password is okay, but it can be improved.") 23 | elif strength >= 3: 24 | remarks.append("Your password is strong.") 25 | 26 | return remarks 27 | 28 | def main(): 29 | print('Welcome to Password Strength Checker') 30 | while True: 31 | password = getpass.getpass('Enter the password: ') 32 | strength_remarks = check_password_strength(password) 33 | for remark in strength_remarks: 34 | print(remark) 35 | 36 | choice = input('Do you want to check another password\'s strength (y/n): ') 37 | if choice.lower() != 'y': 38 | print('Exiting...') 39 | break 40 | 41 | if __name__ == '__main__': 42 | main() 43 | -------------------------------------------------------------------------------- /PythonCodes/TicTacToe.py: -------------------------------------------------------------------------------- 1 | import random 2 | class TicTacToe: 3 | 4 | def __init__(self): 5 | self.board = [] 6 | 7 | def create_board(self): 8 | for i in range(3): 9 | row = [] 10 | for j in range(3): 11 | row.append('-') 12 | self.board.append(row) 13 | 14 | def get_random_first_player(self): 15 | return random.randint(0, 1) 16 | 17 | def fix_spot(self, row, col, player): 18 | self.board[row][col] = player 19 | 20 | def has_player_won(self, player): 21 | n = len(self.board) 22 | board_values = set() 23 | 24 | # check rows 25 | for i in range(n): 26 | for j in range(n): 27 | board_values.add(self.board[i][j]) 28 | 29 | if board_values == {player}: 30 | return True 31 | else: 32 | board_values.clear() 33 | 34 | # check cols 35 | for i in range(n): 36 | for j in range(n): 37 | board_values.add(self.board[j][i]) 38 | 39 | if board_values == {player}: 40 | return True 41 | else: 42 | board_values.clear() 43 | 44 | # check diagonals 45 | for i in range(n): 46 | board_values.add(self.board[i][i]) 47 | if board_values == {player}: 48 | return True 49 | else: 50 | board_values.clear() 51 | 52 | board_values.add(self.board[0][2]) 53 | board_values.add(self.board[1][1]) 54 | board_values.add(self.board[2][0]) 55 | if board_values == {player}: 56 | return True 57 | else: 58 | return False 59 | 60 | def is_board_filled(self): 61 | for row in self.board: 62 | for item in row: 63 | if item == '-': 64 | return False 65 | return True 66 | 67 | def swap_player_turn(self, player): 68 | return 'X' if player == 'O' else 'O' 69 | 70 | def show_board(self): 71 | for row in self.board: 72 | for item in row: 73 | print(item, end=' ') 74 | print() 75 | 76 | def start(self): 77 | self.create_board() 78 | player = 'X' if self.get_random_first_player() == 1 else 'O' 79 | game_over = False 80 | 81 | while not game_over: 82 | try: 83 | self.show_board() 84 | print(f'\nPlayer {player} turn') 85 | 86 | row, col = list( 87 | map(int, input( 88 | 'Enter row & column numbers to fix spot: ').split())) 89 | print() 90 | 91 | if col is None: 92 | raise ValueError( 93 | 'not enough values to unpack (expected 2, got 1)') 94 | 95 | self.fix_spot(row - 1, col - 1, player) 96 | 97 | game_over = self.has_player_won(player) 98 | if game_over: 99 | print(f'Player {player} wins the game!') 100 | continue 101 | 102 | game_over = self.is_board_filled() 103 | if game_over: 104 | print('Match Draw!') 105 | continue 106 | 107 | player = self.swap_player_turn(player) 108 | 109 | except ValueError as err: 110 | print(err) 111 | 112 | print() 113 | self.show_board() 114 | 115 | 116 | if __name__ == '__main__': 117 | tic_tac_toe = TicTacToe() 118 | tic_tac_toe.start() 119 | -------------------------------------------------------------------------------- /PythonCodes/TicTacToe2.py: -------------------------------------------------------------------------------- 1 | board = [' ' for x in range(9)] 2 | 3 | def print_board(): 4 | row1 = '| {} | {} | {} |'.format(board[0], board[1], board[2]) 5 | row2 = '| {} | {} | {} |'.format(board[3], board[4], board[5]) 6 | row3 = '| {} | {} | {} |'.format(board[6], board[7], board[8]) 7 | print() 8 | print(row1) 9 | print(row2) 10 | print(row3) 11 | print() 12 | 13 | def player_move(icon): 14 | if icon == 'X': 15 | number = 1 16 | elif icon == 'O': 17 | number = 2 18 | print('Your turn player {}'.format(number)) 19 | choice = int(input('Enter your move (1-9): ').strip()) 20 | if board[choice - 1] == ' ': 21 | board[choice - 1] = icon 22 | else: 23 | print() 24 | print('That space is taken!') 25 | 26 | def is_victory(icon): 27 | if (board[0] == icon and board[1] == icon and board[2] == icon) or \ 28 | (board[3] == icon and board[4] == icon and board[5] == icon) or \ 29 | (board[6] == icon and board[7] == icon and board[8] == icon) or \ 30 | (board[0] == icon and board[3] == icon and board[6] == icon) or \ 31 | (board[1] == icon and board[4] == icon and board[7] == icon) or \ 32 | (board[2] == icon and board[5] == icon and board[8] == icon) or \ 33 | (board[0] == icon and board[4] == icon and board[8] == icon) or \ 34 | (board[2] == icon and board[4] == icon and board[6] == icon): 35 | return True 36 | else: 37 | return False 38 | 39 | def is_draw(): 40 | if ' ' not in board: 41 | return True 42 | else: 43 | return False 44 | 45 | while True: 46 | print_board() 47 | player_move('X') 48 | print_board() 49 | if is_victory('X'): 50 | print('X Wins! Congratulations!') 51 | break 52 | elif is_draw(): 53 | print('The game is a draw!') 54 | break 55 | player_move('O') 56 | if is_victory('O'): 57 | print_board() 58 | print('O Wins! Congratulations!') 59 | break 60 | elif is_draw(): 61 | print('The game is a draw!') 62 | break 63 | -------------------------------------------------------------------------------- /PythonCodes/basic.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import matplotlib.pyplot as plt 4 | 5 | # x axis values 6 | x = [1,2,3] 7 | # corresponding y axis values 8 | y = [2,4,1] 9 | 10 | # plotting the points 11 | plt.plot(x, y) 12 | 13 | # naming the x axis 14 | plt.xlabel('x - axis') 15 | # naming the y axis 16 | plt.ylabel('y - axis') 17 | 18 | # giving a title to my graph 19 | plt.title('My first graph!') 20 | 21 | # function to show the plot 22 | plt.show() 23 | -------------------------------------------------------------------------------- /PythonCodes/stopwatchGUI.py: -------------------------------------------------------------------------------- 1 | ## Author: sagnik-p 2 | from tkinter import * 3 | import time 4 | def run(): 5 | global root 6 | root = Tk() 7 | root.title("Stopwatch") 8 | width = 400 9 | height = 160 10 | screen_width = root.winfo_screenwidth() 11 | screen_height = root.winfo_screenheight() 12 | x = (screen_width / 2) - (width / 2) 13 | y = (screen_height / 2) - (height / 2) 14 | root.geometry("%dx%d+%d+%d" % (width, height, x, y)) 15 | Top = Frame(root) 16 | Top.pack(side=TOP) 17 | stopWatch = StopWatch(root) 18 | stopWatch.pack(side=TOP,pady=15) 19 | Bottom = Frame(root, width=400) 20 | Bottom.pack(side=BOTTOM) 21 | Start = Button(Bottom, text='Start', command=stopWatch.Start, width=20, height=2, bg="green") 22 | Start.pack(side=LEFT) 23 | Stop = Button(Bottom, text='Stop', command=stopWatch.Stop, width=20, height=2, bg="red") 24 | Stop.pack(side=LEFT) 25 | Reset = Button(Bottom, text='Reset', command=stopWatch.Reset, width=15, height=2) 26 | Reset.pack(side=LEFT) 27 | root.config(bg="black") 28 | root.mainloop() 29 | 30 | 31 | class StopWatch(Frame): 32 | def __init__(self, parent=None, **kw): 33 | Frame.__init__(self, parent, kw) 34 | self.startTime = 0.0 35 | self.nextTime = 0.0 36 | self.onRunning = 0 37 | self.timestr = StringVar() 38 | self.MakeWidget() 39 | def Updater(self): 40 | self.nextTime = time.time() - self.startTime 41 | self.SetTime(self.nextTime) 42 | self.timer = self.after(1, self.Updater) 43 | def MakeWidget(self): 44 | timeText = Label(self, textvariable=self.timestr, font=("callibri", 50), fg="yellow", bg="grey") 45 | self.SetTime(self.nextTime) 46 | timeText.pack(fill=X, expand=NO, pady=2, padx=2) 47 | def SetTime(self, nextElap): 48 | mins = int(nextElap / 60) 49 | secs = int(nextElap - mins * 60.0) 50 | milisecs = int((nextElap - mins * 60.0 - secs) * 100) 51 | self.timestr.set('%02d:%02d:%02d' % (mins, secs, milisecs)) 52 | def Start(self): 53 | if not self.onRunning: 54 | self.startTime = time.time() - self.nextTime 55 | self.Updater() 56 | self.onRunning = 1 57 | def Stop(self): 58 | if self.onRunning: 59 | self.after_cancel(self.timer) 60 | self.nextTime = time.time() - self.startTime 61 | self.SetTime(self.nextTime) 62 | self.onRunning = 0 63 | def Reset(self): 64 | self.startTime = time.time() 65 | self.nextTime = 0.0 66 | self.SetTime(self.nextTime) 67 | if __name__ == '__main__': 68 | run() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Data Science Codes 2 | 3 | 4 |

5 | Data Visualization Image 6 |

7 | 8 | Data visualization is a powerful tool for understanding and communicating insights from data. This repository aims to provide a comprehensive collection of Python libraries and techniques. 9 | 10 | 11 | ## Contributing 12 | 13 | Thank you for your interest in contributing to this project! Hacktoberfest 2023 is the perfect opportunity to get involved. Here's how you can contribute: 14 | 15 | - Star and fork this repository to your own GitHub account. 16 | - Clone the forked repository to your local machine. 17 | 18 | ``` 19 | git clone https://github.com/your-username/Data-Visualization-in-Python.git 20 | 21 | ``` 22 | 23 | - Create a new branch to work on your contribution. 24 | 25 | ``` 26 | git branch your-feature-branch 27 | ``` 28 | 29 | - Switch to your branch 30 | 31 | ``` 32 | git checkout your-feature-branch 33 | 34 | ``` 35 | 36 | ``` 37 | git commit -m "Add a new example for Seaborn" 38 | 39 | ``` 40 | 41 | - Push your changes to Github repo 42 | 43 | ``` 44 | git push origin feature/your-feature-branch 45 | 46 | ``` 47 | 48 | - Create a pull request (PR) from your branch to the main repository. Be sure to describe your contribution and mention any relevant issues. 49 | - Wait for your PR to be reviewed and merged. You may need to make some adjustments based on the feedback received. 50 | 51 | Please adhere to our code of conduct and respect the guidelines outlined in our contributing guidelines. 52 | 53 | Happy Contributing! 54 | 55 | ## Contributors 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Security.md: -------------------------------------------------------------------------------- 1 | ## Security Policy 2 | Supported Versions 3 | The following versions of Data-Science-Codes are currently supported with security updates: 4 | 5 | Version Supported 6 | 1.x.x ✅ Supported 7 | 0.x.x ❌ Not supported 8 | Reporting a Vulnerability 9 | If you discover a security vulnerability in Data-Science-Codes, we encourage you to report it as soon as possible. We will investigate all legitimate reports and do our best to quickly fix the issue. 10 | 11 | How to Report 12 | Please report vulnerabilities by emailing us at Data-Science-Codes@gmail.com. Include as much detail as possible to help us identify and fix the issue swiftly. 13 | Do not share the vulnerability publicly until it has been addressed and a patch is available. 14 | 15 | Security Updates 16 | We will notify users via GitHub releases for any critical security updates. 17 | Minor security patches will be included in regular updates as needed. 18 | 19 | Security Best Practices 20 | Make sure to use the latest version of EzyShop for the latest security features and patches. 21 | Follow password best practices, such as using strong, unique passwords for each account. 22 | Regularly update your dependencies to the latest versions. 23 | 24 | Acknowledgements 25 | We appreciate contributions from the community and researchers who help us improve the security of Data-Science-Codes. Thank you for keeping the platform secure for everyone! 26 | 27 | -------------------------------------------------------------------------------- /Visualization Codes/001_getting_started.py: -------------------------------------------------------------------------------- 1 | # importing the required module 2 | # pip install matplotlib 3 | 4 | import matplotlib.pyplot as plt 5 | 6 | # x axis values 7 | x = [1,2,3] 8 | # corresponding y axis values 9 | y = [2,4,1] 10 | 11 | # plotting the points 12 | plt.plot(x, y) 13 | 14 | # naming the x axis 15 | plt.xlabel('x - axis') 16 | # naming the y axis 17 | plt.ylabel('y - axis') 18 | 19 | # giving a title to my graph 20 | plt.title('My first graph!') 21 | 22 | # function to show the plot 23 | plt.show() 24 | -------------------------------------------------------------------------------- /Visualization Codes/Axis.py: -------------------------------------------------------------------------------- 1 | #Code to plot axis of a graph 2 | 3 | from matplotlib import pyplot as plt 4 | import numpy as np 5 | 6 | plt.plot(np.array([1,2,3,4],[1,4,9,16]),'ro') 7 | plt.axis([0,6,0,20]) 8 | plt.show() 9 | -------------------------------------------------------------------------------- /Visualization Codes/Bar.py: -------------------------------------------------------------------------------- 1 | #code to demonstrate bar graph 2 | import matplotlib.pyplot as plt 3 | import numpy as np 4 | 5 | 6 | x = np.array([5, 2, 9, 4, 7]) 7 | y = np.array([10, 5, 8, 4, 2]) 8 | bar_colors = ['blue', 'green', 'red', 'purple', 'orange'] 9 | plt.bar(x, y, color=bar_colors) 10 | 11 | # Add labels to the axes 12 | plt.xlabel('X-axis Label') 13 | plt.ylabel('Y-axis Label') 14 | 15 | plt.title('Bar Plot Example') 16 | plt.show() 17 | 18 | 19 | -------------------------------------------------------------------------------- /Visualization Codes/Data.py: -------------------------------------------------------------------------------- 1 | #importing the csv module 2 | import csv 3 | 4 | mydict=[{'branch': 'COE','cgpa':'9.0','name':'Debaditya','year':'2'}, 5 | {'branch': 'COE','cgpa':'9.1','name':'Som','year':'2'}, 6 | {'branch': 'CSBS','cgpa':'8.0','name':'Ricky','year':'1'}, 7 | {'branch': 'IT','cgpa':'9.5','name':'Aditya','year':'3'}, 8 | {'branch': 'MCE','cgpa':'7.0','name':'Philips','year':'3'}, 9 | {'branch': 'ECE','cgpa':'9.0','name':'Evan','year':'2'}] 10 | 11 | 12 | #field names 13 | fields = ['name','branch','year','cgpa'] 14 | 15 | #name of csv file 16 | filename = "university_record.csv" 17 | 18 | #writing to csv 19 | with open(filename,'w') as csvfile: 20 | #creating csv dict writer object 21 | writer = csv.DictWriter(csvfile,fieldnames = fields) 22 | 23 | #writing headers(field name) 24 | writer.writeheader() 25 | 26 | #writing data rows 27 | writer.writerows(mydict) -------------------------------------------------------------------------------- /Visualization Codes/Data2.py: -------------------------------------------------------------------------------- 1 | import csv 2 | filename = "aapl.csv" 3 | 4 | fields=[] 5 | rows=[] 6 | 7 | with open(filename,'r') as csvfile: 8 | csvreader = csv.reader(csvfile) 9 | fields = next(csvreader) 10 | 11 | for rows in csvreader: 12 | rows.append(row) 13 | 14 | print("Total no. of rows: %d"%(csvreader.line_num)) 15 | 16 | print('Field names are:'+','.join(field for field in fields)) 17 | 18 | print("\nFirst 5 rows are:\n") 19 | for rows in rows[5]: 20 | for col in row: 21 | print("%10s"%col,end=" "), 22 | print('\n') -------------------------------------------------------------------------------- /Visualization Codes/Data3.py: -------------------------------------------------------------------------------- 1 | import csv 2 | 3 | rows=[{'branch': 'COE','cgpa':'9.0','name':'Debaditya','year':'2'}, 4 | {'branch': 'COE','cgpa':'9.1','name':'Som','year':'2'}, 5 | {'branch': 'CSBS','cgpa':'8.0','name':'Ricky','year':'1'}, 6 | {'branch': 'IT','cgpa':'9.5','name':'Aditya','year':'3'}, 7 | {'branch': 'MCE','cgpa':'7.0','name':'Philips','year':'3'}, 8 | {'branch': 'ECE','cgpa':'9.0','name':'Evan','year':'2'}] 9 | 10 | 11 | #field names 12 | fields = ['name','branch','year','cgpa'] 13 | 14 | #name of csv file 15 | filename = "university_record.csv" 16 | 17 | #writing to csv 18 | with open(filename,'w') as csvfile: 19 | csvwriter = csv.writer(csvfile) 20 | 21 | csvwriter.writerow(fields) 22 | 23 | csvwriter.writerows(rows) -------------------------------------------------------------------------------- /Visualization Codes/Figure.py: -------------------------------------------------------------------------------- 1 | 2 | import numpy as np 3 | from matplotlib import pyplot as plt 4 | 5 | 6 | plt.figure(1) #first figure 7 | plt.subplot(211) 8 | plt.plot([1,2,3]) 9 | plt.plot (np.array([1,2,3])) 10 | plt.subplot(212) 11 | plt.plot([4,5,6]) 12 | plt.plot (np.array([4,5,6])) 13 | # plt.subplot(213) 14 | plt.plot([7,8,9]) 15 | 16 | plt.figure(2) #second figure 17 | plt.plot([4,5,6]) 18 | 19 | plt.figure(3) #third figure 20 | plt.plot([7,8,9]) 21 | plt.plot (np.array([7,8,9])) 22 | 23 | plt.figure(1) #first figure current; 24 | 25 | plt.figure(2) #second figure 26 | plt.plot (np.array([4,5,6])) 27 | plt.figure(3) #first figure current; 28 | 29 | plt.subplot(211) #make subplot(211) in the first figure 30 | 31 | plt.title('Easy as 1,2,3') #subplot 211 32 | -------------------------------------------------------------------------------- /Visualization Codes/Graph.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | x1 = [1,2,3] 3 | y1 = [2,4,1] 4 | 5 | plt.plot(x1, y1, label = "line 1") 6 | 7 | x2 = [1,2,3] 8 | y2 = [4,1,3] 9 | 10 | plt.plot(x2, y2, label = "line 2") 11 | 12 | 13 | plt.xlabel('x - axis') 14 | plt.ylabel('y - axis') 15 | plt.title('Two lines on same graph!') 16 | 17 | 18 | plt.legend() 19 | plt.show() 20 | 21 | -------------------------------------------------------------------------------- /Visualization Codes/Histogram.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | 3 | y = [10, 5, 8, 4, 2] 4 | num_bins = 10 5 | plt.hist(y, bins=num_bins, color='green', alpha=0.5) 6 | 7 | plt.xlabel('X-axis Label') 8 | plt.ylabel('Frequency') 9 | 10 | plt.title('Histogram Plot Example') 11 | plt.show() 12 | -------------------------------------------------------------------------------- /Visualization Codes/Normal.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | 3 | # Example dataset 4 | data = { 5 | 'X': [1.2, 0.5, 2.2, -0.1, 1.7, 2.8, 0.9, 3.0, 2.5, 1.5], 6 | 'Y': [2.3, 0.7, 2.9, 0.4, 1.8, 3.2, 1.2, 3.5, 2.6, 1.9] 7 | } 8 | 9 | # Create a scatter plot of the original data 10 | plt.figure(figsize=(6, 6)) 11 | plt.scatter(data['X'], data['Y'], label='Data Points', color='blue') 12 | plt.xlabel('Feature 1 (X)') 13 | plt.ylabel('Feature 2 (Y)') 14 | plt.title('Scatter Plot of Original Data') 15 | plt.legend() 16 | plt.grid(True) 17 | plt.show() 18 | -------------------------------------------------------------------------------- /Visualization Codes/PCA1.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | 4 | # Example dataset 5 | data = { 6 | 'X': [1.2, 0.5, 2.2, -0.1, 1.7, 2.8, 0.9, 3.0, 2.5, 1.5], 7 | 'Y': [2.3, 0.7, 2.9, 0.4, 1.8, 3.2, 1.2, 3.5, 2.6, 1.9] 8 | } 9 | 10 | # Convert the data into a NumPy array for PCA 11 | data_array = np.array([data['X'], data['Y']]) 12 | 13 | # Perform PCA 14 | mean_centered_data = data_array - np.mean(data_array, axis=1, keepdims=True) 15 | covariance_matrix = np.cov(mean_centered_data) 16 | eigenvalues, eigenvectors = np.linalg.eig(covariance_matrix) 17 | 18 | # Sort the eigenvectors based on eigenvalues (descending order) 19 | sorted_indices = np.argsort(eigenvalues)[::-1] 20 | sorted_eigenvectors = eigenvectors[:, sorted_indices] 21 | 22 | # Take the first principal component 23 | principal_component = sorted_eigenvectors[:, 0] 24 | 25 | # Create a scatter plot of the original data 26 | plt.figure(figsize=(8, 6)) 27 | plt.scatter(data['X'], data['Y'], label='Data Points', color='blue', s=80) 28 | 29 | # Plot the principal component as a line covering the entire plot area 30 | mean_x, mean_y = np.mean(data_array, axis=1) 31 | scaling_factor = 2 # Adjust the scaling factor to extend the line 32 | plt.plot([mean_x - scaling_factor * principal_component[0], mean_x + scaling_factor * principal_component[0]], 33 | [mean_y - scaling_factor * principal_component[1], mean_y + scaling_factor * principal_component[1]], 34 | color='red', linewidth=2, label='Principal Component') 35 | 36 | plt.xlabel('Feature 1 (X)', fontsize=10) 37 | plt.ylabel('Feature 2 (Y)', fontsize=10) 38 | plt.title('PCA: Principal Component', fontsize=12) 39 | plt.legend(fontsize=12) 40 | plt.grid(True) 41 | plt.axis('equal') # Set equal aspect ratio for better visualization 42 | plt.xticks(fontsize=10) 43 | plt.yticks(fontsize=10) 44 | plt.tight_layout() # Adjust plot layout for better spacing 45 | plt.show() 46 | -------------------------------------------------------------------------------- /Visualization Codes/Perceptron_Trick.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | 4 | # for making a simple classifiacation datset 5 | from sklearn.datasets import make_classification 6 | X,y=make_classification(n_samples=100,n_features=2,n_informative=1,n_redundant=0,n_classes=2,n_clusters_per_class=1, 7 | random_state=41,hypercube=False,class_sep=10) 8 | y.shape 9 | plt.figure(figsize=(10,6)) 10 | plt.scatter(X[:,0],X[:,1],c=y,cmap='winter',s=100) 11 | # Perceptron Function for calculating Weights 12 | def Perceptron(X,y): 13 | X=np.insert(X,0,1,axis=1) # inserting 1 at 0th column for each X_i 14 | weights=np.ones(X.shape[1]) # initializing weights as [1,1,1] 15 | lr=0.1 # initializing learning rate 16 | 17 | for i in range(1000): 18 | j=np.random.randint(100) # first choose a random row 19 | y_hat=step(np.dot(X[j],weights)) # calculating Y_hat using step function 20 | weights=weights+lr*(y[j]-y_hat)*X[j] # updating weights W_new=W_old+lr*(Y_i - Y_hat)*X_i 21 | 22 | return weights[0],weights[1:] 23 | # step function 24 | def step(z): 25 | return 1 if z>=0 else 0 26 | intercept_,coef_=Perceptron(X,y) # model training 27 | print("Intercept is-->",intercept_) 28 | print("Coeffecients-->",coef_) 29 | # calculating m and b (m=-(A/B) , b=-(C/B)) 30 | m=-(coef_[0]/coef_[1]) 31 | b=-(intercept_/coef_[1]) 32 | x_input=np.linspace(-3,3,100) 33 | y_input=m*x_input+b 34 | plt.figure(figsize=[10,6]) 35 | plt.plot(x_input,y_input,color='red',linewidth=2) 36 | plt.scatter(X[:,0],X[:,1],c=y,cmap='winter',s=100) 37 | plt.ylim(-3,2) 38 | -------------------------------------------------------------------------------- /Visualization Codes/PieChart.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | 4 | y = np.array([45, 25, 15, 10]) 5 | mylabels = ["Procrastination", "StackOverflow", "Debugging", "Coding"] 6 | mycolors = ["#4B0082", "#9B3192", "#EA5789", "#F7B7A3"] 7 | 8 | # Explode one or more slices (e.g., the first slice) 9 | myexplode = (0.1, 0, 0, 0) 10 | plt.pie(y, labels=mylabels, colors=mycolors, explode=myexplode, autopct='%1.1f%%') 11 | 12 | plt.legend(title="Life of a programmer:", loc="center right") 13 | plt.axis('equal') 14 | 15 | plt.show() 16 | -------------------------------------------------------------------------------- /Visualization Codes/Plot.py: -------------------------------------------------------------------------------- 1 | #importing matplotlib module 2 | from matplotlib import pyplot as plt 3 | 4 | x=[5,2,9,4,7] 5 | y =[10,5,8,4,2] 6 | 7 | plt.plot(x,y) 8 | 9 | plt.show() -------------------------------------------------------------------------------- /Visualization Codes/Scatter2.py: -------------------------------------------------------------------------------- 1 | from matplotlib import pyplot as plt 2 | 3 | x=[5,2,9,4,7] 4 | y=[10,5,8,4,2] 5 | 6 | plt.plot(x,y,'o') 7 | 8 | plt.show() -------------------------------------------------------------------------------- /Visualization Codes/Subplot.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from matplotlib import pyplot as plt 3 | 4 | names = ['group_a','group_b','group_c'] 5 | values = [1,10,100] 6 | plt.subplot(131) 7 | plt.bar(names,values) 8 | plt.scatter(names,values) 9 | plt.subplot(133) 10 | plt.plot(names,values) 11 | plt.suptitle('Catergorical Plotting') 12 | plt.show() -------------------------------------------------------------------------------- /Visualization Codes/VISUALIZATION.md: -------------------------------------------------------------------------------- 1 | # Visualization in Python 2 | This file contains all the various ways to implement matplotlib library for visualization of data in python 3 | 4 | ## Axis 5 | ![Axis](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/46b72fb1-9ef6-4e1d-9b1c-02c6ce81330b) 6 | ## Bar 7 | ![Bar](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/24a536d0-a519-4397-89e3-04f960ccb62c) 8 | ## Figure_1 9 | ![Figure_1](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/45f11522-dab9-4eff-9add-c6d95f2e3fe6) 10 | ## Figure_2 11 | ![Figure_2](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/9ab8c8e7-768b-469b-818f-328a51b3ea49) 12 | ## Graph 13 | ![Graph](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/861e13b8-e5bf-47d4-b194-aba310b15124) 14 | ## Histogram 15 | ![Histogram](![image](https://github.com/Debaditya-Som/Data-Visualization-in-Python/assets/100461991/b9e1cb3a-8cb9-437f-8323-a51f04daf7dc)) 16 | ## Normal 17 | ![Normal](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/6c98a5d7-a915-4955-81bd-43e69d932dab) 18 | ## PCA1 19 | ![PCA1](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/3bf3be39-721a-43ae-b293-95eb4596691c) 20 | ## PieChart 21 | ![PieChart](![image](https://github.com/Debaditya-Som/Data-Visualization-in-Python/assets/100461991/3e058f3a-b060-43af-8f93-7d4ccb90a7af)) 22 | ## Plot 23 | ![Plot](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/f51672f4-9a3d-4ba7-9240-4b265fe4b463) 24 | ## Scatter 25 | ![Scatter](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/18b42153-f91d-4a99-948c-59667c12d97a) 26 | ## Scatter2 27 | ![Scatter2](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/4f14d4a5-fa57-472c-ad14-6c356e001c12) 28 | ## Subplot 29 | ![Subplot](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/55ccb1bd-0bb3-41d8-a7d1-e0a6eece2ba7) 30 | ## Visualization 31 | ![Visualization](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/af4341c1-130b-4df3-a804-c60c68fe1f9a) 32 | ## Visualization2 33 | ![Visualization2](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/15b0b6ea-7a69-4066-9794-e0b0a5c6f81e) 34 | ## Ylabel 35 | ![Ylabel](https://github.com/Anushka-Bhowmick/matplotlib/assets/76967222/9016c3b8-3866-426d-9cef-1571113daf51) 36 | 37 | -------------------------------------------------------------------------------- /Visualization Codes/Visualization.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from matplotlib import pyplot as plt 3 | 4 | #evenly sampled time at 200ms intervals 5 | t = np.arange(0.,5.,0.2) 6 | 7 | #red dashes, blue squares and green triangles 8 | plt.plot(t,t,'r--', t,t**2,'bs',t,t**3,'g^') 9 | plt.show() 10 | -------------------------------------------------------------------------------- /Visualization Codes/Visualization2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from matplotlib import pyplot as plt 3 | 4 | data = { 'a': np.arange(50), 5 | 'c': np.random.randint(0,50,50), 6 | 'd': np.random.randn(50) } 7 | 8 | data['b'] = data['a']+ 10* np.random.randn(50) 9 | data['d'] = np.abs(data['d'])*100 10 | 11 | plt.scatter( 'a', 'b',c='c',s='d', data = data) 12 | plt.xlabel('entry a') 13 | plt.ylabel('entry b') 14 | plt.show() -------------------------------------------------------------------------------- /Visualization Codes/Voltage-vs-Current-Graph.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | 4 | # Input data for the three curves (12 points each) 5 | # We can change the Points as we see fit 6 | # This Current data Set is for the Input Charactertics of BJT in Emitter Base 7 | voltage_red = np.array([0.24, 0.34, 0.44, 0.55, 0.60, 0.61, 0.62, 0.62, 0.62, 0.62, 0.62, 0.62,0.62,0.62,0.63,0.63,0.63,0.63,0.63,0.63,0.63,0.63,0.63,0.64,0.64,0.64,0.64,0.64]) 8 | current_red = np.array([0.2, 0.3, 0.4, 1.1, 2.6, 4.3, 5.7, 7.7, 9.6, 11.6, 13.8, 15.7,17.7,19.4,21.4,25.3,26.8,28.6,29.0,31.3,41.0,50.6,59.8,69.1,78.5,88.1,97.8,107.1]) 9 | 10 | voltage_blue = np.array([0.23, 0.32, 0.45, 0.54, 0.58, 0.61, 0.62, 0.62, 0.63, 0.64, 0.64, 0.65]) 11 | current_blue = np.array([0.2, 0.3, 0.5, 0.8, 2.3, 3.7, 5.7, 7.6, 9.2, 11.3, 13.1, 15.0]) 12 | 13 | voltage_green = np.array([0.21, 0.32, 0.45, 0.54, 0.58, 0.61, 0.62, 0.63, 0.63, 0.64, 0.64, 0.65]) 14 | current_green = np.array([0.1, 0.3, 0.5, 1.1, 2.5, 3.7, 5.6, 7.4, 9.3, 11.0, 13.0, 14.9]) 15 | 16 | # Create the plot 17 | plt.figure(figsize=(10, 6)) 18 | plt.plot(voltage_red, current_red, color='red', label='Red Curve(2V)') 19 | plt.plot(voltage_blue, current_blue, color='blue', label='Blue Curve(6V)') 20 | plt.plot(voltage_green, current_green, color='green', label='Green Curve(10V)') 21 | 22 | # Add labels and title 23 | plt.xlabel(' Base Emitter Voltage (V)') 24 | plt.ylabel(' Base Current (μA)') 25 | plt.title('Current vs Voltage') 26 | plt.legend() 27 | 28 | # Display the plot 29 | plt.grid(True) 30 | plt.show() 31 | -------------------------------------------------------------------------------- /Visualization Codes/Ylabel.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | plt.plot([1,2,3,4]) 3 | plt.ylabel('Some numbers') 4 | plt.show() -------------------------------------------------------------------------------- /Visualization Codes/distribution.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import matplotlib.pyplot as plt 3 | 4 | data=pd.read_csv("./datasets/dataset.csv") 5 | data.plot() 6 | ## if you dont want to plot all parameters, uncomment the following line 7 | ## data[["Age","Fare","Cabin"]].plot() 8 | plt.show() -------------------------------------------------------------------------------- /Visualization Codes/enhance.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/Visualization Codes/enhance.jpg -------------------------------------------------------------------------------- /Visualization Codes/enhance_histogram.py: -------------------------------------------------------------------------------- 1 | #write a python script to enhance the grey scale image using simple histogram equalization technique and display the equalized histogram along with the result image 2 | import cv2 3 | import numpy 4 | from matplotlib import pyplot as plt 5 | inpImg = 'enhance.jpg' 6 | img = cv2.imread(inpImg) 7 | img_to_yuv = cv2.cvtColor(img,cv2.COLOR_BGR2YUV) 8 | img_to_yuv[:,:,0] = cv2.equalizeHist(img_to_yuv[:,:,0]) 9 | hist_equalization_result = cv2.cvtColor(img_to_yuv,cv2.COLOR_YUV2BGR) 10 | outputImg = 'result.jpg' 11 | cv2.imwrite(outputImg, hist_equalization_result) 12 | inpImg = 'result.jpg' 13 | img = cv2.imread(inpImg, cv2.IMREAD_GRAYSCALE) 14 | cv2.imshow('Result',img) 15 | hist = cv2.calcHist([img],[0],None,[256],[0,256]) 16 | plt.hist(img.ravel(),256,[0,256]) 17 | plt.title('Histogram for the image') 18 | plt.show() 19 | while True: 20 | k = cv2.waitKey(0) & 0xFF 21 | if k == 27: break 22 | cv2.destroyAllWindows() 23 | -------------------------------------------------------------------------------- /Visualization Codes/scatter.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | 4 | def scatterplot(x_data, y_data, x_label="", y_label="", title="", color = "r", yscale_log=False): 5 | 6 | 7 | ax = plt.subplots() 8 | ax.scatter(x_data, y_data, s = 10, color = color, alpha = 0.75) 9 | 10 | if yscale_log == True: 11 | ax.set_yscale('log') 12 | 13 | ax.set_title(title) 14 | ax.set_xlabel(x_label) 15 | ax.set_ylabel(y_label) 16 | -------------------------------------------------------------------------------- /Visualization Codes/scatterplot.py: -------------------------------------------------------------------------------- 1 | # Import necessary libraries 2 | import seaborn as sns 3 | import matplotlib.pyplot as plt 4 | 5 | # Load sample dataset from Seaborn 6 | tips = sns.load_dataset("tips") 7 | 8 | # Create a Seaborn scatter plot 9 | # `tips` is the DataFrame to be plotted 10 | # `x` and `y` specify the columns for the x and y axes 11 | # `hue` adds a categorical variable to the plot, color-coding the points 12 | # `palette` specifies the color palette to be used for the categorical variable 13 | # `size` changes the size of the points in the plot 14 | sns.scatterplot(x="total_bill", y="tip", hue="sex", palette="Set1", size="size", data=tips) 15 | 16 | # Set plot labels and title 17 | plt.xlabel("Total Bill ($)") 18 | plt.ylabel("Tip ($)") 19 | plt.title("Total Bill vs. Tip Amount") 20 | 21 | # Display the plot 22 | plt.show() 23 | -------------------------------------------------------------------------------- /datasets/dataset.csv: -------------------------------------------------------------------------------- 1 | PassengerId,Pclass,Name,Sex,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked 2 | 892,3,"Kelly, Mr. James",male,34.5,0,0,330911,7.8292,,Q 3 | 893,3,"Wilkes, Mrs. James (Ellen Needs)",female,47,1,0,363272,7,,S 4 | 894,2,"Myles, Mr. Thomas Francis",male,62,0,0,240276,9.6875,,Q 5 | 895,3,"Wirz, Mr. Albert",male,27,0,0,315154,8.6625,,S 6 | 896,3,"Hirvonen, Mrs. Alexander (Helga E Lindqvist)",female,22,1,1,3101298,12.2875,,S 7 | 897,3,"Svensson, Mr. Johan Cervin",male,14,0,0,7538,9.225,,S 8 | 898,3,"Connolly, Miss. Kate",female,30,0,0,330972,7.6292,,Q 9 | 899,2,"Caldwell, Mr. Albert Francis",male,26,1,1,248738,29,,S 10 | 900,3,"Abrahim, Mrs. Joseph (Sophie Halaut Easu)",female,18,0,0,2657,7.2292,,C 11 | 901,3,"Davies, Mr. John Samuel",male,21,2,0,A/4 48871,24.15,,S 12 | 902,3,"Ilieff, Mr. Ylio",male,,0,0,349220,7.8958,,S 13 | 903,1,"Jones, Mr. Charles Cresson",male,46,0,0,694,26,,S 14 | 904,1,"Snyder, Mrs. John Pillsbury (Nelle Stevenson)",female,23,1,0,21228,82.2667,B45,S 15 | 905,2,"Howard, Mr. Benjamin",male,63,1,0,24065,26,,S 16 | 906,1,"Chaffee, Mrs. Herbert Fuller (Carrie Constance Toogood)",female,47,1,0,W.E.P. 5734,61.175,E31,S 17 | 907,2,"del Carlo, Mrs. Sebastiano (Argenia Genovesi)",female,24,1,0,SC/PARIS 2167,27.7208,,C 18 | 908,2,"Keane, Mr. Daniel",male,35,0,0,233734,12.35,,Q 19 | 909,3,"Assaf, Mr. Gerios",male,21,0,0,2692,7.225,,C 20 | 910,3,"Ilmakangas, Miss. Ida Livija",female,27,1,0,STON/O2. 3101270,7.925,,S 21 | 911,3,"Assaf Khalil, Mrs. Mariana (Miriam"")""",female,45,0,0,2696,7.225,,C 22 | 912,1,"Rothschild, Mr. Martin",male,55,1,0,PC 17603,59.4,,C 23 | 913,3,"Olsen, Master. Artur Karl",male,9,0,1,C 17368,3.1708,,S 24 | 914,1,"Flegenheim, Mrs. Alfred (Antoinette)",female,,0,0,PC 17598,31.6833,,S 25 | 915,1,"Williams, Mr. Richard Norris II",male,21,0,1,PC 17597,61.3792,,C 26 | 916,1,"Ryerson, Mrs. Arthur Larned (Emily Maria Borie)",female,48,1,3,PC 17608,262.375,B57 B59 B63 B66,C 27 | 917,3,"Robins, Mr. Alexander A",male,50,1,0,A/5. 3337,14.5,,S 28 | 918,1,"Ostby, Miss. Helene Ragnhild",female,22,0,1,113509,61.9792,B36,C 29 | 919,3,"Daher, Mr. Shedid",male,22.5,0,0,2698,7.225,,C 30 | 920,1,"Brady, Mr. John Bertram",male,41,0,0,113054,30.5,A21,S 31 | 921,3,"Samaan, Mr. Elias",male,,2,0,2662,21.6792,,C 32 | 922,2,"Louch, Mr. Charles Alexander",male,50,1,0,SC/AH 3085,26,,S 33 | 923,2,"Jefferys, Mr. Clifford Thomas",male,24,2,0,C.A. 31029,31.5,,S 34 | 924,3,"Dean, Mrs. Bertram (Eva Georgetta Light)",female,33,1,2,C.A. 2315,20.575,,S 35 | 925,3,"Johnston, Mrs. Andrew G (Elizabeth Lily"" Watson)""",female,,1,2,W./C. 6607,23.45,,S 36 | 926,1,"Mock, Mr. Philipp Edmund",male,30,1,0,13236,57.75,C78,C 37 | 927,3,"Katavelas, Mr. Vassilios (Catavelas Vassilios"")""",male,18.5,0,0,2682,7.2292,,C 38 | 928,3,"Roth, Miss. Sarah A",female,,0,0,342712,8.05,,S 39 | 929,3,"Cacic, Miss. Manda",female,21,0,0,315087,8.6625,,S 40 | 930,3,"Sap, Mr. Julius",male,25,0,0,345768,9.5,,S 41 | 931,3,"Hee, Mr. Ling",male,,0,0,1601,56.4958,,S 42 | 932,3,"Karun, Mr. Franz",male,39,0,1,349256,13.4167,,C 43 | 933,1,"Franklin, Mr. Thomas Parham",male,,0,0,113778,26.55,D34,S 44 | 934,3,"Goldsmith, Mr. Nathan",male,41,0,0,SOTON/O.Q. 3101263,7.85,,S 45 | 935,2,"Corbett, Mrs. Walter H (Irene Colvin)",female,30,0,0,237249,13,,S 46 | 936,1,"Kimball, Mrs. Edwin Nelson Jr (Gertrude Parsons)",female,45,1,0,11753,52.5542,D19,S 47 | 937,3,"Peltomaki, Mr. Nikolai Johannes",male,25,0,0,STON/O 2. 3101291,7.925,,S 48 | 938,1,"Chevre, Mr. Paul Romaine",male,45,0,0,PC 17594,29.7,A9,C 49 | 939,3,"Shaughnessy, Mr. Patrick",male,,0,0,370374,7.75,,Q 50 | 940,1,"Bucknell, Mrs. William Robert (Emma Eliza Ward)",female,60,0,0,11813,76.2917,D15,C 51 | 941,3,"Coutts, Mrs. William (Winnie Minnie"" Treanor)""",female,36,0,2,C.A. 37671,15.9,,S 52 | 942,1,"Smith, Mr. Lucien Philip",male,24,1,0,13695,60,C31,S 53 | 943,2,"Pulbaum, Mr. Franz",male,27,0,0,SC/PARIS 2168,15.0333,,C 54 | 944,2,"Hocking, Miss. Ellen Nellie""""",female,20,2,1,29105,23,,S 55 | 945,1,"Fortune, Miss. Ethel Flora",female,28,3,2,19950,263,C23 C25 C27,S 56 | 946,2,"Mangiavacchi, Mr. Serafino Emilio",male,,0,0,SC/A.3 2861,15.5792,,C 57 | 947,3,"Rice, Master. Albert",male,10,4,1,382652,29.125,,Q 58 | 948,3,"Cor, Mr. Bartol",male,35,0,0,349230,7.8958,,S 59 | 949,3,"Abelseth, Mr. Olaus Jorgensen",male,25,0,0,348122,7.65,F G63,S 60 | 950,3,"Davison, Mr. Thomas Henry",male,,1,0,386525,16.1,,S 61 | 951,1,"Chaudanson, Miss. Victorine",female,36,0,0,PC 17608,262.375,B61,C 62 | 952,3,"Dika, Mr. Mirko",male,17,0,0,349232,7.8958,,S 63 | 953,2,"McCrae, Mr. Arthur Gordon",male,32,0,0,237216,13.5,,S 64 | 954,3,"Bjorklund, Mr. Ernst Herbert",male,18,0,0,347090,7.75,,S 65 | 955,3,"Bradley, Miss. Bridget Delia",female,22,0,0,334914,7.725,,Q 66 | 956,1,"Ryerson, Master. John Borie",male,13,2,2,PC 17608,262.375,B57 B59 B63 B66,C 67 | 957,2,"Corey, Mrs. Percy C (Mary Phyllis Elizabeth Miller)",female,,0,0,F.C.C. 13534,21,,S 68 | 958,3,"Burns, Miss. Mary Delia",female,18,0,0,330963,7.8792,,Q 69 | 959,1,"Moore, Mr. Clarence Bloomfield",male,47,0,0,113796,42.4,,S 70 | 960,1,"Tucker, Mr. Gilbert Milligan Jr",male,31,0,0,2543,28.5375,C53,C 71 | 961,1,"Fortune, Mrs. Mark (Mary McDougald)",female,60,1,4,19950,263,C23 C25 C27,S 72 | 962,3,"Mulvihill, Miss. Bertha E",female,24,0,0,382653,7.75,,Q 73 | 963,3,"Minkoff, Mr. Lazar",male,21,0,0,349211,7.8958,,S 74 | 964,3,"Nieminen, Miss. Manta Josefina",female,29,0,0,3101297,7.925,,S 75 | 965,1,"Ovies y Rodriguez, Mr. Servando",male,28.5,0,0,PC 17562,27.7208,D43,C 76 | 966,1,"Geiger, Miss. Amalie",female,35,0,0,113503,211.5,C130,C 77 | 967,1,"Keeping, Mr. Edwin",male,32.5,0,0,113503,211.5,C132,C 78 | 968,3,"Miles, Mr. Frank",male,,0,0,359306,8.05,,S 79 | 969,1,"Cornell, Mrs. Robert Clifford (Malvina Helen Lamson)",female,55,2,0,11770,25.7,C101,S 80 | 970,2,"Aldworth, Mr. Charles Augustus",male,30,0,0,248744,13,,S 81 | 971,3,"Doyle, Miss. Elizabeth",female,24,0,0,368702,7.75,,Q 82 | 972,3,"Boulos, Master. Akar",male,6,1,1,2678,15.2458,,C 83 | 973,1,"Straus, Mr. Isidor",male,67,1,0,PC 17483,221.7792,C55 C57,S 84 | 974,1,"Case, Mr. Howard Brown",male,49,0,0,19924,26,,S 85 | 975,3,"Demetri, Mr. Marinko",male,,0,0,349238,7.8958,,S 86 | 976,2,"Lamb, Mr. John Joseph",male,,0,0,240261,10.7083,,Q 87 | 977,3,"Khalil, Mr. Betros",male,,1,0,2660,14.4542,,C 88 | 978,3,"Barry, Miss. Julia",female,27,0,0,330844,7.8792,,Q 89 | 979,3,"Badman, Miss. Emily Louisa",female,18,0,0,A/4 31416,8.05,,S 90 | 980,3,"O'Donoghue, Ms. Bridget",female,,0,0,364856,7.75,,Q 91 | 981,2,"Wells, Master. Ralph Lester",male,2,1,1,29103,23,,S 92 | 982,3,"Dyker, Mrs. Adolf Fredrik (Anna Elisabeth Judith Andersson)",female,22,1,0,347072,13.9,,S 93 | 983,3,"Pedersen, Mr. Olaf",male,,0,0,345498,7.775,,S 94 | 984,1,"Davidson, Mrs. Thornton (Orian Hays)",female,27,1,2,F.C. 12750,52,B71,S 95 | 985,3,"Guest, Mr. Robert",male,,0,0,376563,8.05,,S 96 | 986,1,"Birnbaum, Mr. Jakob",male,25,0,0,13905,26,,C 97 | 987,3,"Tenglin, Mr. Gunnar Isidor",male,25,0,0,350033,7.7958,,S 98 | 988,1,"Cavendish, Mrs. Tyrell William (Julia Florence Siegel)",female,76,1,0,19877,78.85,C46,S 99 | 989,3,"Makinen, Mr. Kalle Edvard",male,29,0,0,STON/O 2. 3101268,7.925,,S 100 | 990,3,"Braf, Miss. Elin Ester Maria",female,20,0,0,347471,7.8542,,S 101 | 991,3,"Nancarrow, Mr. William Henry",male,33,0,0,A./5. 3338,8.05,,S 102 | 992,1,"Stengel, Mrs. Charles Emil Henry (Annie May Morris)",female,43,1,0,11778,55.4417,C116,C 103 | 993,2,"Weisz, Mr. Leopold",male,27,1,0,228414,26,,S 104 | 994,3,"Foley, Mr. William",male,,0,0,365235,7.75,,Q 105 | 995,3,"Johansson Palmquist, Mr. Oskar Leander",male,26,0,0,347070,7.775,,S 106 | 996,3,"Thomas, Mrs. Alexander (Thamine Thelma"")""",female,16,1,1,2625,8.5167,,C 107 | 997,3,"Holthen, Mr. Johan Martin",male,28,0,0,C 4001,22.525,,S 108 | 998,3,"Buckley, Mr. Daniel",male,21,0,0,330920,7.8208,,Q 109 | 999,3,"Ryan, Mr. Edward",male,,0,0,383162,7.75,,Q 110 | 1000,3,"Willer, Mr. Aaron (Abi Weller"")""",male,,0,0,3410,8.7125,,S 111 | 1001,2,"Swane, Mr. George",male,18.5,0,0,248734,13,F,S 112 | 1002,2,"Stanton, Mr. Samuel Ward",male,41,0,0,237734,15.0458,,C 113 | 1003,3,"Shine, Miss. Ellen Natalia",female,,0,0,330968,7.7792,,Q 114 | 1004,1,"Evans, Miss. Edith Corse",female,36,0,0,PC 17531,31.6792,A29,C 115 | 1005,3,"Buckley, Miss. Katherine",female,18.5,0,0,329944,7.2833,,Q 116 | 1006,1,"Straus, Mrs. Isidor (Rosalie Ida Blun)",female,63,1,0,PC 17483,221.7792,C55 C57,S 117 | 1007,3,"Chronopoulos, Mr. Demetrios",male,18,1,0,2680,14.4542,,C 118 | 1008,3,"Thomas, Mr. John",male,,0,0,2681,6.4375,,C 119 | 1009,3,"Sandstrom, Miss. Beatrice Irene",female,1,1,1,PP 9549,16.7,G6,S 120 | 1010,1,"Beattie, Mr. Thomson",male,36,0,0,13050,75.2417,C6,C 121 | 1011,2,"Chapman, Mrs. John Henry (Sara Elizabeth Lawry)",female,29,1,0,SC/AH 29037,26,,S 122 | 1012,2,"Watt, Miss. Bertha J",female,12,0,0,C.A. 33595,15.75,,S 123 | 1013,3,"Kiernan, Mr. John",male,,1,0,367227,7.75,,Q 124 | 1014,1,"Schabert, Mrs. Paul (Emma Mock)",female,35,1,0,13236,57.75,C28,C 125 | 1015,3,"Carver, Mr. Alfred John",male,28,0,0,392095,7.25,,S 126 | 1016,3,"Kennedy, Mr. John",male,,0,0,368783,7.75,,Q 127 | 1017,3,"Cribb, Miss. Laura Alice",female,17,0,1,371362,16.1,,S 128 | 1018,3,"Brobeck, Mr. Karl Rudolf",male,22,0,0,350045,7.7958,,S 129 | 1019,3,"McCoy, Miss. Alicia",female,,2,0,367226,23.25,,Q 130 | 1020,2,"Bowenur, Mr. Solomon",male,42,0,0,211535,13,,S 131 | 1021,3,"Petersen, Mr. Marius",male,24,0,0,342441,8.05,,S 132 | 1022,3,"Spinner, Mr. Henry John",male,32,0,0,STON/OQ. 369943,8.05,,S 133 | 1023,1,"Gracie, Col. Archibald IV",male,53,0,0,113780,28.5,C51,C 134 | 1024,3,"Lefebre, Mrs. Frank (Frances)",female,,0,4,4133,25.4667,,S 135 | 1025,3,"Thomas, Mr. Charles P",male,,1,0,2621,6.4375,,C 136 | 1026,3,"Dintcheff, Mr. Valtcho",male,43,0,0,349226,7.8958,,S 137 | 1027,3,"Carlsson, Mr. Carl Robert",male,24,0,0,350409,7.8542,,S 138 | 1028,3,"Zakarian, Mr. Mapriededer",male,26.5,0,0,2656,7.225,,C 139 | 1029,2,"Schmidt, Mr. August",male,26,0,0,248659,13,,S 140 | 1030,3,"Drapkin, Miss. Jennie",female,23,0,0,SOTON/OQ 392083,8.05,,S 141 | 1031,3,"Goodwin, Mr. Charles Frederick",male,40,1,6,CA 2144,46.9,,S 142 | 1032,3,"Goodwin, Miss. Jessie Allis",female,10,5,2,CA 2144,46.9,,S 143 | 1033,1,"Daniels, Miss. Sarah",female,33,0,0,113781,151.55,,S 144 | 1034,1,"Ryerson, Mr. Arthur Larned",male,61,1,3,PC 17608,262.375,B57 B59 B63 B66,C 145 | 1035,2,"Beauchamp, Mr. Henry James",male,28,0,0,244358,26,,S 146 | 1036,1,"Lindeberg-Lind, Mr. Erik Gustaf (Mr Edward Lingrey"")""",male,42,0,0,17475,26.55,,S 147 | 1037,3,"Vander Planke, Mr. Julius",male,31,3,0,345763,18,,S 148 | 1038,1,"Hilliard, Mr. Herbert Henry",male,,0,0,17463,51.8625,E46,S 149 | 1039,3,"Davies, Mr. Evan",male,22,0,0,SC/A4 23568,8.05,,S 150 | 1040,1,"Crafton, Mr. John Bertram",male,,0,0,113791,26.55,,S 151 | 1041,2,"Lahtinen, Rev. William",male,30,1,1,250651,26,,S 152 | 1042,1,"Earnshaw, Mrs. Boulton (Olive Potter)",female,23,0,1,11767,83.1583,C54,C 153 | 1043,3,"Matinoff, Mr. Nicola",male,,0,0,349255,7.8958,,C 154 | 1044,3,"Storey, Mr. Thomas",male,60.5,0,0,3701,,,S 155 | 1045,3,"Klasen, Mrs. (Hulda Kristina Eugenia Lofqvist)",female,36,0,2,350405,12.1833,,S 156 | 1046,3,"Asplund, Master. Filip Oscar",male,13,4,2,347077,31.3875,,S 157 | 1047,3,"Duquemin, Mr. Joseph",male,24,0,0,S.O./P.P. 752,7.55,,S 158 | 1048,1,"Bird, Miss. Ellen",female,29,0,0,PC 17483,221.7792,C97,S 159 | 1049,3,"Lundin, Miss. Olga Elida",female,23,0,0,347469,7.8542,,S 160 | 1050,1,"Borebank, Mr. John James",male,42,0,0,110489,26.55,D22,S 161 | 1051,3,"Peacock, Mrs. Benjamin (Edith Nile)",female,26,0,2,SOTON/O.Q. 3101315,13.775,,S 162 | 1052,3,"Smyth, Miss. Julia",female,,0,0,335432,7.7333,,Q 163 | 1053,3,"Touma, Master. Georges Youssef",male,7,1,1,2650,15.2458,,C 164 | 1054,2,"Wright, Miss. Marion",female,26,0,0,220844,13.5,,S 165 | 1055,3,"Pearce, Mr. Ernest",male,,0,0,343271,7,,S 166 | 1056,2,"Peruschitz, Rev. Joseph Maria",male,41,0,0,237393,13,,S 167 | 1057,3,"Kink-Heilmann, Mrs. Anton (Luise Heilmann)",female,26,1,1,315153,22.025,,S 168 | 1058,1,"Brandeis, Mr. Emil",male,48,0,0,PC 17591,50.4958,B10,C 169 | 1059,3,"Ford, Mr. Edward Watson",male,18,2,2,W./C. 6608,34.375,,S 170 | 1060,1,"Cassebeer, Mrs. Henry Arthur Jr (Eleanor Genevieve Fosdick)",female,,0,0,17770,27.7208,,C 171 | 1061,3,"Hellstrom, Miss. Hilda Maria",female,22,0,0,7548,8.9625,,S 172 | 1062,3,"Lithman, Mr. Simon",male,,0,0,S.O./P.P. 251,7.55,,S 173 | 1063,3,"Zakarian, Mr. Ortin",male,27,0,0,2670,7.225,,C 174 | 1064,3,"Dyker, Mr. Adolf Fredrik",male,23,1,0,347072,13.9,,S 175 | 1065,3,"Torfa, Mr. Assad",male,,0,0,2673,7.2292,,C 176 | 1066,3,"Asplund, Mr. Carl Oscar Vilhelm Gustafsson",male,40,1,5,347077,31.3875,,S 177 | 1067,2,"Brown, Miss. Edith Eileen",female,15,0,2,29750,39,,S 178 | 1068,2,"Sincock, Miss. Maude",female,20,0,0,C.A. 33112,36.75,,S 179 | 1069,1,"Stengel, Mr. Charles Emil Henry",male,54,1,0,11778,55.4417,C116,C 180 | 1070,2,"Becker, Mrs. Allen Oliver (Nellie E Baumgardner)",female,36,0,3,230136,39,F4,S 181 | 1071,1,"Compton, Mrs. Alexander Taylor (Mary Eliza Ingersoll)",female,64,0,2,PC 17756,83.1583,E45,C 182 | 1072,2,"McCrie, Mr. James Matthew",male,30,0,0,233478,13,,S 183 | 1073,1,"Compton, Mr. Alexander Taylor Jr",male,37,1,1,PC 17756,83.1583,E52,C 184 | 1074,1,"Marvin, Mrs. Daniel Warner (Mary Graham Carmichael Farquarson)",female,18,1,0,113773,53.1,D30,S 185 | 1075,3,"Lane, Mr. Patrick",male,,0,0,7935,7.75,,Q 186 | 1076,1,"Douglas, Mrs. Frederick Charles (Mary Helene Baxter)",female,27,1,1,PC 17558,247.5208,B58 B60,C 187 | 1077,2,"Maybery, Mr. Frank Hubert",male,40,0,0,239059,16,,S 188 | 1078,2,"Phillips, Miss. Alice Frances Louisa",female,21,0,1,S.O./P.P. 2,21,,S 189 | 1079,3,"Davies, Mr. Joseph",male,17,2,0,A/4 48873,8.05,,S 190 | 1080,3,"Sage, Miss. Ada",female,,8,2,CA. 2343,69.55,,S 191 | 1081,2,"Veal, Mr. James",male,40,0,0,28221,13,,S 192 | 1082,2,"Angle, Mr. William A",male,34,1,0,226875,26,,S 193 | 1083,1,"Salomon, Mr. Abraham L",male,,0,0,111163,26,,S 194 | 1084,3,"van Billiard, Master. Walter John",male,11.5,1,1,A/5. 851,14.5,,S 195 | 1085,2,"Lingane, Mr. John",male,61,0,0,235509,12.35,,Q 196 | 1086,2,"Drew, Master. Marshall Brines",male,8,0,2,28220,32.5,,S 197 | 1087,3,"Karlsson, Mr. Julius Konrad Eugen",male,33,0,0,347465,7.8542,,S 198 | 1088,1,"Spedden, Master. Robert Douglas",male,6,0,2,16966,134.5,E34,C 199 | 1089,3,"Nilsson, Miss. Berta Olivia",female,18,0,0,347066,7.775,,S 200 | 1090,2,"Baimbrigge, Mr. Charles Robert",male,23,0,0,C.A. 31030,10.5,,S 201 | 1091,3,"Rasmussen, Mrs. (Lena Jacobsen Solvang)",female,,0,0,65305,8.1125,,S 202 | 1092,3,"Murphy, Miss. Nora",female,,0,0,36568,15.5,,Q 203 | 1093,3,"Danbom, Master. Gilbert Sigvard Emanuel",male,0.33,0,2,347080,14.4,,S 204 | 1094,1,"Astor, Col. John Jacob",male,47,1,0,PC 17757,227.525,C62 C64,C 205 | 1095,2,"Quick, Miss. Winifred Vera",female,8,1,1,26360,26,,S 206 | 1096,2,"Andrew, Mr. Frank Thomas",male,25,0,0,C.A. 34050,10.5,,S 207 | 1097,1,"Omont, Mr. Alfred Fernand",male,,0,0,F.C. 12998,25.7417,,C 208 | 1098,3,"McGowan, Miss. Katherine",female,35,0,0,9232,7.75,,Q 209 | 1099,2,"Collett, Mr. Sidney C Stuart",male,24,0,0,28034,10.5,,S 210 | 1100,1,"Rosenbaum, Miss. Edith Louise",female,33,0,0,PC 17613,27.7208,A11,C 211 | 1101,3,"Delalic, Mr. Redjo",male,25,0,0,349250,7.8958,,S 212 | 1102,3,"Andersen, Mr. Albert Karvin",male,32,0,0,C 4001,22.525,,S 213 | 1103,3,"Finoli, Mr. Luigi",male,,0,0,SOTON/O.Q. 3101308,7.05,,S 214 | 1104,2,"Deacon, Mr. Percy William",male,17,0,0,S.O.C. 14879,73.5,,S 215 | 1105,2,"Howard, Mrs. Benjamin (Ellen Truelove Arman)",female,60,1,0,24065,26,,S 216 | 1106,3,"Andersson, Miss. Ida Augusta Margareta",female,38,4,2,347091,7.775,,S 217 | 1107,1,"Head, Mr. Christopher",male,42,0,0,113038,42.5,B11,S 218 | 1108,3,"Mahon, Miss. Bridget Delia",female,,0,0,330924,7.8792,,Q 219 | 1109,1,"Wick, Mr. George Dennick",male,57,1,1,36928,164.8667,,S 220 | 1110,1,"Widener, Mrs. George Dunton (Eleanor Elkins)",female,50,1,1,113503,211.5,C80,C 221 | 1111,3,"Thomson, Mr. Alexander Morrison",male,,0,0,32302,8.05,,S 222 | 1112,2,"Duran y More, Miss. Florentina",female,30,1,0,SC/PARIS 2148,13.8583,,C 223 | 1113,3,"Reynolds, Mr. Harold J",male,21,0,0,342684,8.05,,S 224 | 1114,2,"Cook, Mrs. (Selena Rogers)",female,22,0,0,W./C. 14266,10.5,F33,S 225 | 1115,3,"Karlsson, Mr. Einar Gervasius",male,21,0,0,350053,7.7958,,S 226 | 1116,1,"Candee, Mrs. Edward (Helen Churchill Hungerford)",female,53,0,0,PC 17606,27.4458,,C 227 | 1117,3,"Moubarek, Mrs. George (Omine Amenia"" Alexander)""",female,,0,2,2661,15.2458,,C 228 | 1118,3,"Asplund, Mr. Johan Charles",male,23,0,0,350054,7.7958,,S 229 | 1119,3,"McNeill, Miss. Bridget",female,,0,0,370368,7.75,,Q 230 | 1120,3,"Everett, Mr. Thomas James",male,40.5,0,0,C.A. 6212,15.1,,S 231 | 1121,2,"Hocking, Mr. Samuel James Metcalfe",male,36,0,0,242963,13,,S 232 | 1122,2,"Sweet, Mr. George Frederick",male,14,0,0,220845,65,,S 233 | 1123,1,"Willard, Miss. Constance",female,21,0,0,113795,26.55,,S 234 | 1124,3,"Wiklund, Mr. Karl Johan",male,21,1,0,3101266,6.4958,,S 235 | 1125,3,"Linehan, Mr. Michael",male,,0,0,330971,7.8792,,Q 236 | 1126,1,"Cumings, Mr. John Bradley",male,39,1,0,PC 17599,71.2833,C85,C 237 | 1127,3,"Vendel, Mr. Olof Edvin",male,20,0,0,350416,7.8542,,S 238 | 1128,1,"Warren, Mr. Frank Manley",male,64,1,0,110813,75.25,D37,C 239 | 1129,3,"Baccos, Mr. Raffull",male,20,0,0,2679,7.225,,C 240 | 1130,2,"Hiltunen, Miss. Marta",female,18,1,1,250650,13,,S 241 | 1131,1,"Douglas, Mrs. Walter Donald (Mahala Dutton)",female,48,1,0,PC 17761,106.425,C86,C 242 | 1132,1,"Lindstrom, Mrs. Carl Johan (Sigrid Posse)",female,55,0,0,112377,27.7208,,C 243 | 1133,2,"Christy, Mrs. (Alice Frances)",female,45,0,2,237789,30,,S 244 | 1134,1,"Spedden, Mr. Frederic Oakley",male,45,1,1,16966,134.5,E34,C 245 | 1135,3,"Hyman, Mr. Abraham",male,,0,0,3470,7.8875,,S 246 | 1136,3,"Johnston, Master. William Arthur Willie""""",male,,1,2,W./C. 6607,23.45,,S 247 | 1137,1,"Kenyon, Mr. Frederick R",male,41,1,0,17464,51.8625,D21,S 248 | 1138,2,"Karnes, Mrs. J Frank (Claire Bennett)",female,22,0,0,F.C.C. 13534,21,,S 249 | 1139,2,"Drew, Mr. James Vivian",male,42,1,1,28220,32.5,,S 250 | 1140,2,"Hold, Mrs. Stephen (Annie Margaret Hill)",female,29,1,0,26707,26,,S 251 | 1141,3,"Khalil, Mrs. Betros (Zahie Maria"" Elias)""",female,,1,0,2660,14.4542,,C 252 | 1142,2,"West, Miss. Barbara J",female,0.92,1,2,C.A. 34651,27.75,,S 253 | 1143,3,"Abrahamsson, Mr. Abraham August Johannes",male,20,0,0,SOTON/O2 3101284,7.925,,S 254 | 1144,1,"Clark, Mr. Walter Miller",male,27,1,0,13508,136.7792,C89,C 255 | 1145,3,"Salander, Mr. Karl Johan",male,24,0,0,7266,9.325,,S 256 | 1146,3,"Wenzel, Mr. Linhart",male,32.5,0,0,345775,9.5,,S 257 | 1147,3,"MacKay, Mr. George William",male,,0,0,C.A. 42795,7.55,,S 258 | 1148,3,"Mahon, Mr. John",male,,0,0,AQ/4 3130,7.75,,Q 259 | 1149,3,"Niklasson, Mr. Samuel",male,28,0,0,363611,8.05,,S 260 | 1150,2,"Bentham, Miss. Lilian W",female,19,0,0,28404,13,,S 261 | 1151,3,"Midtsjo, Mr. Karl Albert",male,21,0,0,345501,7.775,,S 262 | 1152,3,"de Messemaeker, Mr. Guillaume Joseph",male,36.5,1,0,345572,17.4,,S 263 | 1153,3,"Nilsson, Mr. August Ferdinand",male,21,0,0,350410,7.8542,,S 264 | 1154,2,"Wells, Mrs. Arthur Henry (Addie"" Dart Trevaskis)""",female,29,0,2,29103,23,,S 265 | 1155,3,"Klasen, Miss. Gertrud Emilia",female,1,1,1,350405,12.1833,,S 266 | 1156,2,"Portaluppi, Mr. Emilio Ilario Giuseppe",male,30,0,0,C.A. 34644,12.7375,,C 267 | 1157,3,"Lyntakoff, Mr. Stanko",male,,0,0,349235,7.8958,,S 268 | 1158,1,"Chisholm, Mr. Roderick Robert Crispin",male,,0,0,112051,0,,S 269 | 1159,3,"Warren, Mr. Charles William",male,,0,0,C.A. 49867,7.55,,S 270 | 1160,3,"Howard, Miss. May Elizabeth",female,,0,0,A. 2. 39186,8.05,,S 271 | 1161,3,"Pokrnic, Mr. Mate",male,17,0,0,315095,8.6625,,S 272 | 1162,1,"McCaffry, Mr. Thomas Francis",male,46,0,0,13050,75.2417,C6,C 273 | 1163,3,"Fox, Mr. Patrick",male,,0,0,368573,7.75,,Q 274 | 1164,1,"Clark, Mrs. Walter Miller (Virginia McDowell)",female,26,1,0,13508,136.7792,C89,C 275 | 1165,3,"Lennon, Miss. Mary",female,,1,0,370371,15.5,,Q 276 | 1166,3,"Saade, Mr. Jean Nassr",male,,0,0,2676,7.225,,C 277 | 1167,2,"Bryhl, Miss. Dagmar Jenny Ingeborg ",female,20,1,0,236853,26,,S 278 | 1168,2,"Parker, Mr. Clifford Richard",male,28,0,0,SC 14888,10.5,,S 279 | 1169,2,"Faunthorpe, Mr. Harry",male,40,1,0,2926,26,,S 280 | 1170,2,"Ware, Mr. John James",male,30,1,0,CA 31352,21,,S 281 | 1171,2,"Oxenham, Mr. Percy Thomas",male,22,0,0,W./C. 14260,10.5,,S 282 | 1172,3,"Oreskovic, Miss. Jelka",female,23,0,0,315085,8.6625,,S 283 | 1173,3,"Peacock, Master. Alfred Edward",male,0.75,1,1,SOTON/O.Q. 3101315,13.775,,S 284 | 1174,3,"Fleming, Miss. Honora",female,,0,0,364859,7.75,,Q 285 | 1175,3,"Touma, Miss. Maria Youssef",female,9,1,1,2650,15.2458,,C 286 | 1176,3,"Rosblom, Miss. Salli Helena",female,2,1,1,370129,20.2125,,S 287 | 1177,3,"Dennis, Mr. William",male,36,0,0,A/5 21175,7.25,,S 288 | 1178,3,"Franklin, Mr. Charles (Charles Fardon)",male,,0,0,SOTON/O.Q. 3101314,7.25,,S 289 | 1179,1,"Snyder, Mr. John Pillsbury",male,24,1,0,21228,82.2667,B45,S 290 | 1180,3,"Mardirosian, Mr. Sarkis",male,,0,0,2655,7.2292,F E46,C 291 | 1181,3,"Ford, Mr. Arthur",male,,0,0,A/5 1478,8.05,,S 292 | 1182,1,"Rheims, Mr. George Alexander Lucien",male,,0,0,PC 17607,39.6,,S 293 | 1183,3,"Daly, Miss. Margaret Marcella Maggie""""",female,30,0,0,382650,6.95,,Q 294 | 1184,3,"Nasr, Mr. Mustafa",male,,0,0,2652,7.2292,,C 295 | 1185,1,"Dodge, Dr. Washington",male,53,1,1,33638,81.8583,A34,S 296 | 1186,3,"Wittevrongel, Mr. Camille",male,36,0,0,345771,9.5,,S 297 | 1187,3,"Angheloff, Mr. Minko",male,26,0,0,349202,7.8958,,S 298 | 1188,2,"Laroche, Miss. Louise",female,1,1,2,SC/Paris 2123,41.5792,,C 299 | 1189,3,"Samaan, Mr. Hanna",male,,2,0,2662,21.6792,,C 300 | 1190,1,"Loring, Mr. Joseph Holland",male,30,0,0,113801,45.5,,S 301 | 1191,3,"Johansson, Mr. Nils",male,29,0,0,347467,7.8542,,S 302 | 1192,3,"Olsson, Mr. Oscar Wilhelm",male,32,0,0,347079,7.775,,S 303 | 1193,2,"Malachard, Mr. Noel",male,,0,0,237735,15.0458,D,C 304 | 1194,2,"Phillips, Mr. Escott Robert",male,43,0,1,S.O./P.P. 2,21,,S 305 | 1195,3,"Pokrnic, Mr. Tome",male,24,0,0,315092,8.6625,,S 306 | 1196,3,"McCarthy, Miss. Catherine Katie""""",female,,0,0,383123,7.75,,Q 307 | 1197,1,"Crosby, Mrs. Edward Gifford (Catherine Elizabeth Halstead)",female,64,1,1,112901,26.55,B26,S 308 | 1198,1,"Allison, Mr. Hudson Joshua Creighton",male,30,1,2,113781,151.55,C22 C26,S 309 | 1199,3,"Aks, Master. Philip Frank",male,0.83,0,1,392091,9.35,,S 310 | 1200,1,"Hays, Mr. Charles Melville",male,55,1,1,12749,93.5,B69,S 311 | 1201,3,"Hansen, Mrs. Claus Peter (Jennie L Howard)",female,45,1,0,350026,14.1083,,S 312 | 1202,3,"Cacic, Mr. Jego Grga",male,18,0,0,315091,8.6625,,S 313 | 1203,3,"Vartanian, Mr. David",male,22,0,0,2658,7.225,,C 314 | 1204,3,"Sadowitz, Mr. Harry",male,,0,0,LP 1588,7.575,,S 315 | 1205,3,"Carr, Miss. Jeannie",female,37,0,0,368364,7.75,,Q 316 | 1206,1,"White, Mrs. John Stuart (Ella Holmes)",female,55,0,0,PC 17760,135.6333,C32,C 317 | 1207,3,"Hagardon, Miss. Kate",female,17,0,0,AQ/3. 30631,7.7333,,Q 318 | 1208,1,"Spencer, Mr. William Augustus",male,57,1,0,PC 17569,146.5208,B78,C 319 | 1209,2,"Rogers, Mr. Reginald Harry",male,19,0,0,28004,10.5,,S 320 | 1210,3,"Jonsson, Mr. Nils Hilding",male,27,0,0,350408,7.8542,,S 321 | 1211,2,"Jefferys, Mr. Ernest Wilfred",male,22,2,0,C.A. 31029,31.5,,S 322 | 1212,3,"Andersson, Mr. Johan Samuel",male,26,0,0,347075,7.775,,S 323 | 1213,3,"Krekorian, Mr. Neshan",male,25,0,0,2654,7.2292,F E57,C 324 | 1214,2,"Nesson, Mr. Israel",male,26,0,0,244368,13,F2,S 325 | 1215,1,"Rowe, Mr. Alfred G",male,33,0,0,113790,26.55,,S 326 | 1216,1,"Kreuchen, Miss. Emilie",female,39,0,0,24160,211.3375,,S 327 | 1217,3,"Assam, Mr. Ali",male,23,0,0,SOTON/O.Q. 3101309,7.05,,S 328 | 1218,2,"Becker, Miss. Ruth Elizabeth",female,12,2,1,230136,39,F4,S 329 | 1219,1,"Rosenshine, Mr. George (Mr George Thorne"")""",male,46,0,0,PC 17585,79.2,,C 330 | 1220,2,"Clarke, Mr. Charles Valentine",male,29,1,0,2003,26,,S 331 | 1221,2,"Enander, Mr. Ingvar",male,21,0,0,236854,13,,S 332 | 1222,2,"Davies, Mrs. John Morgan (Elizabeth Agnes Mary White) ",female,48,0,2,C.A. 33112,36.75,,S 333 | 1223,1,"Dulles, Mr. William Crothers",male,39,0,0,PC 17580,29.7,A18,C 334 | 1224,3,"Thomas, Mr. Tannous",male,,0,0,2684,7.225,,C 335 | 1225,3,"Nakid, Mrs. Said (Waika Mary"" Mowad)""",female,19,1,1,2653,15.7417,,C 336 | 1226,3,"Cor, Mr. Ivan",male,27,0,0,349229,7.8958,,S 337 | 1227,1,"Maguire, Mr. John Edward",male,30,0,0,110469,26,C106,S 338 | 1228,2,"de Brito, Mr. Jose Joaquim",male,32,0,0,244360,13,,S 339 | 1229,3,"Elias, Mr. Joseph",male,39,0,2,2675,7.2292,,C 340 | 1230,2,"Denbury, Mr. Herbert",male,25,0,0,C.A. 31029,31.5,,S 341 | 1231,3,"Betros, Master. Seman",male,,0,0,2622,7.2292,,C 342 | 1232,2,"Fillbrook, Mr. Joseph Charles",male,18,0,0,C.A. 15185,10.5,,S 343 | 1233,3,"Lundstrom, Mr. Thure Edvin",male,32,0,0,350403,7.5792,,S 344 | 1234,3,"Sage, Mr. John George",male,,1,9,CA. 2343,69.55,,S 345 | 1235,1,"Cardeza, Mrs. James Warburton Martinez (Charlotte Wardle Drake)",female,58,0,1,PC 17755,512.3292,B51 B53 B55,C 346 | 1236,3,"van Billiard, Master. James William",male,,1,1,A/5. 851,14.5,,S 347 | 1237,3,"Abelseth, Miss. Karen Marie",female,16,0,0,348125,7.65,,S 348 | 1238,2,"Botsford, Mr. William Hull",male,26,0,0,237670,13,,S 349 | 1239,3,"Whabee, Mrs. George Joseph (Shawneene Abi-Saab)",female,38,0,0,2688,7.2292,,C 350 | 1240,2,"Giles, Mr. Ralph",male,24,0,0,248726,13.5,,S 351 | 1241,2,"Walcroft, Miss. Nellie",female,31,0,0,F.C.C. 13528,21,,S 352 | 1242,1,"Greenfield, Mrs. Leo David (Blanche Strouse)",female,45,0,1,PC 17759,63.3583,D10 D12,C 353 | 1243,2,"Stokes, Mr. Philip Joseph",male,25,0,0,F.C.C. 13540,10.5,,S 354 | 1244,2,"Dibden, Mr. William",male,18,0,0,S.O.C. 14879,73.5,,S 355 | 1245,2,"Herman, Mr. Samuel",male,49,1,2,220845,65,,S 356 | 1246,3,"Dean, Miss. Elizabeth Gladys Millvina""""",female,0.17,1,2,C.A. 2315,20.575,,S 357 | 1247,1,"Julian, Mr. Henry Forbes",male,50,0,0,113044,26,E60,S 358 | 1248,1,"Brown, Mrs. John Murray (Caroline Lane Lamson)",female,59,2,0,11769,51.4792,C101,S 359 | 1249,3,"Lockyer, Mr. Edward",male,,0,0,1222,7.8792,,S 360 | 1250,3,"O'Keefe, Mr. Patrick",male,,0,0,368402,7.75,,Q 361 | 1251,3,"Lindell, Mrs. Edvard Bengtsson (Elin Gerda Persson)",female,30,1,0,349910,15.55,,S 362 | 1252,3,"Sage, Master. William Henry",male,14.5,8,2,CA. 2343,69.55,,S 363 | 1253,2,"Mallet, Mrs. Albert (Antoinette Magnin)",female,24,1,1,S.C./PARIS 2079,37.0042,,C 364 | 1254,2,"Ware, Mrs. John James (Florence Louise Long)",female,31,0,0,CA 31352,21,,S 365 | 1255,3,"Strilic, Mr. Ivan",male,27,0,0,315083,8.6625,,S 366 | 1256,1,"Harder, Mrs. George Achilles (Dorothy Annan)",female,25,1,0,11765,55.4417,E50,C 367 | 1257,3,"Sage, Mrs. John (Annie Bullen)",female,,1,9,CA. 2343,69.55,,S 368 | 1258,3,"Caram, Mr. Joseph",male,,1,0,2689,14.4583,,C 369 | 1259,3,"Riihivouri, Miss. Susanna Juhantytar Sanni""""",female,22,0,0,3101295,39.6875,,S 370 | 1260,1,"Gibson, Mrs. Leonard (Pauline C Boeson)",female,45,0,1,112378,59.4,,C 371 | 1261,2,"Pallas y Castello, Mr. Emilio",male,29,0,0,SC/PARIS 2147,13.8583,,C 372 | 1262,2,"Giles, Mr. Edgar",male,21,1,0,28133,11.5,,S 373 | 1263,1,"Wilson, Miss. Helen Alice",female,31,0,0,16966,134.5,E39 E41,C 374 | 1264,1,"Ismay, Mr. Joseph Bruce",male,49,0,0,112058,0,B52 B54 B56,S 375 | 1265,2,"Harbeck, Mr. William H",male,44,0,0,248746,13,,S 376 | 1266,1,"Dodge, Mrs. Washington (Ruth Vidaver)",female,54,1,1,33638,81.8583,A34,S 377 | 1267,1,"Bowen, Miss. Grace Scott",female,45,0,0,PC 17608,262.375,,C 378 | 1268,3,"Kink, Miss. Maria",female,22,2,0,315152,8.6625,,S 379 | 1269,2,"Cotterill, Mr. Henry Harry""""",male,21,0,0,29107,11.5,,S 380 | 1270,1,"Hipkins, Mr. William Edward",male,55,0,0,680,50,C39,S 381 | 1271,3,"Asplund, Master. Carl Edgar",male,5,4,2,347077,31.3875,,S 382 | 1272,3,"O'Connor, Mr. Patrick",male,,0,0,366713,7.75,,Q 383 | 1273,3,"Foley, Mr. Joseph",male,26,0,0,330910,7.8792,,Q 384 | 1274,3,"Risien, Mrs. Samuel (Emma)",female,,0,0,364498,14.5,,S 385 | 1275,3,"McNamee, Mrs. Neal (Eileen O'Leary)",female,19,1,0,376566,16.1,,S 386 | 1276,2,"Wheeler, Mr. Edwin Frederick""""",male,,0,0,SC/PARIS 2159,12.875,,S 387 | 1277,2,"Herman, Miss. Kate",female,24,1,2,220845,65,,S 388 | 1278,3,"Aronsson, Mr. Ernst Axel Algot",male,24,0,0,349911,7.775,,S 389 | 1279,2,"Ashby, Mr. John",male,57,0,0,244346,13,,S 390 | 1280,3,"Canavan, Mr. Patrick",male,21,0,0,364858,7.75,,Q 391 | 1281,3,"Palsson, Master. Paul Folke",male,6,3,1,349909,21.075,,S 392 | 1282,1,"Payne, Mr. Vivian Ponsonby",male,23,0,0,12749,93.5,B24,S 393 | 1283,1,"Lines, Mrs. Ernest H (Elizabeth Lindsey James)",female,51,0,1,PC 17592,39.4,D28,S 394 | 1284,3,"Abbott, Master. Eugene Joseph",male,13,0,2,C.A. 2673,20.25,,S 395 | 1285,2,"Gilbert, Mr. William",male,47,0,0,C.A. 30769,10.5,,S 396 | 1286,3,"Kink-Heilmann, Mr. Anton",male,29,3,1,315153,22.025,,S 397 | 1287,1,"Smith, Mrs. Lucien Philip (Mary Eloise Hughes)",female,18,1,0,13695,60,C31,S 398 | 1288,3,"Colbert, Mr. Patrick",male,24,0,0,371109,7.25,,Q 399 | 1289,1,"Frolicher-Stehli, Mrs. Maxmillian (Margaretha Emerentia Stehli)",female,48,1,1,13567,79.2,B41,C 400 | 1290,3,"Larsson-Rondberg, Mr. Edvard A",male,22,0,0,347065,7.775,,S 401 | 1291,3,"Conlon, Mr. Thomas Henry",male,31,0,0,21332,7.7333,,Q 402 | 1292,1,"Bonnell, Miss. Caroline",female,30,0,0,36928,164.8667,C7,S 403 | 1293,2,"Gale, Mr. Harry",male,38,1,0,28664,21,,S 404 | 1294,1,"Gibson, Miss. Dorothy Winifred",female,22,0,1,112378,59.4,,C 405 | 1295,1,"Carrau, Mr. Jose Pedro",male,17,0,0,113059,47.1,,S 406 | 1296,1,"Frauenthal, Mr. Isaac Gerald",male,43,1,0,17765,27.7208,D40,C 407 | 1297,2,"Nourney, Mr. Alfred (Baron von Drachstedt"")""",male,20,0,0,SC/PARIS 2166,13.8625,D38,C 408 | 1298,2,"Ware, Mr. William Jeffery",male,23,1,0,28666,10.5,,S 409 | 1299,1,"Widener, Mr. George Dunton",male,50,1,1,113503,211.5,C80,C 410 | 1300,3,"Riordan, Miss. Johanna Hannah""""",female,,0,0,334915,7.7208,,Q 411 | 1301,3,"Peacock, Miss. Treasteall",female,3,1,1,SOTON/O.Q. 3101315,13.775,,S 412 | 1302,3,"Naughton, Miss. Hannah",female,,0,0,365237,7.75,,Q 413 | 1303,1,"Minahan, Mrs. William Edward (Lillian E Thorpe)",female,37,1,0,19928,90,C78,Q 414 | 1304,3,"Henriksson, Miss. Jenny Lovisa",female,28,0,0,347086,7.775,,S 415 | 1305,3,"Spector, Mr. Woolf",male,,0,0,A.5. 3236,8.05,,S 416 | 1306,1,"Oliva y Ocana, Dona. Fermina",female,39,0,0,PC 17758,108.9,C105,C 417 | 1307,3,"Saether, Mr. Simon Sivertsen",male,38.5,0,0,SOTON/O.Q. 3101262,7.25,,S 418 | 1308,3,"Ware, Mr. Frederick",male,,0,0,359309,8.05,,S 419 | 1309,3,"Peter, Master. Michael J",male,,1,1,2668,22.3583,,C 420 | -------------------------------------------------------------------------------- /output_plots/Axis.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Axis.jpg -------------------------------------------------------------------------------- /output_plots/Bar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Bar.jpg -------------------------------------------------------------------------------- /output_plots/Figure_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Figure_1.png -------------------------------------------------------------------------------- /output_plots/Figure_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Figure_2.png -------------------------------------------------------------------------------- /output_plots/Figure_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Figure_3.png -------------------------------------------------------------------------------- /output_plots/Graph.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Graph.jpg -------------------------------------------------------------------------------- /output_plots/Histogram equalisation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Histogram equalisation.png -------------------------------------------------------------------------------- /output_plots/Histogram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Histogram.jpg -------------------------------------------------------------------------------- /output_plots/Normal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Normal.jpg -------------------------------------------------------------------------------- /output_plots/PCA1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/PCA1.jpg -------------------------------------------------------------------------------- /output_plots/PieChart.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/PieChart.jpg -------------------------------------------------------------------------------- /output_plots/Plot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Plot.jpg -------------------------------------------------------------------------------- /output_plots/Scatter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Scatter.jpg -------------------------------------------------------------------------------- /output_plots/Scatter2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Scatter2.jpg -------------------------------------------------------------------------------- /output_plots/Subplot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Subplot.jpg -------------------------------------------------------------------------------- /output_plots/Visualization.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Visualization.jpg -------------------------------------------------------------------------------- /output_plots/Visualization2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Visualization2.jpg -------------------------------------------------------------------------------- /output_plots/Volatge-vs-Current.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Volatge-vs-Current.png -------------------------------------------------------------------------------- /output_plots/Ylabel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/Ylabel.jpg -------------------------------------------------------------------------------- /output_plots/result.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debaditya-Som/Data-Science-Codes/dbbec3ff757544451be9389c5057c0214eaac335/output_plots/result.jpg -------------------------------------------------------------------------------- /pca.py: -------------------------------------------------------------------------------- 1 | #PCA - PRINCIPAL COMPONENT ANALYSIS is dimestionality reduction method that is often used to reduce the dimensionality of large data sets by trnasforming 2 | # a large set of variables into a smaller one that still contains most of the information in the large set 3 | #in this technique the variablrs are trnasformed into a new set of variables, which are linear comnbination of original variables. This new set of variables are know as principal components. 4 | # The first principl component captures the most variation in data, but the second pricpal component captures the maximum variance, that is orthogonal to the first principal componenet and so on. 5 | 6 | import numpy as np 7 | import pandas as pd 8 | import matplotlib.pyplot as plt 9 | from sklearn.decomposition import PCA 10 | from sklearn.preprocessing import StandardScaler 11 | 12 | df = pd.read_csv('iris.csv') 13 | df.Species.replace({'Iris-setosa':0,'Iris-versicolor':1,'Iris-virginica':2},inplace= True) 14 | df.head() 15 | 16 | features = ['SepalLengthCm','SepalWidthCm','PetalLengthCm','PetalWidthCm'] 17 | x = df.loc[:, features].values 18 | y = df.loc[:,['Species']].values 19 | 20 | x = StandardScaler().fit_transform(x) 21 | pd.DataFrame(data=x,columns=features).head() 22 | 23 | pca = PCA() 24 | X_new = pca.fit_transform(x) 25 | explained_variance = pca.explained_variance_ratio_ #VARIANCE 26 | 27 | pca = PCA(n_components=2) 28 | principalComponent = pca.fit_transform(x) 29 | principalDF = pd.DataFrame(data= principalComponent, columns=['PC1','PC2']) 30 | -------------------------------------------------------------------------------- /regression/multipleregression.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from pandas import DataFrame 3 | from sklearn import linear_model 4 | import statsmodels.api as sm 5 | df = DataFrame(pd.read_csv('stock.csv')) 6 | print(df) 7 | X = df[['Interest_Rate','Unemployment_Rate']] 8 | Y = df ['Stock_Index_Price'] 9 | regr = linear_model.LinearRegression() 10 | regr.fit(X,Y) 11 | print('Intercept value: \n', regr.intercept_) 12 | print('Coefficient value: \n', regr.coef_) 13 | New_Interest_Rate= 2.75 14 | New_Unemployment_Rate = 5.3 15 | print('predicted stock index price: \n', regr.predict([[New_Interest_Rate,New_Unemployment_Rate]])) 16 | r_sq = regr.score(X,Y) 17 | print("Co-efficient of determintion(R-squared)",{r_sq}) 18 | X = sm.add_constant(X) 19 | model = sm.OLS(Y,X).fit() 20 | adjusted_r_sq = model.rsquared_adj 21 | print("Adjusted r squared:",adjusted_r_sq) 22 | -------------------------------------------------------------------------------- /regression/regression.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from pandas import DataFrame 3 | from sklearn import linear_model 4 | import statsmodels.api as sm 5 | 6 | df = DataFrame(pd.read_csv("stock.csv")) 7 | # Here we have 1 variable for simple regression. 8 | X = df[['Interest_Rate']] 9 | Y = df['Stock_Index_Price'] 10 | # Model fitting with sklearn 11 | regr = linear_model.LinearRegression() 12 | regr.fit(X,Y) 13 | 14 | print('Intercept value: \n', regr.intercept_) 15 | print('Coefficient value: \n', regr.coef_) 16 | 17 | # Creating a scatter plot with a regression line 18 | import seaborn as sn 19 | import matplotlib.pyplot as plt 20 | 21 | sn.regplot(x= 'Interest_Rate', y='Stock_Index_Price', data= df) 22 | plt.title('Scatter plot for Stock_Index_Price versus Interest_Rate with a regression line',y=1.05) 23 | plt.xlabel('Interest_Rate') 24 | plt.ylabel('Stock_Index_Price') 25 | plt.show() 26 | y_pred = regr.predict(X) 27 | # Convert y_pred to a DataFrame 28 | df1 = pd.DataFrame({'Predicted Stock Index Price': y_pred}) 29 | 30 | print(df1) # Print the DataFrame 31 | 32 | #print(y_pred) if required 33 | # Prediction with sklearn 34 | New_Interest_Rate = 2.90 35 | print('Predicted Stock Index Price: \n', regr.predict([[New_Interest_Rate]])) 36 | numeric_col = ['Interest_Rate', 'Stock_Index_Price'] 37 | df[numeric_col].corr() 38 | X = sm.add_constant(X) # (1) 39 | model = sm.OLS(Y, X).fit() # (2) 40 | print_model = model.summary() # (3) 41 | print(print_model) # (4) 42 | 43 | # R-squared: 0.876 44 | # Adj. R-squared: 0.870 45 | # Coefficient Standard error P values 46 | # const -99.4643 95.210 0.308 47 | # Interest_Rate 564.2039 45.317 0.000 48 | -------------------------------------------------------------------------------- /tkinter/adding_buttons.py: -------------------------------------------------------------------------------- 1 | 2 | from tkinter import * 3 | 4 | #this command adds a label in the screen 5 | def click(): 6 | global screen 7 | lbl = Label(screen, text = "You clicked the button") 8 | lbl.pack() 9 | return 10 | 11 | screen = Tk() 12 | 13 | #setting screen dimensions 14 | screen.geometry("400x400") 15 | 16 | #changing the bacground color 17 | screen.config(bg = "#ff0120") 18 | 19 | #Adding button 20 | btn = Button(screen, text = "Click Me!", bg="#ffff00", command = click) #click function is invoked when the button is clicked 21 | 22 | #packing the button in the screen 23 | btn.pack() 24 | 25 | screen.mainloop() -------------------------------------------------------------------------------- /tkinter/first_gui_program.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | # creating a GUI Screen 4 | screen = Tk() 5 | 6 | # A label that contains text 7 | label = Label(screen, text = "Hello world!", padx = 10, pady = 20) 8 | 9 | # Packing the label into the GUI screen 10 | label.pack() 11 | 12 | # Running the mainloop function to display the GUI screen continuously in the screen 13 | screen.mainloop() -------------------------------------------------------------------------------- /tkinter/gui tic tac toe.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | def newgame(): 3 | global move,turn 4 | 5 | r1=['','',''] 6 | r2=['','',''] 7 | r3=['','',''] 8 | 9 | def empty(): 10 | screen.destroy() 11 | newgame() 12 | 13 | def gameover(): 14 | btn1.config(command=empty) 15 | btn2.config(command=empty) 16 | btn3.config(command=empty) 17 | btn4.config(command=empty) 18 | btn5.config(command=empty) 19 | btn6.config(command=empty) 20 | btn7.config(command=empty) 21 | btn8.config(command=empty) 22 | btn9.config(command=empty) 23 | screen.geometry('400x450+400+200') 24 | if r1[0] != '' and r1[0] == r1[1] and r1[0] == r1[2] or r1[2]!='' and r1[2]==r1[0] and r1[2]==r1[1]: 25 | b= r1[0] 26 | movelbl.config(text='%s is the winner' % b) 27 | btn1.config(bg='green') 28 | btn2.config(bg='green') 29 | btn3.config(bg='green') 30 | btn10.grid(row=3,column=0, columnspan=3, ipadx=24, ipady = 5) 31 | 32 | 33 | elif r2[0] != '' and r2[0] == r2[1] and r2[0] == r2[2] or r2[2]!='' and r2[2]==r2[0] and r2[2]==r2[1] : 34 | b = r2[0] 35 | movelbl.config(text='%s is the winner' % b) 36 | btn4.config(bg='green') 37 | btn5.config(bg='green') 38 | btn6.config(bg='green') 39 | btn10.grid(row=3,column=0, columnspan=3, ipadx=24, ipady = 5) 40 | elif r3[0] != '' and r3[0] == r3[1] and r3[0] == r3[2] or r3[2]!='' and r3[2]==r3[0] and r3[2]==r3[1]: #3B 41 | b = r3[0] 42 | movelbl.config(text='%s is the winner' % b) 43 | btn7.config(bg='green') 44 | btn8.config(bg='green') 45 | btn9.config(bg='green') 46 | btn10.grid(row=3,column=0, columnspan=3, ipadx=24, ipady = 5) 47 | elif r1[0] != '' and r1[0] == r2[0] and r1[0] == r3[0] or r3[0]!='' and r3[0]==r1[0] and r3[0]==r2[0]: 48 | b = r1[0] 49 | movelbl.config(text='%s is the winner' % b) 50 | btn1.config(bg='green') 51 | btn4.config(bg='green') 52 | btn7.config(bg='green') 53 | btn10.grid(row=3,column=0, columnspan=3, ipadx=24, ipady = 5) 54 | elif r1[1] != '' and r1[1] == r2[1] and r1[1] == r3[1] or r3[1]!='' and r3[1]==r1[1] and r3[1]==r2[1]: 55 | b = r1[1] 56 | movelbl.config(text='%s is the winner' % b) 57 | btn2.config(bg='green') 58 | btn5.config(bg='green') 59 | btn8.config(bg='green') 60 | btn10.grid(row=3,column=0, columnspan=3, ipadx=24, ipady = 5) 61 | elif r1[2] != '' and r1[2] == r2[2] and r1[2] == r3[2] or r3[2]!='' and r3[2]==r1[2] and r3[2]==r2[2]: 62 | b = r1[2] 63 | movelbl.config(text='%s is the winner' % b) 64 | btn3.config(bg='green') 65 | btn6.config(bg='green') 66 | btn9.config(bg='green') 67 | btn10.grid(row=3,column=0, columnspan=3, ipadx=24, ipady = 5) 68 | elif r1[0] != '' and r1[0] == r2[1] and r1[0] == r3[2] or r3[2]!='' and r3[2]==r1[0] and r3[2]==r2[1]: 69 | b = r1[0] 70 | movelbl.config(text='%s is the winner' % b) 71 | btn1.config(bg='green') 72 | btn5.config(bg='green') 73 | btn9.config(bg='green') 74 | btn10.grid(row=3,column=0, columnspan=3, ipadx=24, ipady = 5) 75 | elif r1[2] != '' and r1[2] == r2[1] and r1[2] == r3[0] or r3[0]!='' and r3[0]==r2[1] and r3[0]==r1[2]: 76 | b = r1[2] 77 | movelbl.config(text='%s is the winner' % b) 78 | btn3.config(bg='green') 79 | btn5.config(bg='green') 80 | btn7.config(bg='green') 81 | btn10.grid(row=3,column=0, columnspan=3, ipadx=24, ipady = 5) 82 | 83 | def win(): 84 | if r1[0]!='' and r1[0]==r1[1] and r1[0]==r1[2]: #1A #horizontal wins 85 | return True 86 | if r1[2]!='' and r1[2]==r1[0] and r1[2]==r1[1]: #1B 87 | return True 88 | if r2[0]!='' and r2[0]==r2[1] and r2[0]==r2[2]: #2A 89 | return True 90 | if r2[2]!='' and r2[2]==r2[0] and r2[2]==r2[1]: #2B 91 | return True 92 | if r3[0]!='' and r3[0]==r3[1] and r3[0]==r3[2]: #3A 93 | return True 94 | if r3[2]!='' and r3[2]==r3[0] and r3[2]==r3[1]: #3B 95 | return True 96 | if r1[0]!='' and r1[0]==r2[0] and r1[0]==r3[0]: #4A #vertical wins 97 | return True 98 | if r3[0]!='' and r3[0]==r1[0] and r3[0]==r2[0]: #4B 99 | return True 100 | if r1[1]!='' and r1[1] == r2[1] and r1[1] == r3[1]: #5A 101 | return True 102 | if r3[1]!='' and r3[1]==r1[1] and r3[1]==r2[1]: #5B 103 | return True 104 | if r1[2]!='' and r1[2] == r2[2] and r1[2] == r3[2]: #6A 105 | return True 106 | if r3[2]!='' and r3[2]==r1[2] and r3[2]==r2[2]: #6B 107 | return True 108 | if r1[0]!='' and r1[0]==r2[1] and r1[0]==r3[2]: #7A # diagonal wins 109 | return True 110 | if r3[2]!='' and r3[2]==r1[0] and r3[2]==r2[1]: #7B 111 | return True 112 | if r3[0]!='' and r3[0]==r2[1] and r3[0]==r1[2]: #8A 113 | return True 114 | if r1[2]!='' and r1[2]==r2[1] and r1[2]==r3[0]: #8B 115 | return True 116 | else: 117 | return False 118 | def cl1(): 119 | if len(move)%2==0: 120 | btn1.config(text='O') 121 | if r1[0]=='': 122 | r1[0]='0' 123 | b = win() 124 | if b==True: 125 | gameover() 126 | else: 127 | btn1.config(bg='blue') 128 | btn2.config(bg='blue') 129 | btn3.config(bg='blue') 130 | btn4.config(bg='blue') 131 | btn5.config(bg='blue') 132 | btn6.config(bg='blue') 133 | btn7.config(bg='blue') 134 | btn8.config(bg='blue') 135 | btn9.config(bg='blue') 136 | move.pop() 137 | movelbl.config(text=turn[0],bg='blue') 138 | else: 139 | btn1.config(text='X') 140 | if r1[0] == '': 141 | r1[0] = 'X' 142 | b = win() 143 | if b == True: 144 | gameover() 145 | else: 146 | btn1.config(bg='red') 147 | btn2.config(bg='red') 148 | btn3.config(bg='red') 149 | btn4.config(bg='red') 150 | btn5.config(bg='red') 151 | btn6.config(bg='red') 152 | btn7.config(bg='red') 153 | btn8.config(bg='red') 154 | btn9.config(bg='red') 155 | move.pop() 156 | movelbl.config(text=turn[1],bg='red') 157 | btn1.config(command=empty) 158 | def cl2(): 159 | if len(move)%2==0: 160 | btn2.config(text='O') 161 | if r1[1]=='': 162 | r1[1]='0' 163 | b = win() 164 | if b==True: 165 | gameover() 166 | else: 167 | btn1.config(bg='blue') 168 | btn2.config(bg='blue') 169 | btn3.config(bg='blue') 170 | btn4.config(bg='blue') 171 | btn5.config(bg='blue') 172 | btn6.config(bg='blue') 173 | btn7.config(bg='blue') 174 | btn8.config(bg='blue') 175 | btn9.config(bg='blue') 176 | move.pop() 177 | movelbl.config(text=turn[0],bg='blue') 178 | else: 179 | btn2.config(text='X') 180 | if r1[1] == '': 181 | r1[1] = 'X' 182 | b = win() 183 | if b == True: 184 | gameover() 185 | else: 186 | btn1.config(bg='red') 187 | btn2.config(bg='red') 188 | btn3.config(bg='red') 189 | btn4.config(bg='red') 190 | btn5.config(bg='red') 191 | btn6.config(bg='red') 192 | btn7.config(bg='red') 193 | btn8.config(bg='red') 194 | btn9.config(bg='red') 195 | move.pop() 196 | movelbl.config(text=turn[1],bg='red') 197 | btn2.config(command=empty) 198 | def cl3(): 199 | if len(move)%2==0: 200 | btn3.config(text='O') 201 | if r1[2]=='': 202 | r1[2]='0' 203 | b = win() 204 | if b==True: 205 | gameover() 206 | else: 207 | btn1.config(bg='blue') 208 | btn2.config(bg='blue') 209 | btn3.config(bg='blue') 210 | btn4.config(bg='blue') 211 | btn5.config(bg='blue') 212 | btn6.config(bg='blue') 213 | btn7.config(bg='blue') 214 | btn8.config(bg='blue') 215 | btn9.config(bg='blue') 216 | move.pop() 217 | movelbl.config(text=turn[0],bg='blue') 218 | else: 219 | btn3.config(text='X') 220 | if r1[2] == '': 221 | r1[2] = 'X' 222 | b = win() 223 | if b == True: 224 | gameover() 225 | else: 226 | btn1.config(bg='red') 227 | btn2.config(bg='red') 228 | btn3.config(bg='red') 229 | btn4.config(bg='red') 230 | btn5.config(bg='red') 231 | btn6.config(bg='red') 232 | btn7.config(bg='red') 233 | btn8.config(bg='red') 234 | btn9.config(bg='red') 235 | move.pop() 236 | movelbl.config(text=turn[1],bg='red') 237 | btn3.config(command=empty) 238 | def cl4(): 239 | if len(move)%2==0: 240 | btn4.config(text='O') 241 | if r2[0]=='': 242 | r2[0]='0' 243 | b = win() 244 | if b==True: 245 | gameover() 246 | else: 247 | btn1.config(bg='blue') 248 | btn2.config(bg='blue') 249 | btn3.config(bg='blue') 250 | btn4.config(bg='blue') 251 | btn5.config(bg='blue') 252 | btn6.config(bg='blue') 253 | btn7.config(bg='blue') 254 | btn8.config(bg='blue') 255 | btn9.config(bg='blue') 256 | move.pop() 257 | movelbl.config(text=turn[0],bg='blue') 258 | else: 259 | btn4.config(text='X') 260 | if r2[0] == '': 261 | r2[0] = 'X' 262 | b = win() 263 | if b == True: 264 | gameover() 265 | else: 266 | btn1.config(bg='red') 267 | btn2.config(bg='red') 268 | btn3.config(bg='red') 269 | btn4.config(bg='red') 270 | btn5.config(bg='red') 271 | btn6.config(bg='red') 272 | btn7.config(bg='red') 273 | btn8.config(bg='red') 274 | btn9.config(bg='red') 275 | move.pop() 276 | movelbl.config(text=turn[1],bg='red') 277 | btn4.config(command=empty) 278 | def cl5(): 279 | if len(move)%2==0: 280 | btn5.config(text='O') 281 | if r2[1]=='': 282 | r2[1]='0' 283 | b = win() 284 | if b==True: 285 | gameover() 286 | else: 287 | btn1.config(bg='blue') 288 | btn2.config(bg='blue') 289 | btn3.config(bg='blue') 290 | btn4.config(bg='blue') 291 | btn5.config(bg='blue') 292 | btn6.config(bg='blue') 293 | btn7.config(bg='blue') 294 | btn8.config(bg='blue') 295 | btn9.config(bg='blue') 296 | move.pop() 297 | movelbl.config(text=turn[0],bg='blue') 298 | else: 299 | btn5.config(text='X') 300 | if r2[1] == '': 301 | r2[1] = 'X' 302 | b = win() 303 | if b == True: 304 | gameover() 305 | else: 306 | btn1.config(bg='red') 307 | btn2.config(bg='red') 308 | btn3.config(bg='red') 309 | btn4.config(bg='red') 310 | btn5.config(bg='red') 311 | btn6.config(bg='red') 312 | btn7.config(bg='red') 313 | btn8.config(bg='red') 314 | btn9.config(bg='red') 315 | move.pop() 316 | movelbl.config(text=turn[1],bg='red') 317 | btn5.config(command=empty) 318 | 319 | def cl6(): 320 | if len(move)%2==0: 321 | btn6.config(text='O') 322 | if r2[2]=='': 323 | r2[2]='0' 324 | b = win() 325 | if b==True: 326 | gameover() 327 | else: 328 | btn1.config(bg='blue') 329 | btn2.config(bg='blue') 330 | btn3.config(bg='blue') 331 | btn4.config(bg='blue') 332 | btn5.config(bg='blue') 333 | btn6.config(bg='blue') 334 | btn7.config(bg='blue') 335 | btn8.config(bg='blue') 336 | btn9.config(bg='blue') 337 | move.pop() 338 | movelbl.config(text=turn[0],bg='blue') 339 | else: 340 | btn6.config(text='X') 341 | if r2[2] == '': 342 | r2[2] = 'X' 343 | b = win() 344 | if b == True: 345 | gameover() 346 | else: 347 | btn1.config(bg='red') 348 | btn2.config(bg='red') 349 | btn3.config(bg='red') 350 | btn4.config(bg='red') 351 | btn5.config(bg='red') 352 | btn6.config(bg='red') 353 | btn7.config(bg='red') 354 | btn8.config(bg='red') 355 | btn9.config(bg='red') 356 | move.pop() 357 | movelbl.config(text=turn[1],bg='red') 358 | btn6.config(command=empty) 359 | def cl7(): 360 | if len(move)%2==0: 361 | btn7.config(text='O') 362 | if r3[0]=='': 363 | r3[0]='0' 364 | b = win() 365 | if b==True: 366 | gameover() 367 | else: 368 | btn1.config(bg='blue') 369 | btn2.config(bg='blue') 370 | btn3.config(bg='blue') 371 | btn4.config(bg='blue') 372 | btn5.config(bg='blue') 373 | btn6.config(bg='blue') 374 | btn7.config(bg='blue') 375 | btn8.config(bg='blue') 376 | btn9.config(bg='blue') 377 | move.pop() 378 | movelbl.config(text=turn[0],bg='blue') 379 | else: 380 | btn7.config(text='X') 381 | if r3[0] == '': 382 | r3[0] = 'X' 383 | b = win() 384 | if b == True: 385 | gameover() 386 | else: 387 | btn1.config(bg='red') 388 | btn2.config(bg='red') 389 | btn3.config(bg='red') 390 | btn4.config(bg='red') 391 | btn5.config(bg='red') 392 | btn6.config(bg='red') 393 | btn7.config(bg='red') 394 | btn8.config(bg='red') 395 | btn9.config(bg='red') 396 | move.pop() 397 | movelbl.config(text=turn[1],bg='red') 398 | btn7.config(command=empty) 399 | def cl8(): 400 | if len(move)%2==0: 401 | btn8.config(text='O') 402 | if r3[1]=='': 403 | r3[1]='0' 404 | b = win() 405 | if b==True: 406 | gameover() 407 | else: 408 | btn1.config(bg='blue') 409 | btn2.config(bg='blue') 410 | btn3.config(bg='blue') 411 | btn4.config(bg='blue') 412 | btn5.config(bg='blue') 413 | btn6.config(bg='blue') 414 | btn7.config(bg='blue') 415 | btn8.config(bg='blue') 416 | btn9.config(bg='blue') 417 | move.pop() 418 | movelbl.config(text=turn[0],bg='blue') 419 | else: 420 | btn8.config(text='X') 421 | if r3[1] == '': 422 | r3[1] = 'X' 423 | b = win() 424 | if b == True: 425 | gameover() 426 | else: 427 | btn1.config(bg='red') 428 | btn2.config(bg='red') 429 | btn3.config(bg='red') 430 | btn4.config(bg='red') 431 | btn5.config(bg='red') 432 | btn6.config(bg='red') 433 | btn7.config(bg='red') 434 | btn8.config(bg='red') 435 | btn9.config(bg='red') 436 | move.pop() 437 | movelbl.config(text=turn[1],bg='red') 438 | btn8.config(command=empty) 439 | def cl9(): 440 | if len(move)%2==0: 441 | btn9.config(text='O') 442 | if r3[2]=='': 443 | r3[2]='0' 444 | b = win() 445 | if b==True: 446 | gameover() 447 | else: 448 | btn1.config(bg='blue') 449 | btn2.config(bg='blue') 450 | btn3.config(bg='blue') 451 | btn4.config(bg='blue') 452 | btn5.config(bg='blue') 453 | btn6.config(bg='blue') 454 | btn7.config(bg='blue') 455 | btn8.config(bg='blue') 456 | btn9.config(bg='blue') 457 | move.pop() 458 | movelbl.config(text=turn[0],bg='blue') 459 | else: 460 | btn9.config(text='X') 461 | if r3[2] == '': 462 | r3[2] = 'X' 463 | b = win() 464 | if b == True: 465 | gameover() 466 | else: 467 | btn1.config(bg='red') 468 | btn2.config(bg='red') 469 | btn3.config(bg='red') 470 | btn4.config(bg='red') 471 | btn5.config(bg='red') 472 | btn6.config(bg='red') 473 | btn7.config(bg='red') 474 | btn8.config(bg='red') 475 | btn9.config(bg='red') 476 | move.pop() 477 | movelbl.config(text=turn[1],bg='red') 478 | btn9.config(command=empty) 479 | 480 | 481 | screen= Tk() 482 | screen.title('TIC TAC TOE') 483 | screen.geometry('400x400+400+200') 484 | 485 | turn= ["X's Turn","O's Turn"] 486 | 487 | move = [1,2,3,4,5,6,7,8,9] 488 | if len(move)%2==1: 489 | movelbl = Label(screen,text=turn[0],font=('times new roman',22),bg='blue',fg='yellow') 490 | movelbl.pack(pady=20) 491 | 492 | frame = Frame(screen,bg='orange') 493 | frame.pack(side=TOP,padx = 10, pady =5) 494 | 495 | font=('times new roman',38,'bold') 496 | 497 | btn1= Button(frame,text='',font=font,bg='blue',fg='#ffffff',width= 3,height=1,activebackground='#903812',activeforeground='#111111',command=cl1) 498 | btn1.grid(row=0,column=0) 499 | btn1.bind('') 500 | btn2 =Button(frame,text='',font=font,bg='blue',fg='#ffffff',width= 3,height=1,activebackground='#903812',activeforeground='#111111',command=cl2) 501 | btn2.grid(row=0,column=1) 502 | btn2.bind('') 503 | btn3 =Button(frame,text='',font=font,bg='blue',fg='#ffffff',width= 3,height=1,activebackground='#903812',activeforeground='#111111',command=cl3) 504 | btn3.grid(row=0,column=2) 505 | btn3.bind('') 506 | btn4 =Button(frame,text='',font=font,bg='blue',fg='#ffffff',width= 3,height=1,activebackground='#903812',activeforeground='#111111',command=cl4) 507 | btn4.grid(row=1,column=0) 508 | btn4.bind('') 509 | btn5 =Button(frame,text='',font=font,bg='blue',fg='#ffffff',width= 3,height=1,activebackground='#903812',activeforeground='#111111',command=cl5) 510 | btn5.grid(row=1,column=1) 511 | btn5.bind('') 512 | btn6 =Button(frame,text='',font=font,bg='blue',fg='#ffffff',width= 3,height=1,activebackground='#903812',activeforeground='#111111',command=cl6) 513 | btn6.grid(row=1,column=2) 514 | btn6.bind('') 515 | btn7 =Button(frame,text='',font=font,bg='blue',fg='#ffffff',width= 3,height=1,activebackground='#903812',activeforeground='#111111',command=cl7) 516 | btn7.grid(row=2,column=0) 517 | btn7.bind('') 518 | btn8 =Button(frame,text='',font=font,bg='blue',fg='#ffffff',width= 3,height=1,activebackground='#903812',activeforeground='#111111',command=cl8) 519 | btn8.grid(row=2,column=1) 520 | btn8.bind('') 521 | btn9 =Button(frame,text='',font=font,bg='blue',fg='#ffffff',width= 3,height=1,activebackground='#903812',activeforeground='#111111',command=cl9) 522 | btn9.grid(row=2,column=2) 523 | btn9.bind('') 524 | 525 | btn10 =Button(frame,text='Reset',font=('times new roman',20,'bold'),bg='orange',fg='#ffffff',width= 3,height=1,activebackground='blue',activeforeground='#111111',command=empty) 526 | 527 | 528 | screen.mainloop() 529 | 530 | newgame() 531 | --------------------------------------------------------------------------------