ML Model to Predict Whether the Cancer Is Benign or Malignant on Breast Cancer Wisconsin Data Set

Image for post
Image for post

We already understood the data health check up, and EDA in part 1. In part 2, we understood the different kind of feature selection techniques. In Part 3, we built different models , analyzed & compared the performance. In part 4, we understood the two optimization approaches.

Now, in this tutorial, we will try to understand deploying method using Flask APIs and Heroku.

Prerequisites


Find the Fastest Way to Import CSV Data Into MySQL Database Using Python

Image for post
Image for post

1. Overview

The main objective of this tutorial is to find the best method to import bulk CSV data into MySQL.

2. Prerequisites

Python 3.8.3 : Anaconda download link
MySQL : Download link

sqlalchemy : To install sqlalchemy use the command: pip install sqlalchemy

3. Prepare or Identify Your Data

To begin, prepare or identify the CSV file that you’d like to import to MySQL database. For example, we loaded iris data from GitHub.

3.1 Import Libraries

import os
import sys
import pandas as pd
import numpy as np
from sqlalchemy import create_engine
import seaborn as sns
import matplotlib.pyplot as plt
import mysql.connector as msql
from mysql.connector import Error
import csv


Comparison of Methods for Importing bulk CSV data Into PostgreSQL Using Python

Image for post
Image for post

1. Overview

The main objective of this tutorial is to find the best method to import bulk CSV data into PostgreSQL.

2. Prerequisites

Python 3.8.3 : Anaconda download link

PostgreSQL 13 : Download link

Psycopg2 : To install Psycopg2 use the command: pip install psycopg2

3. Prepare or Identify Your Data

To begin, prepare or identify the CSV file that you’d like to import to PostgreSQL database. For example, we loaded iris data from GitHub.

3.1 Import Libraries

import os
import sys
# import the connect library for psycopg2
import psycopg2
# import the error handling libraries for psycopg2
from psycopg2 import OperationalError, errorcodes, errors
import psycopg2.extras as extras
import pandas as pd
from io import StringIO
import numpy as np
from sqlalchemy import create_engine
import seaborn as sns
import matplotlib.pyplot …

Insert Bulk Data Using to_sql()(alchemy) Into PostgreSQL Database

Image for post
Image for post

Prerequisites

Python 3.8.3 : Anaconda download link

PostgreSQL 13 : Download link

Psycopg2 : To install Psycopg2 use the command: pip install psycopg2

Objective

The main objective of this article is to learn step by step working code for the to_sql() method.

Step 1 : Prepare or identify your data

To begin, prepare or identify the CSV file that you’d like to import to PostgreSQL database. For example, we loaded iris data from GitHub.

import os
# import sys to get more detailed Python exception info
import sys
# import the connect library for psycopg2
import psycopg2
# import the error handling libraries for psycopg2
from psycopg2 import OperationalError, errorcodes, errors
import psycopg2.extras …

Extract, Transform, and Load PostgreSQL Data in Python

Image for post
Image for post

Prerequisites

Python 3.8.3 : Anaconda download link

PostgreSQL 13 : Download link

Psycopg2 : To install Psycopg2 use the command: pip install psycopg2, petl

Objective

Generally we create training and testing data by importing csv file into pandas DataFrame but when we have large data stored in database server then we need a method to extract it into pandas DataFrame directly from database server. For this objective, we will learn step by step working code for different methods for doing it.

Step 1 : Import libraries

# import sys to get more detailed Python exception info
import sys
# import the connect library for psycopg2
import psycopg2
# import the error handling libraries for psycopg2
from psycopg2 import OperationalError, errorcodes, errors
import psycopg2.extras …


How to read data from PostgreSQL to Pandas DataFrame?

Image for post
Image for post

Prerequisites

Python 3.8.3 : Anaconda download link

PostgreSQL 13 : Download link

Psycopg2 : To install Psycopg2 use the command: pip install psycopg2

Objective

Generally we create training and testing data by importing csv file into pandas DataFrame but when we have large data stored in database server then we need a method to extract it into pandas DataFrame directly from database server. For this objective, we will learn step by step working code for different methods for doing it.

Step 1 : Import libraries

# import sys to get more detailed Python exception info
import sys
# import the connect library for psycopg2
import psycopg2
# import the error handling libraries for psycopg2
from psycopg2 import OperationalError, errorcodes, errors
import psycopg2.extras

Insert Bulk Data Using copy_from() with StringIO Into PostgreSQL Database

Image for post
Image for post

Prerequisites

Python 3.8.3 : Anaconda download link

PostgreSQL 13 : Download link

Psycopg2 : To install Psycopg2 use the command: pip install psycopg2

Objective

The main objective of this article is to learn step by step working code for the copy_from() with StringIO method.

Step 1 : Prepare or identify your data

To begin, prepare or identify the CSV file that you’d like to import to PostgreSQL database. For example, we loaded iris data from GitHub.

import os
# import sys to get more detailed Python exception info
import sys
# import the connect library for psycopg2
import psycopg2
# import the error handling libraries for psycopg2
from psycopg2 import OperationalError, errorcodes, errors
import psycopg2.extras …


Insert Bulk Data Using copy_from() Into PostgreSQL Database

Image for post
Image for post

Prerequisites

Python 3.8.3 : Anaconda download link

PostgreSQL 13 : Download link

Psycopg2 : To install Psycopg2 use the command: pip install psycopg2

Objective

The main objective of this article is to learn step by step working code for the copy_from() method.

Step 1 : Prepare or identify your data

To begin, prepare or identify the CSV file that you’d like to import to PostgreSQL database. For example, we loaded iris data from GitHub.

# import sys to get more detailed Python exception info
import sys
# import the connect library for psycopg2
import psycopg2
# import the error handling libraries for psycopg2
from psycopg2 import OperationalError, errorcodes, errors
import psycopg2.extras as extras
import pandas as pd
irisData = pd.read_csv('https://raw.githubusercontent.com/Muhd-Shahid/Learn-Python-Data-Access/main/iris.csv',index_col=False) …


Insert Bulk Data Using mogrify() Into PostgreSQL Database

Image for post
Image for post

Prerequisites

Python 3.8.3 : Anaconda download link

PostgreSQL 13 : Download link

Psycopg2 : To install Psycopg2 use the command: pip install psycopg2

Objective

The main objective of this article is to learn step by step working code for the mogrify() method.

Step 1 : Prepare or identify your data

To begin, prepare or identify the CSV file that you’d like to import to PostgreSQL database. For example, we loaded iris data from GitHub.

# import sys to get more detailed Python exception info
import sys
# import the connect library for psycopg2
import psycopg2
# import the error handling libraries for psycopg2
from psycopg2 import OperationalError, errorcodes, errors
import psycopg2.extras as extras
import pandas as pdirisData = pd.read_csv('https://raw.githubusercontent.com/Muhd-Shahid/Learn-Python-Data-Access/main/iris.csv',index_col=False) …


Insert Bulk Data Using execute_values() method into PostgreSQL Database using Python

Image for post
Image for post

Prerequisites

Python 3.8.3 : Anaconda download link

PostgreSQL 13 : Download link

Psycopg2 : To install Psycopg2 use the command: pip install psycopg2

Objective

The main objective of this article is to learn step by step working code for the execute_values() method.

To begin, prepare or identify the CSV file that you’d like to import to PostgreSQL database. For example, we loaded iris data from GitHub.

# import sys to get more detailed Python exception info
import sys
# import the connect library for psycopg2
import psycopg2
# import the error handling libraries for psycopg2
from psycopg2 import OperationalError, errorcodes, errors
import psycopg2.extras

About

Shahid

Making it easy to understand | Push and Pull Data | SQL | Explore and Visualize Data | Hypothesis Testing | Statistics | ML | NLP | Data Science | Dreamer!!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store