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

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.

We are using Python 3.8.3, you can use any version.

pip install virtualenv, please check resources below for environment setup.

pip install flask

pip install -r requirements.txt, can be found here

Create your account on Heroku |…


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

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
from sqlalchemy.exc import SQLAlchemyError
import seaborn as sns
import matplotlib.pyplot as plt
import mysql.connector as msql
from mysql.connector …


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

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.

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…


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

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 as extras
import pandas as…


Extract, Transform, and Load PostgreSQL Data in Python

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…


How to read data from PostgreSQL to Pandas DataFrame?

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…


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

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 as extras
import…


Insert Bulk Data Using copy_from() Into PostgreSQL Database

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…


Insert Bulk Data Using mogrify() Into PostgreSQL Database

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…


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

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 as extras
import pandas as pdirisData…

Learner CARES

I’m a learner, work as a full-time Data Science Manager. In my spare time I do sharing my knowledge and focusing on one thing — to help people learn.

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