# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import pandas as pd
from numpy import *
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import os
import cv2
import numpy as np
from keras.models import model_from_json
from keras.preprocessing import image
from sklearn import preprocessing
from sklearn import datasets, linear_model
from sklearn.metrics import mean_squared_error, r2_score
from sklearn import metrics

from sklearn.model_selection import train_test_split
from sklearn import neighbors

data =pd.read_csv('/Users/kurukundasreenathreddy/Desktop/Major project/data/train.csv')
array = data.values

for i in range(len(array)):
	if array[i][0]=="Male":
		array[i][0]=1
	else:
		array[i][0]=0


df=pd.DataFrame(array)

maindf =df[[0,1,2,3,4,5,6]]
mainarray=maindf.values
print (mainarray)


temp=df[7]
train_y =temp.values
# print(train_y)
# print(mainarray)
train_y=temp.values

for i in range(len(train_y)):
	train_y[i] =str(train_y[i])



mul_lr = linear_model.LogisticRegression(multi_class='multinomial', solver='newton-cg',max_iter =1000)
mul_lr.fit(mainarray, train_y)

testdata =pd.read_csv('/Users/kurukundasreenathreddy/Desktop/Major project/data/test.csv')
test = testdata.values

for i in range(len(test)):
	if test[i][0]=="Male":
		test[i][0]=1
	else:
		test[i][0]=0


# -

data

data.describe()

data.isnull

sns.pairplot(data)

sns.relplot(x="Gender",y="Personality (Class label)",data=data)

sns.relplot(x="Age",y="Personality (Class label)",hue="Age",data=data)

sns.catplot(x="Age",y="Personality (Class label)",data=data)

sns.relplot(x="Age",y="Personality (Class label)", kind="line",data=data)

data["Age"].value_counts()

# +
df1=pd.DataFrame(test)

testdf =df1[[0,1,2,3,4,5,6]]
maintestarray=testdf.values
print(maintestarray)

y_pred = mul_lr.predict(maintestarray)
for i in range(len(y_pred)) :
	y_pred[i]=str((y_pred[i]))
DF = pd.DataFrame(y_pred,columns=['Predicted Personality'])
DF.index=DF.index+1
DF.index.names = ['Serial Number']
DF.to_csv("output.csv")
# -

sns.distplot(data.Age,kde=True)

sns.boxplot(x='Age',y='Personality (Class label)',data=data)

sns.heatmap(data.isnull(), cmap='plasma') 

sns.countplot(x='Age',hue='Personality (Class label)',data=data)

sns.countplot(x='Age',hue='Gender',data=data)

# +
photo="Demo1.jpg"
im = cv2.imread(photo)

im = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
# -

plt.imshow(im, interpolation='nearest',cmap='gray')

im = cv2.GaussianBlur(im, (5, 5), 0)

plt.imshow(im)

im_th = cv2.adaptiveThreshold(im, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 115, 1)

plt.imshow(im_th,interpolation='nearest',cmap='gray')

plt.imshow(im,cmap='hot')
plt.colorbar()

import tkinter as tk
from tkinter import *
from PIL import ImageTk,Image

# +
root = Tk()
root.title("Personality Detection")
root.geometry("400x200")

def graph():
    Personality_detection = np .random.normal(2000,250000,50000)
    plt.hist(Personality_detection,200)
    plt.show()

my_button = Button(root,text = "Graph",command = graph)

my_button.pack()
    
root.mainloop()

    

# +
class Win1:
    def __init__(self, master):
        self.master = master
        self.master.geometry("400x300")
        self.show_widgets()
 
    def show_widgets(self):
        self.frame = tk.Frame(self.master)
        self.master.title("Window n.1")
        self.create_button("Click to open Window 2", Win2)
        self.create_button("Click to open Window 3", Win3)
        self.create_button("Click to open Window 4", Win4)
        self.frame.pack()
 
    def create_button(self, text, _class):
        "Button that creates a new window"
        tk.Button(
            self.frame, text=text,
            command=lambda: self.new_window(_class)).pack()
 
    def new_window(self, _class):
            global win2, win3 , win4
 
            try:
                if _class == Win2:
                    if win2.state() == "normal":
                        win2.focus()
            except:  
                win2 = tk.Toplevel(self.master)
                _class(win2)
 
            try:
                if _class == Win3:
                    if win3.state() == "normal":
                        win3.focus()
            except:  
                win3 = tk.Toplevel(self.master)
                _class(win3)
                
            try:
                if _class == Win4:
                    if win4.state() == "normal":
                        win4.focus()
            except:  
                win4 = tk.Toplevel(self.master)
                _class(win4)
 
    def close_window(self):
        self.master.destroy()
 
class Win2(Win1):
 
    def show_widgets(self):
        self.master.title("Window 2")
        self.frame = tk.Frame(self.master, bg="red")
        self.quit_button = tk.Button(
            self.frame, text=f"Quit this window n. 2",
            command=self.close_window)
        self.quit_button.pack()
        self.create_button("Open window 3 from window 2", Win3)
        self.frame.pack()
        self.label = tk.Label(
            self.frame, text="THIS IS ONLY IN THE THIRD WINDOW")
 
class Win3(Win2):
 
    def show_widgets(self):
        self.master.title("Window 3")
        self.frame = tk.Frame(self.master, bg="green")
        self.quit_button = tk.Button(
            self.frame, text=f"Quit this window n. 3",
            command=self.close_window)
        self.label = tk.Label(
            self.frame, text="1)50-0= Extraversion\n      2)100-50 = Agreeableness\n   3)150-100=Conscientiousness\n4)200-150=Neuroticism\n5)250-200=Openness")
        self.label.pack()
        self.frame.pack()
        
class Win4(Win3):
 
    def show_widgets(self):
        self.master.title("Window 4")
        self.frame = tk.Frame(self.master, bg="green")
        self.quit_button = tk.Button(
            self.frame, text=f"Quit this window n. 4",
            command=self.close_window)
        self.label = tk.Label(
            self.frame, text="1)Openness to experience is one of the domains which are used to describe human personality in the Five Factor Model. Openness involves six facets, or dimensions: active imagination, aesthetic sensitivity, attentiveness to inner feelings, preference for variety, intellectual\ncuriosity, and challenging authority.\n 2)Neuroticism is the trait disposition to experience negative affects, including anger, anxiety, self‐consciousness, irritability, emotional instability, and depression")
        self.label.pack()
        self.frame.pack()
 
root = tk.Tk()
app = Win1(root)
root.mainloop()
# -

cv2.namedWindow("Resulting Image with Rectangular ", cv2.WINDOW_NORMAL)
cv2.imshow("Resulting Image  ", im)
cv2.waitKey(0)
cv2.destroyAllWindows()

hist



StarcoderdataJupyterScriptsDedupFiltered