https://cdn-icons-png.flaticon.com/512/6596/6596971.png

Predict which leads have the most propensity to convert.

We will train a machine learning (ML) model based on historical lead conversion data, in order to predict likelihood of conversion for new leads.

Determining the value of each lead is a critical factor for businesses that want to maximize their sales efforts. It helps them identify which leads are most likely to convert and generate revenue over time.

Here is an example on how to build an ML model in Peliqan.io with a few lines of Python code.

Import required modules

from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
from sklearn.preprocessing import LabelEncoder
from collections import defaultdict
from joblib import dump
import pandas as pd

Load a dataset

Load data from a table into a dataframe (df). The table needs to contains lead data, including an indication if these leads converted (historical data).

# Load Data
dbconn = pq.dbconnect('dw_123')
df = dbconn.fetch('dw_123', 'crm', 'leads', df=True)

Using Streamlit to build an app

We use the Streamlit module (st), built into Peliqan.io, to build a UI and show data.

# Show a title (st = Streamlit module)
st.title("Lead Conversion")

# Show some text
st.text("Predict Hot Leads")

# Show the dataframe
st.dataframe(df.head(), use_container_width=True)

This is what the output looks like:

Untitled

Here’s our code in the Peliqan low-code editor, with a preview:

Untitled

Prepare the data