{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sn\nimport pandas as pd\nimport sklearn","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:30.281630Z","iopub.execute_input":"2022-11-05T00:29:30.282021Z","iopub.status.idle":"2022-11-05T00:29:30.288209Z","shell.execute_reply.started":"2022-11-05T00:29:30.281991Z","shell.execute_reply":"2022-11-05T00:29:30.286989Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn import datasets\ndataset = datasets.load_iris()","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:30.291029Z","iopub.execute_input":"2022-11-05T00:29:30.291753Z","iopub.status.idle":"2022-11-05T00:29:30.300215Z","shell.execute_reply.started":"2022-11-05T00:29:30.291708Z","shell.execute_reply":"2022-11-05T00:29:30.299125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.DataFrame(data = np.c_[dataset['data'], dataset['target']],\n                 columns = dataset['feature_names'] + ['target'])\n\ndf['species'] = pd.Categorical.from_codes(dataset.target, dataset.target_names)","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:30.302914Z","iopub.execute_input":"2022-11-05T00:29:30.303618Z","iopub.status.idle":"2022-11-05T00:29:30.312700Z","shell.execute_reply.started":"2022-11-05T00:29:30.303576Z","shell.execute_reply":"2022-11-05T00:29:30.311420Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:30.314715Z","iopub.execute_input":"2022-11-05T00:29:30.315686Z","iopub.status.idle":"2022-11-05T00:29:30.335903Z","shell.execute_reply.started":"2022-11-05T00:29:30.315644Z","shell.execute_reply":"2022-11-05T00:29:30.334778Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.corr()","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:30.338174Z","iopub.execute_input":"2022-11-05T00:29:30.338819Z","iopub.status.idle":"2022-11-05T00:29:30.354198Z","shell.execute_reply.started":"2022-11-05T00:29:30.338777Z","shell.execute_reply":"2022-11-05T00:29:30.353072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.plot(x='sepal length (cm)', y='sepal width (cm)', kind='scatter')","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:30.355717Z","iopub.execute_input":"2022-11-05T00:29:30.356175Z","iopub.status.idle":"2022-11-05T00:29:30.600189Z","shell.execute_reply.started":"2022-11-05T00:29:30.356134Z","shell.execute_reply":"2022-11-05T00:29:30.598834Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.plot(x='petal length (cm)', y='petal width (cm)', kind='scatter')","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:30.604316Z","iopub.execute_input":"2022-11-05T00:29:30.604780Z","iopub.status.idle":"2022-11-05T00:29:30.845436Z","shell.execute_reply.started":"2022-11-05T00:29:30.604737Z","shell.execute_reply":"2022-11-05T00:29:30.844057Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sn.pairplot(df)","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:30.847479Z","iopub.execute_input":"2022-11-05T00:29:30.847901Z","iopub.status.idle":"2022-11-05T00:29:35.875282Z","shell.execute_reply.started":"2022-11-05T00:29:30.847860Z","shell.execute_reply":"2022-11-05T00:29:35.874213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import LogisticRegression\nfrom sklearn.model_selection import train_test_split\nfrom sklearn import metrics","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:35.876643Z","iopub.execute_input":"2022-11-05T00:29:35.877039Z","iopub.status.idle":"2022-11-05T00:29:35.882119Z","shell.execute_reply.started":"2022-11-05T00:29:35.877008Z","shell.execute_reply":"2022-11-05T00:29:35.881113Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = df.iloc[:,:4]\ny = df[\"species\"]","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:35.883532Z","iopub.execute_input":"2022-11-05T00:29:35.883888Z","iopub.status.idle":"2022-11-05T00:29:35.897981Z","shell.execute_reply.started":"2022-11-05T00:29:35.883858Z","shell.execute_reply":"2022-11-05T00:29:35.897021Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X.shape","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:35.899567Z","iopub.execute_input":"2022-11-05T00:29:35.900252Z","iopub.status.idle":"2022-11-05T00:29:35.911284Z","shell.execute_reply.started":"2022-11-05T00:29:35.900207Z","shell.execute_reply":"2022-11-05T00:29:35.910128Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y.shape","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:35.912650Z","iopub.execute_input":"2022-11-05T00:29:35.913343Z","iopub.status.idle":"2022-11-05T00:29:35.923632Z","shell.execute_reply.started":"2022-11-05T00:29:35.913301Z","shell.execute_reply":"2022-11-05T00:29:35.922651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.30, random_state=2)","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:35.927101Z","iopub.execute_input":"2022-11-05T00:29:35.927435Z","iopub.status.idle":"2022-11-05T00:29:35.934952Z","shell.execute_reply.started":"2022-11-05T00:29:35.927406Z","shell.execute_reply":"2022-11-05T00:29:35.934125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = LogisticRegression(random_state = 0)","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:35.936386Z","iopub.execute_input":"2022-11-05T00:29:35.936739Z","iopub.status.idle":"2022-11-05T00:29:35.946677Z","shell.execute_reply.started":"2022-11-05T00:29:35.936705Z","shell.execute_reply":"2022-11-05T00:29:35.945861Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:35.948314Z","iopub.execute_input":"2022-11-05T00:29:35.948733Z","iopub.status.idle":"2022-11-05T00:29:36.003148Z","shell.execute_reply.started":"2022-11-05T00:29:35.948694Z","shell.execute_reply":"2022-11-05T00:29:36.002381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.coef_","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:36.004356Z","iopub.execute_input":"2022-11-05T00:29:36.004660Z","iopub.status.idle":"2022-11-05T00:29:36.011887Z","shell.execute_reply.started":"2022-11-05T00:29:36.004631Z","shell.execute_reply":"2022-11-05T00:29:36.010826Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.score(X_test, y_test)","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:36.013502Z","iopub.execute_input":"2022-11-05T00:29:36.013879Z","iopub.status.idle":"2022-11-05T00:29:36.026408Z","shell.execute_reply.started":"2022-11-05T00:29:36.013850Z","shell.execute_reply":"2022-11-05T00:29:36.025315Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Y_pred = model.predict(X_test)\nY_pred","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:36.027339Z","iopub.execute_input":"2022-11-05T00:29:36.027647Z","iopub.status.idle":"2022-11-05T00:29:36.039683Z","shell.execute_reply.started":"2022-11-05T00:29:36.027619Z","shell.execute_reply":"2022-11-05T00:29:36.038755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import confusion_matrix\ncm = confusion_matrix(y_test, Y_pred)\ncm","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:29:36.040992Z","iopub.execute_input":"2022-11-05T00:29:36.042174Z","iopub.status.idle":"2022-11-05T00:29:36.054753Z","shell.execute_reply.started":"2022-11-05T00:29:36.042137Z","shell.execute_reply":"2022-11-05T00:29:36.053972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sn.heatmap(cm, annot=True)","metadata":{"execution":{"iopub.status.busy":"2022-11-05T00:34:26.931228Z","iopub.execute_input":"2022-11-05T00:34:26.931586Z","iopub.status.idle":"2022-11-05T00:34:27.220075Z","shell.execute_reply.started":"2022-11-05T00:34:26.931559Z","shell.execute_reply":"2022-11-05T00:34:27.219321Z"},"trusted":true},"execution_count":null,"outputs":[]}]}