0.9 C
New York
Friday, December 13, 2024

Your New Go-To for Time-Sequence Knowledge Visualization


Introducing KitikiPlot, a Python library designed for visualizing sequential and time-series categorical “Sliding Window” patterns. This revolutionary instrument is designed to empower knowledge practitioners throughout numerous fields, together with genomics, air high quality monitoring, and climate forecasting to uncover insights with enhanced readability and precision. Designed with simplicity and flexibility, it integrates seamlessly with Python’s knowledge ecosystem whereas providing visually interesting outputs for sample recognition. Let’s discover its potential, and rework the best way of analyzing categorical sequences.

Studying Targets

  • Perceive the KitikiPlot sliding window visualization approach for sequential and time-series categorical knowledge.
  • Discover its parameters to tailor visualizations for particular datasets and functions.
  • Apply KitikiPlot throughout numerous domains, together with genomics, climate evaluation, and air high quality monitoring.
  • Develop proficiency in visualizing advanced knowledge patterns utilizing Python and Matplotlib.
  • Acknowledge the importance of visible readability in categorical knowledge evaluation to reinforce decision-making processes.

This text was revealed as part of the Knowledge Science Blogathon.

KitikiPlot: Simplify Complicated Knowledge Visualization

KitikiPlot is a robust visualization instrument designed to simplify advanced knowledge evaluation, particularly for functions like sliding window graphs and dynamic knowledge illustration. It gives flexibility, vibrant visualizations, and seamless integration with Python, making it supreme for domains similar to genomics, air high quality monitoring, and climate forecasting. With its customizable options, KitikiPlot transforms uncooked knowledge into impactful visuals effortlessly.

  • KitikiPlot is a Python library for visualizing sequential and time-series categorical “Sliding Window” knowledge.
  • The time period ‘kitiki‘(కిటికీ) means ‘window‘ in Telugu.

Key Options

  • Sliding Window: The visible illustration consists of a number of rectangular bars, every equivalent to knowledge from a particular sliding window.
  • Body: Every bar is split into a number of rectangular cells referred to as “Frames.” These frames are organized side-by-side, every representing a price from the sequential categorical knowledge.
  • Customization Choices: Customers can customise home windows extensively, together with choices for shade maps, hatching patterns, and alignments.
  • Versatile Labeling: The library permits customers to regulate labels, titles, ticks, and legends in line with their preferences.

Getting Began: Your First Steps with KitikiPlot

Dive into the world of KitikiPlot with this quick-start information. From set up to your first visualization, we’ll stroll you thru each step to make your knowledge shine.

Set up KitikiPlot utilizing pip

pip set up kitikiplot

Import “kitikiplot”

import pandas as pd
from kitikiplot import KitikiPlot

Load the dataframe

Thought-about the information body ‘weatherHistory.csv’ from https://www.kaggle.com/datasets/muthuj7/weather-dataset.

df= pd.read_csv( PATH_TO_CSV_FILE )
print("Form: ", df.form)
df= df.iloc[45:65, :]
print("Form: ", df.form)
df.head(3)
data set KitikiPlot
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( ) 
Load the dataframe: KitikiPlot

Understanding KitikiPlot Parameters

To completely leverage the ability of KitikiPlot, it’s important to grasp the varied parameters that management how your knowledge is visualized. These parameters permit you to customise points similar to window measurement, step intervals, and different settings, making certain your visualizations are tailor-made to your particular wants. On this part, we’ll break down key parameters like stride and window_length that will help you fine-tune your plots for optimum outcomes.

stride : int (optionally available)

  • The variety of components to maneuver the window after every iteration when changing a listing to a DataFrame.
  • Default is 1.
index= 0
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist(), stride= 2 )
ktk.plot( cell_width= 2, transpose= True )
stride: KitikiPlot

window_length : int (optionally available)

  • The size of every window when changing a listing to a DataFrame.
  • Default is 10.
index= 0

ktk= KitikiPlot( knowledge= df["Summary"].values.tolist(), window_length= 5 )

ktk.plot( transpose= True,
          xtick_prefix= "Body",
          ytick_prefix= "Window",
          cell_width= 2 )   
window_length : KitikiPlot

figsize : tuple (optionally available)

  • The scale of the determine (width, peak).
  • Default is (25, 5).
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( figsize= (20, 8) )
figsize: KitikiPlot

cell_width : float

  • The width of every cell within the grid.
  • Default is 0.5.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( cell_width= 2 )
cell_width: KitikiPlot

cell_height : float

  • The peak of every cell within the grid.
  • Default is 2.0.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( cell_height= 3 )
cell_height : KitikiPlot

transpose : bool (optionally available)

  • A flag indicating whether or not to transpose the KitikiPlot.
  • Default is False.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( transpose= False )
transpose: KitikiPlot
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( 
            cell_width= 2,
            transpose= True,
            xtick_prefix= "Body",
            ytick_prefix= "Window",
            xlabel= "Frames",
            ylabel= "Sliding_Windows" )
transpose: KitikiPlot

window_gap : float

  • The hole between cells within the grid.
  • Default is 1.0.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( window_gap= 3 )
window_gap: KitikiPlot

window_range : str or tuple (optionally available)

  • The vary of home windows to show.
  • Use “all” to indicate all home windows or specify a tuple (start_index, end_index).
  • Default is “all”.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( window_range= "all" )
window_range: KitikiPlot
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( window_range= (3,8) )
window_range1: KitikiPlot

align : bool

  • A flag indicating whether or not to shift consecutive bars vertically (if transpose= False), andhorizontally(if transpose= True) by stride worth.
  • Default is True.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( align= True )
KitikiPlot
ktk.plot( 
         align= False,
         display_yticks= False # Show no yticks
        )
align1: KitikiPlot
ktk.plot( 
         cell_width= 2, 
         align= True, 
         transpose= True, 
         xlabel= "Frames",
         ylabel= "Sliding Home windows",
         xtick_prefix= "Body",
         ytick_prefix= "Window"
        )
align2
ktk.plot( 
         cell_width= 2, 
         align= False, 
         transpose= True,
         xlabel= "Frames",
         ylabel= "Sliding Home windows",
         ytick_prefix= "Window",
         display_xticks= False 
        )
align3 KitikiPlot

cmap : str or dict

  • If a string, it must be a colormap title to generate colours.
  • If a dictionary, it ought to map distinctive values to particular colours.
  • Default is ‘rainbow’.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( 
          cmap= "Greens",
          display_legend= True
        )
cmap
ktk.plot( 
          cmap= {"Largely Cloudy": "Inexperienced"},
          display_legend= True
        )
edge_color

edge_color : str

  • The colour to make use of for the perimeters of the rectangle.
  • Default is ‘#000000’.
ktk.plot( 
          cmap= {"Largely Cloudy": "Inexperienced"},
          fallback_color= "wheat",
          edge_color= "blue",
        )
edge_color

fallback_color : str

  • The colour to make use of as fallback if no particular shade is assigned.
  • Default is ‘#FAFAFA’.
ktk.plot( 
          cmap= {"Largely Cloudy": "Inexperienced"},
          fallback_color= "wheat",
          display_legend= True
        )
fallback_color

hmap : dict

  • A dictionary mapping distinctive values to their corresponding hatch patterns.
  • Default is ‘{}’.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( 
          cmap= {"Largely Cloudy": "gray"},
          fallback_color= "white",
          hmap= *,
          display_hatch= True
        )
fallback_hatch; kitka

fallback_hatch : str

  • The hatch sample to make use of as fallback if no particular hatch is assigned.
  • Default is ‘” “‘ (string with single area).
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( 
          cmap= {"Largely Cloudy": "gray"},
          fallback_color= "white",
          hmap= *,
          fallback_hatch= "",
          display_hatch= True
        )
fallback_hatch str

display_hatch : bool

  • A flag indicating whether or not to show hatch patterns on cells.
  • Default is False.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )

ktk.plot( 
          cmap= {"Largely Cloudy": "#ffffff"},
          fallback_color= "white",
          display_hatch= True
        )
display hatch

xlabel : str (optionally available)

  • Label for the x-axis.
  • Default is “Sliding Home windows”.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( xlabel= "Commentary Window" )
"

ylabel : str (optionally available)

  • Label for the y-axis.
  • Default is “Frames”.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( ylabel= "Body ID" )
 ylabel

display_xticks : bool (optionally available)

  • A flag indicating whether or not to show xticks.
  • Default is True.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( display_xticks= False )
display_xticks

display_yticks : bool (optionally available)

  • A flag indicating whether or not to show yticks
  • Default is True
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( display_yticks= False )
display_yticks

xtick_prefix : str (optionally available)

  • Prefix for x-axis tick labels.
  • Default is “Window”.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( xtick_prefix= "Commentary" )
xtick_prefix

ytick_prefix : str (optionally available)

  • Prefix for y-axis tick labels.
  • Default is “Body”.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( ytick_prefix= "Time" )
ytick_prefix : str (optional)

xticks_values : checklist (optionally available)

  • Record containing the values for xticks
  • Default is []
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
xtick_values= ['Start', "T1", "T2", "T3", "T4", "T5", "T6", "T7", "T8", "T9", "End"]
ktk.plot( xticks_values= xtick_values )
xticks_values

yticks_values : checklist (optionally available)

  • Record containing the values for yticks
  • Default is []
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )

yticks_values= [(str(i.hour)+" "+i.strftime("%p").lower()) for i in  pd.to_datetime(df["Formatted Date"])]
ktk.plot( yticks_values= yticks_values )
yticks_values : list (optional)

xticks_rotation : int (optionally available)

  • Rotation angle for x-axis tick labels.
  • Default is 0.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( xticks_rotation= 45 )
xticks_rotation : int (optional)

yticks_rotation : int (optionally available)

  • Rotation angle for y-axis tick labels.
  • Default is 0.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )

ktk.plot( figsize= (20, 8),     # Improve peak of the plot for good visualization (right here)
          yticks_rotation= 45 
        )
yticks_rotation : int (optional)

title : str (optionally available)

  • The title of the plot.
  • Default is “KitikiPlot: Intuitive Visualization for Sliding Window”.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( title= "KitikiPlot for Climate Dataset")
title : str (optional)

display_grid : bool (optionally available)

  • A flag indicating whether or not to show grid on the plot.
  • Default is False.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist()[:15] )
ktk.plot( display_grid= True )
display_grid : bool (optional)
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist()[:15] )

ktk.plot( 
          cell_width= 2,
          transpose= True,  
          xlabel= "Frames",
          ylabel= "Sliding Home windows",
          ytick_prefix= "Window",
          display_xticks= False,
          display_grid= True 
        )
display_grid : bool (optional)

display_legend : bool (optionally available)

  • A flag indicating whether or not to show a legend on the plot.
  • Default is False.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )
ktk.plot( display_legend= True )
display_legend : bool (optional)

legend_hatch : bool (optionally available)

  • A flag indicating whether or not to incorporate hatch patterns within the legend.
  • Default is False.
ktk= KitikiPlot( knowledge= df["Summary"].values.tolist() )

ktk.plot( 
          cmap= {"Largely Cloudy": "#ffffff"},
          fallback_color= "white",
          display_hatch= True,
          display_legend= True,
          legend_hatch= True
        )
legend_hatch : bool (optional)

legend_kwargs : dict (optionally available)

  • Extra key phrase arguments handed to customise the legend.
  • Default is {}.

Place legend exterior of the Plot

ktk= KitikiPlot( knowledge= df["Summary"].values.tolist()[:15] )

ktk.plot( 
        figsize= (15, 5),
        display_legend= True,
        legend_kwargs= {"bbox_to_anchor": (1, 1.0), "loc":"higher left"} )
Place legend outside of the Plot

Set title for the legend————————————

ktk= KitikiPlot( knowledge= df["Summary"].values.tolist()[:15] )

ktk.plot( 
          figsize= (15, 5),
          display_legend= True,
          legend_kwargs= {"title": "Climate Situations"} 
        )
Set title for the legend

Change edgecolor of the legend

ktk= KitikiPlot( knowledge= df["Summary"].values.tolist()[:15] )

ktk.plot( 
          figsize= (15, 5),
          display_legend= True,
          legend_kwargs= {"edgecolor": "lime"} 
        )
Change edgecolor of the legend

kitiki_cell_kwargs : dict (optionally available)

  • Extra key phrase arguments handed to customise particular person cells.
  • Default is {}.

Set the road type

ktk= KitikiPlot( knowledge= df["Summary"].values.tolist()[:15] )

ktk.plot( 
        figsize= (15, 5),
        kitiki_cell_kwargs= {"linestyle": "--"} )
Set the line style

Alter the road width

ktk= KitikiPlot( knowledge= df["Summary"].values.tolist()[:15] )

ktk.plot( 
        figsize= (15, 5),
        kitiki_cell_kwargs= {"linewidth": 3} )
Adjust the line width: KitikiPlot

Alter the alpha

ktk= KitikiPlot( knowledge= df["Summary"].values.tolist()[:15] )

ktk.plot( 
        figsize= (15, 5),
        kitiki_cell_kwargs= {"alpha": 0.4} )
Adjust the alpha: KitikiPlot

Actual-World Purposes of KitikiPlot

KitikiPlot excels in numerous fields the place knowledge visualization is essential to understanding advanced patterns and tendencies. From genomics and environmental monitoring to finance and predictive modeling, KitikiPlot empowers customers to remodel uncooked knowledge into clear, actionable insights. Whether or not you’re analyzing massive datasets, monitoring air high quality over time, or visualizing tendencies in inventory costs, KitikiPlot gives the flexibleness and customization wanted to satisfy the distinctive calls for of varied industries.

Genomics

  • KitikiPlot permits clear visualization of gene sequences, serving to researchers establish patterns and motifs.
  • It facilitates the evaluation of structural variations in genomes, important for understanding genetic problems.
  • By offering visible representations, it aids in deciphering advanced genomic knowledge, supporting developments in customized medication.

Dataset URL: https://archive.ics.uci.edu/dataset/69/molecular+biology+splice+junction+gene+sequences

# Import crucial libraries
from kitikiplot import KitikiPlot
import pandas as pd

# Load the dataset
df= pd.read_csv( "datasets/molecular+biology+splice+junction+gene+sequences/splice.knowledge", header= None )

# Rename the columns
df.columns= ["Label", "Instance_Name", "Nucleotide_Sequence"]

# Choose 3 gene sequences randomly
df= df.pattern(3, random_state= 1)

# Take away the white areas from the "Nucleotide_Sequence"
df["Nucleotide_Sequence"]= df["Nucleotide_Sequence"].str.strip()

df
Real-World Applications of KitikiPlot
index= 0

ktk= KitikiPlot( knowledge= [i for i in df.iloc[index, 2]], stride= 1, window_length= len(df.iloc[index, 2]) )

ktk.plot(
        figsize= (20, 0.5),
        cell_width= 2,
        cmap= {'A': '#007FFF', 'T': "#fffc00", "G": "#00ff00", "C": "#960018"},
        transpose= True,
        xlabel= "Nucleotides",
        ylabel= "Sequence",
        display_yticks= False,
        xtick_prefix= "Nucleotide",
        xticks_rotation= 90,
        title= "Genome Visualization: "+df.iloc[index, 1].strip()+", Label : "+df.iloc[index,0].strip(),
        display_legend= True,
        legend_kwargs= {"bbox_to_anchor": (1.01, 1), "loc":'higher left', "borderaxespad": 0.})
Genome kitikiplot

Climate Forecasting

  • The library can successfully symbolize temporal climate knowledge, similar to temperature and humidity, over sequential time home windows to establish tendencies.
  • This visualization aids in detecting patterns and fluctuations in climate situations, enhancing the accuracy of forecasts.
  • Moreover, it helps the evaluation of historic knowledge, permitting for higher predictions and knowledgeable decision-making concerning weather-related actions.

Dataset URL: https://www.kaggle.com/datasets/muthuj7/weather-dataset

# Import crucial libraries
from kitikiplot import KitikiPlot
import pandas as pd

# Learn csv
df= pd.read_csv( "datasets/weatherHistory/weatherHistory.csv")
print("Form: ", df.form)

# Choose a subset of knowledge for visualization
df= df.iloc[45:65, :]
print("Form: ", df.form)

df.head(3)
Weather_DataFrame: KitikiPlot
index= 0

weather_data= ['Mostly Cloudy', 'Overcast', 'Overcast', 'Overcast', 'Overcast', 'Overcast','Overcast', 'Overcast', 
               'Overcast', 'Mostly Cloudy', 'Mostly Cloudy', 'Partly Cloudy', 'Partly Cloudy', 'Partly Cloudy', 
               'Partly Cloudy', 'Mostly Cloudy', 'Mostly Cloudy', 'Mostly Cloudy', 'Mostly Cloudy', 'Mostly Cloudy']
time_period= ['21 pm', '22 pm', '23 pm', '0 am', '1 am', '2 am', '3 am', '4 am', '5 am', '6 am', '7 am', '8 am', 
              '9 am', '10 am', '11 am', '12 pm', '13 pm', '14 pm', '15 pm', '16 pm']
ktk= KitikiPlot( knowledge= weather_data, stride= 1, window_length= 10 )
ktk.plot(
        figsize= (20, 5),
        cell_width= 2,
        transpose= False,
        xlabel= "Window",
        ylabel= "Time",
        yticks_values= time_period,
        xticks_rotation= 90, 
        cmap= {"Largely Cloudy": "brown", "Partly Cloudy": "#a9cbe0","Overcast": "#fdbf6f"},
        legend_kwargs= {"bbox_to_anchor": (1.01, 1), "loc":'higher left', "borderaxespad": 0.},
        display_legend= True,
        title= "Climate Sample on 10-04-2006")
Weather_DataFrame: KitikiPlot

Air High quality Monitoring

  • Customers can analyze pollutant ranges over time with KitikiPlot to detect variations and correlations in environmental knowledge.
  • This functionality permits for the identification of tendencies in air high quality, facilitating a deeper understanding of how completely different pollution work together and fluctuate as a result of numerous elements.
  • Moreover, it helps the exploration of temporal relationships between air high quality indices and particular pollution, enhancing the effectiveness of air high quality monitoring efforts.

Dataset URL: https://archive.ics.uci.edu/dataset/360/air+high quality

from kitikiplot import KitikiPlot
import pandas as pd

# Learn excel
df= pd.read_excel( "datasets/air+high quality/AirQualityUCI.xlsx" ) 

# Extract knowledge from in the future (2004-11-01)
df= df[ df['Date']== "2004-11-01" ]
print("Form : ", df.form)
df.head( 3 )

# Convert float to int
df["CO(GT)"]= df["CO(GT)"].astype(int)
Air Quality Monitoring: KitikiPlot
CO_values= [3, 3, 3, 3, -200, 2, 1, 1, 1, 1, 2, 3, 4, 4, 3, 3, 3, 2]
time_period= ['0 am', '1 am', '2 am', '3 am', '4 am', '5 am', '6 am', '7 am', '8 am', '9 am', '10 am',
              '11 am', '12 pm', '13 pm', '14 pm', '15 pm', '16 pm', '17 pm']
ktk= KitikiPlot( knowledge= CO_values )
ktk.plot(
        figsize= (20, 5),
        cell_width= 2,
        cmap= {-200: "cornflowerblue", 1: "#ffeaea", 2: "#feb9b9", 3: "#ff7070", 4: "#b00"},
        transpose= True,
        xlabel= "Time",
        ylabel= "Sliding Home windows of CO(GT) values (in mg/m^3)",
        display_xticks= True,
        xticks_values= time_period,
        ytick_prefix= "Window",
        xticks_rotation= 90, 
        display_legend= True,
        title= "CO(GT) Development in Air",
        legend_kwargs= {"bbox_to_anchor": (1.01, 1), "loc":'higher left', "borderaxespad": 0.})
KitikiPlot

Conclusion

KitikiPlot simplifies the visualization of sequential and time-series categorical sliding window knowledge, making advanced patterns extra interpretable. Its versatility spans numerous functions, together with genomics, climate evaluation, and air high quality monitoring, highlighting its broad utility in each analysis and trade. With a concentrate on readability and value, KitikiPlot enhances the extraction of actionable insights from categorical knowledge. As an open-source library, it empowers knowledge scientists and researchers to successfully sort out numerous challenges. 

Key Takeaways

  • KitikiPlot is a flexible Python library designed for exact and user-friendly sliding window knowledge visualizations.
  • Its customizable parameters permit customers to create significant and interpretable visualizations tailor-made to their datasets.
  • The library helps a variety of real-world functions throughout numerous analysis and trade domains.
  • As an open-source instrument, KitikiPlot ensures accessibility for knowledge science practitioners and researchers alike.
  • Clear and insightful visualizations facilitate the identification of tendencies in sequential categorical knowledge.

Assets

Quotation

@software program{ KitikiPlot_2024
writer = {Boddu Sri Pavan and Boddu Swathi Sree},
title = {{KitikiPlot: A Python library to visualise categorical sliding window knowledge}},
yr = {2024},
model = {0.1.2},
url = {url{https://github.com/BodduSriPavan-111/kitikiplot},
doi = {10.5281/zenodo.14293030}
howpublished = {url{https://github.com/BodduSriPavan-111/kitikiplot}}
}

Ceaselessly Requested Questions

Q1. What kind of knowledge is KitikiPlot designed for?

A. KitikiPlot focuses on visualizing sequential and time-series categorical knowledge utilizing a sliding window strategy.

Q2. Can I exploit KitikiPlot for non-categorical knowledge?

A. Whereas primarily supposed for categorical knowledge, KitikiPlot will be tailored for different knowledge sorts via inventive preprocessing strategies, similar to discretization, and so on,.

Q3. Is KitikiPlot appropriate with fashionable Python knowledge libraries?

A. Sure, KitikiPlot integrates seamlessly with fashionable libraries like Pandas and Matplotlib for efficient preprocessing and enhanced visualization.

The media proven on this article isn’t owned by Analytics Vidhya and is used on the Writer’s discretion.

Over a yr of working expertise as an AI ML Engineer, I’ve developed state-of-the-art fashions for human physique posture recognition, hand and mouth gesture recognition techniques with +90% accuracies. I stay up for proceed my work on data-driven machine studying.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles