<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mercy Jeruto</title>
    <description>The latest articles on DEV Community by Mercy Jeruto (@miley775).</description>
    <link>https://dev.to/miley775</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3052032%2Fa90cf1d5-0575-4df1-8f53-09310eb8440b.jpeg</url>
      <title>DEV Community: Mercy Jeruto</title>
      <link>https://dev.to/miley775</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/miley775"/>
    <language>en</language>
    <item>
      <title>Unsupervised Learning: Discovering Hidden Patterns in Data</title>
      <dc:creator>Mercy Jeruto</dc:creator>
      <pubDate>Sat, 26 Jul 2025 17:32:34 +0000</pubDate>
      <link>https://dev.to/miley775/unsupervised-learning-discovering-hidden-patterns-in-data-40al</link>
      <guid>https://dev.to/miley775/unsupervised-learning-discovering-hidden-patterns-in-data-40al</guid>
      <description>&lt;p&gt;In the world of machine learning, not all problems come with clear instructions. Sometimes, we don't know the answer in advance we just have raw data. This is where Unsupervised Learning comes in.&lt;br&gt;
While Supervised Learning teaches a model using labeled data (like predicting prices or classifying emails as spam), Unsupervised Learning lets algorithms explore and uncover structure in unlabeled datasets much like solving a puzzle without knowing the final picture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Unsupervised Learning?&lt;/strong&gt;&lt;br&gt;
Unsupervised Learning is a type of machine learning where the model is trained without labeled output. The goal is to find patterns, groupings, or meaningful insights from the data based purely on its internal structure.&lt;/p&gt;

&lt;p&gt;Think of unsupervised learning like walking into a library with no catalog system. Books are scattered around, and you have no idea what genres or categories exist. You start grouping them based on clues like titles, covers, or page numbers. Eventually, you might sort them into categories like fiction, history, or science even though no one told you those categories existed.&lt;/p&gt;

&lt;p&gt;That’s exactly what an unsupervised learning algorithm does.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main Techniques in Unsupervised Learning&lt;/strong&gt;&lt;br&gt;
&lt;u&gt;&lt;strong&gt;1.&lt;/strong&gt; &lt;strong&gt;Clustering&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
Clustering is about grouping similar data points together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A) &lt;em&gt;KMeans Clustering&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Idea: Divide data into K groups based on similarity.&lt;/p&gt;

&lt;p&gt;How it works: The algorithm randomly picks K "centroids", assigns each data point to the closest one, and adjusts centroids until things stabilize.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Real-world use:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Customer Segmentation:&lt;/em&gt; In retail or hospitality, we can use clustering to group customers based on age, income, and spending habits.&lt;/p&gt;

&lt;p&gt;Example:Here's a step-by-step visual demonstration of applying K-Means clustering to mall customer data:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Understanding the Data&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Typical mall customer data includes: Customer ID, Age, Annual Income(k$), Spending Score (1-100).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs41jpoxi6qmk61dg2vcx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs41jpoxi6qmk61dg2vcx.png" alt=" " width="558" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A simple ASCII-style diagram to help you visualize how KMeans clustering works:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74r1qsqqctj5q8yjvga5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74r1qsqqctj5q8yjvga5.png" alt=" " width="367" height="200"&gt;&lt;/a&gt;&lt;br&gt;
These * symbols represent data points like customers, documents, or patterns, but we don’t yet know how they’re grouped.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkk7p4157glyxad9ay6bv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkk7p4157glyxad9ay6bv.png" alt=" " width="386" height="190"&gt;&lt;/a&gt;&lt;br&gt;
C1, C2, C3 are randomly placed centroids, each representing a starting guess for a cluster center.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7d9zwgl6otqju3h2kmvb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7d9zwgl6otqju3h2kmvb.png" alt=" " width="482" height="293"&gt;&lt;/a&gt;&lt;br&gt;
Each point now belongs to the nearest centroid forming three clusters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ilycmjmda5vmvt77i56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ilycmjmda5vmvt77i56.png" alt=" " width="325" height="169"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B)&lt;/strong&gt; &lt;strong&gt;Hierarchical Clustering&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Idea:&lt;/em&gt; Build a tree of clusters (like a family tree) by progressively merging or splitting groups.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Visual Aid:&lt;/em&gt; Dendrograms show the merging process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5di1ahftc0hr3r5amhxw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5di1ahftc0hr3r5amhxw.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Use case:&lt;/em&gt; Better for visualizing how clusters are formed, especially when we don’t know the number of clusters in advance.&lt;br&gt;
Below is a python code using the mall customer data;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from scipy.cluster.hierarchy import dendrogram, linkage
linkage_matrix = linkage(df[['Age', 'Spending Score (1-100)']], method='ward')
dendrogram(linkage_matrix)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;&lt;strong&gt;2.&lt;/strong&gt; &lt;strong&gt;Dimensionality Reduction&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
When working with machine learning models, datasets with too many features can cause issues like slow computation and overfitting. Dimensionality reduction helps to reduce the number of features while retaining key information. Techniques like &lt;strong&gt;principal component analysis (PCA), singular value decomposition (SVD)&lt;/strong&gt; and &lt;strong&gt;linear discriminant analysis (LDA)&lt;/strong&gt; convert data into a lower-dimensional space while preserving important details.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A) &lt;em&gt;Principal Component Analysis (PCA)&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Idea:&lt;/em&gt; Transform the data into fewer dimensions while preserving variance.&lt;/p&gt;

&lt;p&gt;How it helps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Improves speed and efficiency.&lt;/li&gt;
&lt;li&gt;Useful for visualizing high-dimensional data in 2D or 3D.&lt;/li&gt;
&lt;li&gt;Helps in noise reduction and pattern recognition.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;u&gt;&lt;em&gt;Why It Matters&lt;/em&gt;&lt;/u&gt;&lt;br&gt;
&lt;em&gt;You don’t always have labels:&lt;/em&gt; In real-world business problems, labels (like churned customers or fraud cases) are expensive or missing.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Find hidden insights:&lt;/em&gt; Unsupervised models can uncover segments, anomalies, or structures you didn’t even know existed.&lt;/p&gt;

&lt;p&gt;Better targeting: Marketers use clustering to tailor campaigns. Hotels can design loyalty offers based on cluster behavior. Security teams can identify unusual access patterns.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;Analogy:&lt;/strong&gt; Sorting Socks Blindfolded&lt;/u&gt;&lt;br&gt;
Imagine reaching into a laundry basket blindfolded. You don’t know the colors, but you try sorting socks by feel — thick vs. thin, long vs. short. Eventually, you form groups. That’s unsupervised learning — no labels, just internal patterns.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sklearn.cluster import KMeans
import matplotlib.pyplot as plt

kmeans = KMeans(n_clusters=5)
df['Cluster'] = kmeans.fit_predict(df[['Annual Income (k$)', 'Spending Score (1-100)']])

# Plot clusters
plt.figure(figsize=(8, 5))
plt.scatter(df['Annual Income (k$)'], df['Spending Score (1-100)'], c=df['Cluster'], cmap='rainbow')
plt.xlabel('Annual Income (k$)')
plt.ylabel('Spending Score')
plt.title('Customer Segmentation using KMeans')
plt.show()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives a powerful visualization — showing customer groups based on how they spend and what they earn.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
Unsupervised learning may seem like data alchemy at first — turning unlabeled, messy data into gold. But with tools like KMeans, Hierarchical Clustering, and PCA, we can find meaning in the chaos. Whether you're segmenting customers, detecting fraud, or simplifying data — these techniques are vital for modern data-driven decision making.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Python for SQL: Beginner Level-Introduction to Database Connectivity</title>
      <dc:creator>Mercy Jeruto</dc:creator>
      <pubDate>Sat, 24 May 2025 07:26:27 +0000</pubDate>
      <link>https://dev.to/miley775/python-for-sql-beginner-level-introduction-to-database-connectivity-5932</link>
      <guid>https://dev.to/miley775/python-for-sql-beginner-level-introduction-to-database-connectivity-5932</guid>
      <description>&lt;p&gt;&lt;strong&gt;Outline&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Python is a widely used and flexible programming language applicable in numerous areas including web development, scientific computing, and data analysis. A key advantage of Python is its capability to connect with and interact with databases. In this article, we will provide an introduction to using Python for SQL and show how it can be utilized to connect to and manage databases.&lt;br&gt;
Although SQL is a robust language for interacting with databases, it does have its drawbacks. For instance, crafting intricate queries or conducting data analysis can be challenging when relying solely on SQL. In contrast, Python is a versatile programming language that excels in executing complex data analysis, machine learning, and web development activities. By integrating Python with SQL, you can leverage the strengths of both languages to carry out more sophisticated data analysis and database management tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python for SQL: Database Connectivity&lt;/strong&gt;&lt;br&gt;
To link Python with a database, you must utilize a Python library or module that offers a database driver. A database driver is a software element that establishes a connection between the Python application and the database management system.&lt;br&gt;
Numerous well-known Python libraries exist for connecting to databases, such as:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;PyMySQL:&lt;/em&gt;&lt;/strong&gt; A pure Python MySQL driver that allows you to connect to a MySQL database and perform SQL queries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;psycopg2:&lt;/em&gt;&lt;/strong&gt; A PostgreSQL database adapter that provides access to the PostgreSQL database server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;sqlite3:&lt;/em&gt;&lt;/strong&gt; A built-in Python library for working with SQLite databases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;SQLAlchemy:&lt;/em&gt;&lt;/strong&gt; A SQL toolkit and Object-Relational Mapping (ORM) library that provides a high-level interface to SQL databases.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this article, we will utilize the PyMySQL library to establish a connection with and manage a MySQL database. PyMySQL is a Python library designed for connecting to MySQL databases. MySQL, an open-source database management system based on the relational model, is commonly used for web applications. PyMySQL offers an easy-to-use interface for connecting to MySQL databases and executing SQL queries.&lt;br&gt;
Connecting to a MySQL Database&lt;br&gt;
To connect to a MySQL database using Python, you need to install the PyMySQL library. Run the following command to install it using the pip package manager:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install pymysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you have installed the PyMySQL library, you can create a connection to a MySQL database using the connect() function. The connect() function takes several parameters, including the hostname, username, password, and database name. To connect to a MySQL database using pymysql, we need to create a connection object. To connect to the database, one must utilise the connection object. Here’s an example of how to create a connection object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pymysql 
connection = pymysql.connect(host='localhost', user='root', password='passCode', db='your_database')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we are connecting to a MySQL database running on the local machine. We are using the root user and the password “passCode” to authenticate ourselves. Finally, we are connecting to a database called “your_database”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating a Cursor object&lt;/strong&gt;&lt;br&gt;
A cursor object is used to execute SQL queries against a database. A cursor object acts as a pointer to a specific location in the database, allowing you to retrieve, insert, update, or delete data. In PyMySQL library, creating a cursor object is an essential step in executing SQL queries.&lt;/p&gt;

&lt;p&gt;The database connection object is used to generate the cursor object. To create a cursor object, you need to call the cursor() method on the database connection object. Here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pymysql 
# Open database connection 
db = pymysql.connect("localhost","user","password","database_name" ) 

# Create a cursor object 
cursor = db.cursor() 

# Execute SQL query 
cursor.execute("SELECT * FROM table_name") 

# Fetch all rows 
rows = cursor.fetchall()

for row in results: 
print(row)
# Close database connection 
db.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we first open a database connection using the PyMySQL library. The connection requires the host, user, password, and database name to connect to a MySQL database. Once the connection is established, we create a cursor object using the cursor() method.&lt;/p&gt;

&lt;p&gt;After the cursor object is created, we can execute an SQL query using the execute() method. In this example, we execute a SELECT statement that retrieves all rows from a specific table in the database.&lt;/p&gt;

&lt;p&gt;The fetchall() method is then called on the cursor object to retrieve all rows from the SELECT statement. The rows are stored in a variable named rows. We are iterating over the results and printing each row. Then, we close the database connection using the close() method.&lt;br&gt;
_&lt;br&gt;
It’s important to note that the cursor object does not retrieve any data until a query is executed. The execute() method is used to execute the SQL query, and the fetchall() method retrieves the data from the query._&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To add data to the database&lt;/strong&gt;&lt;br&gt;
In order to add data to a database with pymysql, it is necessary to first create a connection to the database and then execute SQL commands. Below is an example code snippet demonstrating how to insert data into a MySQL database using pymysql:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pymysql

# Connect to the database
connection = pymysql.connect(host='localhost',
                             user='username',
                             password='password',
                             db='database_name')

# Cursor object creation
cursor = connection.cursor()

# Define the SQL query
sql_query = "INSERT INTO books (author, name, mail, pages) VALUES (%s, %s, %s, %d)"

# Data insertion
data = ("Enid", "Secret Seven", "enid@example.com", 21)


# Execute the query with the data
cursor.execute(sql_query, data)

# Commit the changes
connection.commit()

# Close the cursor and the connection
cursor.close()
connection.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The SQL query we establish is an INSERT statement designed to add data to the books table. The data intended for insertion is indicated by the query’s %s and %d placeholders.&lt;/p&gt;

&lt;p&gt;Subsequently, we define the data to be inserted as a tuple comprising three elements: the name, email, and phone number. We execute the query with the data by utilizing the execute() method of the cursor object. Following this, we commit the changes through the commit method of the connection object.&lt;/p&gt;

&lt;p&gt;It is important to note that if you wish to insert multiple rows of data simultaneously, you may opt for the executemany() method instead of execute(). The executemany() method accepts a list of tuples as its second argument, with each tuple representing a row of data to be inserted.&lt;br&gt;
Dealing with Errors &lt;br&gt;
Handling errors is an important part of writing reliable code in PyMySQL. Here’s an example of how to handle errors&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pymysql

# Connect to the database
try:
    connection = pymysql.connect(host='localhost',
                                 user='username',
                                 password='password',
                                 db='database_name')
except pymysql.Error as e:
    print("Error connecting to database:", e)
    exit()

# Create a cursor object
try:
    cursor = connection.cursor()
except pymysql.Error as e:
    print("Error creating cursor:", e)
    exit()

# Define the SQL query
sql_query = "INSERT INTO books (author, name, mail, pages, weight) VALUES (%s, %s, %s, %d, %d)"

# Define the data to be inserted
data = ("Enid", "Secret Seven", "enid@example.com", 21, 2)

# Execute the query with the data
try:
    cursor.execute(sql_query, data)
except pymysql.Error as e:
    print("Error executing query:", e)
    exit()

# Commit the changes
try:
    connection.commit()
except pymysql.Error as e:
    print("Error committing changes:", e)
    exit()

# Close the cursor and the connection
try:
    cursor.close()
    connection.close()
except pymysql.Error as e:
    print("Error closing connection:", e)
    exit()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, we use try-except blocks to handle errors and exceptions at different stages of the code. When we connect to the database, we use a try-except block to catch any errors that may occur. If an error occurs, we print an error message and exit the program.&lt;/p&gt;

&lt;p&gt;We do the same thing when we create a cursor object, execute the query, commit the changes, and close the cursor and connection.&lt;/p&gt;

&lt;p&gt;If an error occurs at any of these stages, we print an error message and exit the program.&lt;br&gt;
**&lt;br&gt;
Conclusion**&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Python can be used to connect to SQL databases and execute queries using libraries like PyMySQL, sqlite3, and sqlalchemy.&lt;/li&gt;
&lt;li&gt;Using Python with SQL can allow for more powerful and flexible data analysis and manipulation, as well as easier automation of database tasks.&lt;/li&gt;
&lt;li&gt;Python code can be used to insert, update, and delete data in a database, as well as query and retrieve data.&lt;/li&gt;
&lt;li&gt;When using Python with SQL, it’s important to handle errors and exceptions gracefully to ensure reliability and prevent unexpected behavior.&lt;/li&gt;
&lt;li&gt;Python can also be used with other database technologies, such as NoSQL databases and object-relational mappers (ORMs), depending on the needs of your project.&lt;/li&gt;
&lt;li&gt;Learning how to use Python with SQL can be a valuable skill for data analysts, data scientists, and software developers who work with databases.&lt;/li&gt;
&lt;li&gt;There are various resources from where you can master Python in SQL for data analysis. Some of them are — Edx, Scaler, freecodecamp, Kdnuggets, etc.&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>Falling behind? Data Analytics and Physical Security in Kenya</title>
      <dc:creator>Mercy Jeruto</dc:creator>
      <pubDate>Fri, 23 May 2025 17:07:55 +0000</pubDate>
      <link>https://dev.to/miley775/data-analytics-and-physical-security-in-kenya-3gof</link>
      <guid>https://dev.to/miley775/data-analytics-and-physical-security-in-kenya-3gof</guid>
      <description>&lt;p&gt;The incorporation of data analytics in the physical security sector has the capability to bring about a new level of efficiency and effectiveness in maintaining safety, safeguarding assets, and achieving cost reductions.&lt;br&gt;
From interconnected smart systems to access control, surveillance, and incident management, significant insights can be gotten which will assist security teams in making decisions based on data. &lt;br&gt;
The implementation includes the rollout of an incident management system (i.e. applications such as dispatch, incident reporting, investigations, task management and guard tours), data collection and analysis and data visualization. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqi4xlcxc4a0qz77gwl52.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqi4xlcxc4a0qz77gwl52.jpg" alt=" " width="800" height="463"&gt;&lt;/a&gt;&lt;br&gt;
A study was conducted by one Farhad Tajali at the University of Southern California while pursuing a doctoral degree in Organizational Change and Leadership. The study focused on security professionals with a lens on skill gaps and assets. The research explores knowledge, motivation and organizational influences (KMO) to identify assets and needs impacting the utilization of data analytics in the field of physical security. The purpose of this study was to evaluate the utilization of data analytics by security professionals in the field of physical security. Upon conducting the literature review, scholarly sources supported the hypothesis that security professionals lack effective utilization of data for process improvement, risk mitigation and to inform their decision-making.&lt;/p&gt;

&lt;h2&gt;
  
  
  Results and findings
&lt;/h2&gt;

&lt;p&gt;The study found three key findings impacting security professionals’;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Slow adoption of data analytics through triangulation of both quantitative and qualitative research data&lt;/li&gt;
&lt;li&gt;Lack of motivation to engage in data collection and analysis&lt;/li&gt;
&lt;li&gt;Provisioning of resources&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When asked to identify barriers in utilization of data, security professionals reported knowledge and resources as the two main barriers in their profession. Additionally, 94% of security professionals who currently do not perform any form of data analysis reported they would utilize data analytics if they knew more about how to use them effectively.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe7k747q1v97uwkqvpp0y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe7k747q1v97uwkqvpp0y.png" alt=" " width="517" height="301"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;With this;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Is the Kenyan security industry lagging in integrating data analytics into their daily operations and translating quantitative data into practical insights?&lt;/li&gt;
&lt;li&gt;Are there any security professionals’ using data analytics to inform data-driven decision-making?&lt;/li&gt;
&lt;li&gt;Are security professionals’ motivated by other sectors in the context of using data analytics to inform data-driven decision-making?&lt;/li&gt;
&lt;li&gt;Are Security companies in Kenya facilitating or hindering their efforts in the implementation and use of data analytics?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From my own research, some few known Security brands in Kenya are already revolutionizing and integrating physical security with data analytics. (&lt;em&gt;This information was sourced from their websites&lt;/em&gt;)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Opticom Kenya Limited&lt;/li&gt;
&lt;li&gt;Castor Vali Group&lt;/li&gt;
&lt;li&gt;Securex Agencies Limited&lt;/li&gt;
&lt;li&gt;WS Insight Limited&lt;/li&gt;
&lt;li&gt;GardaWorld Security&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Security professionals do not need to be data scientists, but they should strive to be data champions within their organizations. Security professionals should source for adequate training and resources on everything data analytics. Using data, security professionals can tell a better story of the state of security of their clients and within their organizations. &lt;br&gt;
Such intelligence can lead to proactive risk mitigation, effective program management and places the organization in a place of advantage when facing new threats.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Role of Data Science &amp; Analytics in different industry sectors</title>
      <dc:creator>Mercy Jeruto</dc:creator>
      <pubDate>Thu, 24 Apr 2025 10:15:14 +0000</pubDate>
      <link>https://dev.to/miley775/the-role-of-data-science-analytics-in-different-industry-sectors-4n5l</link>
      <guid>https://dev.to/miley775/the-role-of-data-science-analytics-in-different-industry-sectors-4n5l</guid>
      <description>&lt;p&gt;The importance of data science has immensely improved and affected every field, from health to finance, causing a shift towards data-driven insight and efficiency in organizational decisions.&lt;br&gt;
Every day, organizations' collect a huge amount of data, and data science makes a difference by converting the raw data into valuable insights.&lt;br&gt;
Data science and analytics is transforming industries by enabling data-driven decision-making, optimizing operations, and unlocking new opportunities. Here’s how they are reshaping various sectors today:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Healthcare&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Predictive Analytics:&lt;/strong&gt;&lt;/em&gt; Data analytics can track disease patterns and predict potential outbreaks. By analyzing factors such as population density, climate, and travel data, healthcare organizations can take proactive measures to control the spread of diseases&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Hospital resource optimization:&lt;/em&gt;&lt;/strong&gt; Analyzing patient admission rates, bed occupancy, and staff availability, hospitals can predict peak demand periods and allocate resources, accordingly, ensuring efficient patient care.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Early Disease Detection:&lt;/strong&gt;&lt;/em&gt; Sophisticated algorithms analyze patient data, such as medical histories, test results, and genetic information, to identify early signs of diseases like cancer, diabetes, and cardiovascular issues. These algorithms can predict disease risks, allowing healthcare providers to initiate preventative measures and interventions in a timely manner&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Repurposing Existing Drugs:&lt;/strong&gt;&lt;/em&gt; Through data analysis, researchers can identify alternative uses for existing drugs, bringing new treatments to market faster and at lower costs compared to developing entirely new drugs&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Finance &amp;amp; Banking&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Marketing and Customer Analytics:&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
By analysing customer data, banks can develop targeted marketing campaigns, segment customer bases, and create personalised experiences.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Operational Efficiency:&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
Data science optimises internal processes, automates manual tasks, and streamlines workflows, reducing costs and improving productivity.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Regulatory Compliance:&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
Banks must comply with numerous regulations and standards.&lt;br&gt;
Data science helps ensure compliance by analysing vast amounts of data, identifying potential anomalies, and facilitating audits and reporting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Manufacturing &amp;amp; Supply Chain&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Forecasting:&lt;/strong&gt;&lt;/em&gt; With the ability to integrate more data with higher granularity, companies can utilize predictive and prescriptive analysis to improve the accuracy of demand forecasting.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Pricing:&lt;/strong&gt;&lt;/em&gt; Dynamic pricing will allow companies to further maximize exploration of the customer demand curve, react to market behavior, and gain market growth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Transportation &amp;amp; Logistics&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Route Optimization:&lt;/em&gt;&lt;/strong&gt; Reduces fuel costs and delivery times (e.g., UPS, Uber).&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Demand Forecasting:&lt;/em&gt;&lt;/strong&gt; Predicts peak travel times for ride-sharing services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Agriculture (AgTech)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Weather Patterns:&lt;/em&gt;&lt;/strong&gt; Monitoring temperature, humidity, rainfall, and other climatic factors to predict how crops perform under different conditions.&lt;br&gt;
&lt;em&gt;&lt;strong&gt;Soil Health:&lt;/strong&gt;&lt;/em&gt; Collect soil composition, moisture levels, and nutrient content data to determine the best crops to plant and the most effective fertilizers.&lt;br&gt;
&lt;em&gt;&lt;strong&gt;Crop Yields:&lt;/strong&gt;&lt;/em&gt; Analyzing historical and real-time data on crop performance to forecast yields and optimize harvesting schedules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Market Trends:&lt;/em&gt;&lt;/strong&gt; Gathering data on commodity prices, demand fluctuations, and consumer preferences to make informed decisions about planting and selling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Telecommunications&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Network Optimization:&lt;/em&gt;&lt;/strong&gt; Telecom analytics tools offer an overview of the network’s performance, with important telecom metrics like network latency, packet loss, MOS score, etc. This enables telecom operators to detect bottlenecks, maximize network capacity, guarantee sufficient bandwidth, and prevent congestion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Customer Churn Prediction:&lt;/em&gt;&lt;/strong&gt;  Data analytics here can track and supervise any drop in service performance continually, model network behavior, and predict future needs accordingly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Price optimization:&lt;/em&gt;&lt;/strong&gt; A telecom company can use data analytics to obtain precise and actionable insights into consumer behavior and develop winning pricing plans. This requires you to study customer responses to various pricing strategies, past purchases, and other competitor pricing.&lt;/p&gt;

&lt;p&gt;Key Drivers of Transformation&lt;br&gt;
✔ Big Data &amp;amp; Cloud Computing – Enables processing vast datasets at scale.&lt;br&gt;
✔ AI &amp;amp; Machine Learning – Automates insights and predictions.&lt;br&gt;
✔ IoT &amp;amp; Real-Time Analytics – Provides instant decision-making capabilities.&lt;br&gt;
✔ Automation &amp;amp; RPA – Streamlines repetitive tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenges&lt;/strong&gt;&lt;br&gt;
Data privacy &amp;amp; security concerns.&lt;br&gt;
Need for skilled data scientists.&lt;br&gt;
Bias in AI models.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Data science and analytics are revolutionizing industries by making operations smarter, more efficient, and customer-centric. Companies that leverage these technologies gain a competitive edge, while laggards risk falling behind.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>SQL Aggregate Functions for beginners</title>
      <dc:creator>Mercy Jeruto</dc:creator>
      <pubDate>Tue, 15 Apr 2025 10:04:58 +0000</pubDate>
      <link>https://dev.to/miley775/sql-aggregate-functions-for-beginners-3chf</link>
      <guid>https://dev.to/miley775/sql-aggregate-functions-for-beginners-3chf</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4zbkevr19pggan2lmgg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4zbkevr19pggan2lmgg.jpg" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;SQL AGGREGATE FUNCTIONS&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Data aggregation is the process of taking several rows of data and condensing them into a single result or summary. When dealing with large datasets, this is invaluable because it allows you to extract relevant insights without having to scrutinize each individual data point.&lt;/p&gt;

&lt;p&gt;So, what exactly are SQL aggregate functions? They are specialized functions that perform calculations on groups of variables and return a single result. Unlike traditional functions, aggregate functions work on groups of rows of data. This allows you to efficiently compute statistics or generate summary information from a dataset.&lt;/p&gt;

&lt;p&gt;In this article, we will look at the importance of SQL aggregate functions and how to use them. We’ll explain them using real-world examples.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnqt7oahpsp0pd6to5amo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnqt7oahpsp0pd6to5amo.jpg" alt=" " width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's explore each of them below;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;COUNT()&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The COUNT() functions objective is to count the number of rows in a table or the number of non-null values in a column.&lt;/p&gt;

&lt;p&gt;Suppose you want to find out how many products are sold in your store; you can use the following query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT COUNT(*) as total_products
FROM products;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.SUM()&lt;/p&gt;

&lt;p&gt;The SUM() function returns the total of a numerical column. It is typically used when you need to find the total of values such as sales income, quantities, or expenses.  Imagine that you want to know your company's entire revenue from sales; you can do so by running the following query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT SUM(sales_amount) as total_revenue
FROM sales_data;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.AVG()&lt;br&gt;
When you need to calculate the average (mean) value of a numeric column, the AVG() function is your go-to. It is useful when looking for the average price, rating, units sold, and so on. Here is an example in a query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT AVG(Price)
FROM Products;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.MIN() and MAX()&lt;/p&gt;

&lt;p&gt;The MIN() function returns the smallest value within a column. It's especially useful for locating the lowest or smallest value in a dataset. On the other hand, the MAX() function returns the largest value within a column. It is useful for determining the highest value in a dataset. An example respectively;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT MIN(price) 
FROM pieces;

SELECT MAX(price)
FROM pieces;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other functions include;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fny2snol6r13rg3i51kbm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fny2snol6r13rg3i51kbm.jpg" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's break down how ORDER BY, GROUP BY, HAVING, and LIMIT work in SQL with a concise example.&lt;br&gt;
Example;&lt;br&gt;
Suppose you have a table named sales with the following columns:&lt;br&gt;
• id (integer)&lt;br&gt;
• product (varchar)&lt;br&gt;
• quantity (integer)&lt;br&gt;
• price (decimal)&lt;br&gt;
• sale_date (date)&lt;br&gt;
SQL Query Explanation&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; GROUP BY: This clause groups rows that have the same values in specified columns into summary rows.&lt;/li&gt;
&lt;li&gt; HAVING: This clause filters groups based on a condition, similar to WHERE but for groups.&lt;/li&gt;
&lt;li&gt; ORDER BY: This clause sorts the result set by specified column(s).&lt;/li&gt;
&lt;li&gt; LIMIT: This clause restricts the number of rows returned.
Example Query
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
    product, 
    SUM(quantity) AS total_quantity, 
    SUM(price * quantity) AS total_sales
FROM 
    sales
GROUP BY 
    product
HAVING 
    SUM(quantity) &amp;gt; 100
ORDER BY 
    total_sales DESC
LIMIT 
    10;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation of the Query&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; SELECT: Choose the columns to display. Here, we select product, the sum of quantity as total_quantity, and the sum of price * quantity as total_sales.&lt;/li&gt;
&lt;li&gt; FROM: Specify the table to query, which is sales.&lt;/li&gt;
&lt;li&gt; GROUP BY: Group the results by product.&lt;/li&gt;
&lt;li&gt; HAVING: Filter groups where the total quantity is greater than 100.&lt;/li&gt;
&lt;li&gt; ORDER BY: Sort the results by total_sales in descending order.&lt;/li&gt;
&lt;li&gt; LIMIT: Return only the top 10 rows.
This query will give you the top 10 products with the highest total sales, but only for those products where the total quantity sold is greater than 100.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Feel free to adapt these examples to fit your specific needs! &lt;/p&gt;

&lt;p&gt;Remember practice makes perfect&lt;br&gt;
Good Luck!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
