SlideShare uma empresa Scribd logo
1 de 24
Data Visualization in
  Python/Django
   By KENNETH EMEKA ODOH
     By KENNETH EMEKA
     ODOH
Table of Contents
Introduction
Motivation
Method
Appendices
Conclusion
References
Introduction
 My background
 Requirements (
 Python, Django, Matplotlib, ajax ) and other
 third-party libraries.

 What this talk is not about ( we are not trying
 to re-implement Google analytics ).

 Source codes are available at (
  https://github.com/kenluck2001/PyCon2012
  _Talk ).
"Everything should be made as simple as
MOTIVATION
There is a need to represent the business
 analytic data in a graphical form. This because
 a picture speaks more than a thousand words.




   Source: en.wikipedia.org
Where do we find
data?




   Source: en.wikipedia.org
Sources of Data

• CSV
• DATABASES
Data Processing
 Identify the data source.
 Preprocessing of the data (
  removing nulls, wide characters
  ) e.g. Google refine.
 Actual data processing.
 Present the clean data in
  descriptive format. i.e. Data
  visualization
   See Appendix 1
Visual Representation of
            data
     Charts / Diagram format
     Texts format
      Tables
      Log files




Source: devk2.wordpress.com   Source: elementsdatabase.com
Categorization of data
Real-time
 See Appendix 2
Batch-based
  See Appendix 2
Rules of Data Collection
 Keep data in the easiest
  processable form e.g
  database, csv
 Keep data collected with
  timestamp.
 Gather data that are relevant to
  the business needs.
 Remove old data
Where is the data
   visualization done?
 Server
  See Appendix from 2 - 6
 Client
  Examples of Javascript library
  DS.js ( http://d3js.org/ )
  gRaphael.js (
   http://g.raphaeljs.com/ )
Factors to Consider for
Choice of Visualization
 Where do we perform the
  visualization processing?
 Is it Server or Client?


It depends
 Security
 Scalability
Tools needed for data
analysis
 Csvkit (
  http://csvkit.readthedocs.org/en/latest/ )
 networkx ( http://networkx.lanl.gov/ )
 pySAL ( http://code.google.com/p/pysal/
  )
Appendices
Let the codes begin




     Source:
     caseinsights.com
Appendix 1
## This describes a scatter plot of solar radiation against the month.
This aim to describe the steps of data gathering.CSV file from data science
hackathon website. The source code is available in a folder named
“plotCode”

import csv
from matplotlib.backends.backend_agg
import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

def prepareList(month_most_common_list):
''' Prepare the input for process by removing all unnecessary values. Replace "NA"
with 0''„
    output_list = []
    for x in month_most_common_list:
    if x != 'NA':
        output_list.append(x)
    else:
        output_list.append(0)
    return output_list
Appendix 1
def plotSolarRadiationAgainstMonth(filename):
                                                                contd.
  trainRowReader = csv.reader(open(filename, 'rb'), delimiter=',')
  month_most_common_list = []
  Solar_radiation_64_list = []
  for row in trainRowReader:
      month_most_common = row[3]
      Solar_radiation_64 = row[6]
      month_most_common_list.append(month_most_common)
      Solar_radiation_64_list.append(Solar_radiation_64)
  #convert all elements in the list to float while skipping the first element for the 1st element is a
description of the field.
  month_most_common_list = [float(i) for i in prepareList(month_most_common_list)[1:] ]
  Solar_radiation_64_list = [float(i) for i in prepareList(Solar_radiation_64_list)[1:] ]
  fig=Figure()
  ax=fig.add_subplot(111)
  title='Scatter Diagram of solar radiation against month of the year'
  ax.set_xlabel('Most common month')
  ax.set_ylabel('Solar Radiation')
  fig.suptitle(title, fontsize=14)
  try:
      ax.scatter(month_most_common_list, Solar_radiation_64_list)
      #it is possible to make other kind of plots e.g bar charts, pie charts, histogram
  except ValueError:
      pass
  canvas = FigureCanvas(fig)
  canvas.print_figure('solarRadMonth.png',dpi=500)

  if __name__ == "__main__":
      plotSolarRadiationAgainstMonth('TrainingData.csv')
Appendix 2
From the project in folder named WebMonitor

class LoadEvent:
…
def fillMonitorModel(self):
   for monObj in self.monitorObjList:
      mObj = Monitor(url = monObj[2], httpStatus =
monObj[0], responseTime = monObj[1], contentStatus
= monObj[5])
      mObj.save()

#also see the following examples in project named
YAAStasks.py This shows how the analytic tables are
loaded with real-time data.
Appendix 3
from django.http import HttpResponse
from matplotlib.backends.backend_agg
import FigureCanvasAgg as FigureCanvasfrom matplotlib.figure
import Figurefrom YAAS.stats.models import RegisteredUser, OnlineUser, StatBid #scatter diagram of number of bids
made against number of online users
# weekly report
@staff_member_required
def weeklyScatterOnlinUsrBid(request, week_no):
   page_title='Weekly Scatter Diagram based on Online user verses Bid'
   weekno=week_no
   fig=Figure()
   ax=fig.add_subplot(111)
   year=stat.getYear()
   onlUserObj = OnlineUser.objects.filter(week=weekno).filter(year=year)
   bidObj = StatBid.objects.filter(week=weekno).filter(year=year)
   onlUserlist = list(onlUserObj.values_list('no_of_online_user', flat=True))
   bidlist = list(bidObj.values_list('no_of_bids', flat=True))
    title='Scatter Diagram of number of online User against number of bids (week {0}){1}'.format(weekno,year)
   ax.set_xlabel('Number of online Users')
   ax.set_ylabel('Number of Bids')
   fig.suptitle(title, fontsize=14)
   try:
       ax.scatter(onlUserlist, bidlist)
    except ValueError:
       pass
   canvas = FigureCanvas(fig)
   response = HttpResponse(content_type='image/png')
   canvas.print_png(response)
   return response

More info. can be found in YAAS/graph/The folder named
"graph"
Appendix 4
# Example of how database may be deleted to recover some space.
From folder named “YAAS”. Check task.py
@periodic_task(run_every=crontab(hour=1, minute=30, day_of_week=
0))
def deleteOldItemsandBids():
   hunderedandtwentydays = datetime.today() -
datetime.timedelta(days=120)
   myItem = Item.objects.filter(end_date__lte=hunderedandtwentydays
).delete()
   myBid = Bid.objects.filter(end_date__lte=hunderedandtwentydays
).delete()#populate the registereduser and onlineuser model at regular
intervals
Appendix 5

Check project in
YAAS/stats/

for more information on
statistical processing
Appendix 6
 # how to refresh the views in django. To keep the charts.
 updated. See WebMonitor project

 {% extends "base.html" %}

 {% block site_wrapper %}
 <div id="messages">Updating tables ...</div>
 <script>
    function refresh() {
       $.ajax({
              url: "/monitor/",
              success: function(data) {
 $('#messages').html(data);
              }
      });
         setInterval("refresh()", 100000);
  }
 $(function(){ refresh(); });
 </script>
 {% endblock %}
References
 Python documentation ( http://www.python.org/ )
 Django documentation (
  https://www.djangoproject.com/ )
 Stack overflow ( http://stackoverflow.com/ )
 Celery documentation
  (http://ask.github.com/celery/)


Pictures
 email logo ( http:// ambrosedesigns.co.uk )
 blog logo ( http:// sociolatte.com )
Thanks for listening
           Follow me using any of


                    @kenluck2001

                    kenluck2001@yahoo.com


                    http://kenluck2001.tumblr.com
                    /

                    https://github.com/kenluck200
                    1

Mais conteúdo relacionado

Mais procurados

Data Visualization Tools in Python
Data Visualization Tools in PythonData Visualization Tools in Python
Data Visualization Tools in PythonRoman Merkulov
 
Data Analysis and Visualization using Python
Data Analysis and Visualization using PythonData Analysis and Visualization using Python
Data Analysis and Visualization using PythonChariza Pladin
 
03. Data Exploration.pptx
03. Data Exploration.pptx03. Data Exploration.pptx
03. Data Exploration.pptxSarojkumari55
 
Introduction to data visualisation with D3
Introduction to data visualisation with D3Introduction to data visualisation with D3
Introduction to data visualisation with D3Aleksander Fabijan
 
The Basics of Statistics for Data Science By Statisticians
The Basics of Statistics for Data Science By StatisticiansThe Basics of Statistics for Data Science By Statisticians
The Basics of Statistics for Data Science By StatisticiansStat Analytica
 
Data Visualization in Python
Data Visualization in PythonData Visualization in Python
Data Visualization in PythonJagriti Goswami
 
Predictive Analysis Powerpoint Presentation Slides
Predictive Analysis Powerpoint Presentation SlidesPredictive Analysis Powerpoint Presentation Slides
Predictive Analysis Powerpoint Presentation SlidesSlideTeam
 
Data visualization & Story Telling with Data
Data visualization & Story Telling with DataData visualization & Story Telling with Data
Data visualization & Story Telling with DataDr Nisha Arora
 
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ..."Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ...Hunter Whitney
 
ML - Multiple Linear Regression
ML - Multiple Linear RegressionML - Multiple Linear Regression
ML - Multiple Linear RegressionAndrew Ferlitsch
 
Data Visualization Trends - Next Steps for Tableau
Data Visualization Trends - Next Steps for TableauData Visualization Trends - Next Steps for Tableau
Data Visualization Trends - Next Steps for TableauArunima Gupta
 
Anomaly detection in plain static graphs
Anomaly detection in plain static graphsAnomaly detection in plain static graphs
Anomaly detection in plain static graphsdash-javad
 

Mais procurados (20)

Text Classification
Text ClassificationText Classification
Text Classification
 
Data Analysis in Python
Data Analysis in PythonData Analysis in Python
Data Analysis in Python
 
Data Visualization Tools in Python
Data Visualization Tools in PythonData Visualization Tools in Python
Data Visualization Tools in Python
 
Data Analysis and Visualization using Python
Data Analysis and Visualization using PythonData Analysis and Visualization using Python
Data Analysis and Visualization using Python
 
Anomaly detection
Anomaly detectionAnomaly detection
Anomaly detection
 
What is Jupyter Notebook?
What is Jupyter Notebook?What is Jupyter Notebook?
What is Jupyter Notebook?
 
03. Data Exploration.pptx
03. Data Exploration.pptx03. Data Exploration.pptx
03. Data Exploration.pptx
 
Introduction to data visualisation with D3
Introduction to data visualisation with D3Introduction to data visualisation with D3
Introduction to data visualisation with D3
 
Data visualization
Data visualizationData visualization
Data visualization
 
The Basics of Statistics for Data Science By Statisticians
The Basics of Statistics for Data Science By StatisticiansThe Basics of Statistics for Data Science By Statisticians
The Basics of Statistics for Data Science By Statisticians
 
Data Wrangling
Data WranglingData Wrangling
Data Wrangling
 
Data Visualization in Python
Data Visualization in PythonData Visualization in Python
Data Visualization in Python
 
Predictive Analysis Powerpoint Presentation Slides
Predictive Analysis Powerpoint Presentation SlidesPredictive Analysis Powerpoint Presentation Slides
Predictive Analysis Powerpoint Presentation Slides
 
Data visualization & Story Telling with Data
Data visualization & Story Telling with DataData visualization & Story Telling with Data
Data visualization & Story Telling with Data
 
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ..."Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
 
Data Visualization.pptx
Data Visualization.pptxData Visualization.pptx
Data Visualization.pptx
 
ML - Multiple Linear Regression
ML - Multiple Linear RegressionML - Multiple Linear Regression
ML - Multiple Linear Regression
 
Data Visualization Trends - Next Steps for Tableau
Data Visualization Trends - Next Steps for TableauData Visualization Trends - Next Steps for Tableau
Data Visualization Trends - Next Steps for Tableau
 
Data Visualization - A Brief Overview
Data Visualization - A Brief OverviewData Visualization - A Brief Overview
Data Visualization - A Brief Overview
 
Anomaly detection in plain static graphs
Anomaly detection in plain static graphsAnomaly detection in plain static graphs
Anomaly detection in plain static graphs
 

Destaque

Data visualization by Kenneth Odoh
Data visualization by Kenneth OdohData visualization by Kenneth Odoh
Data visualization by Kenneth Odohpyconfi
 
What is a Deployment Tool and How Can it Help Me?
What is a Deployment Tool and How Can it Help Me?What is a Deployment Tool and How Can it Help Me?
What is a Deployment Tool and How Can it Help Me?XebiaLabs
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
Visdjango presentation django_boston_oct_2014
Visdjango presentation django_boston_oct_2014Visdjango presentation django_boston_oct_2014
Visdjango presentation django_boston_oct_2014jlbaldwin
 
Delineating Cancer Genomics through Data Visualization
Delineating Cancer Genomics through  Data VisualizationDelineating Cancer Genomics through  Data Visualization
Delineating Cancer Genomics through Data VisualizationRupam Das
 
Con-Action Project Midterm Presentation
Con-Action Project Midterm PresentationCon-Action Project Midterm Presentation
Con-Action Project Midterm PresentationJ S
 
Building a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryBuilding a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Using Django for a scientific document analysis (web) application
Using Django for a scientific document analysis (web) applicationUsing Django for a scientific document analysis (web) application
Using Django for a scientific document analysis (web) applicationvanatteveldt
 
Making Sense of Millions of Thoughts: Finding Patterns in the Tweets
Making Sense of Millions of Thoughts: Finding Patterns in the TweetsMaking Sense of Millions of Thoughts: Finding Patterns in the Tweets
Making Sense of Millions of Thoughts: Finding Patterns in the TweetsKrist Wongsuphasawat
 
Adventure in Data: A tour of visualization projects at Twitter
Adventure in Data: A tour of visualization projects at TwitterAdventure in Data: A tour of visualization projects at Twitter
Adventure in Data: A tour of visualization projects at TwitterKrist Wongsuphasawat
 
Titan and Cassandra at WellAware
Titan and Cassandra at WellAwareTitan and Cassandra at WellAware
Titan and Cassandra at WellAwaretwilmes
 
Apache Cassandra for Timeseries- and Graph-Data
Apache Cassandra for Timeseries- and Graph-DataApache Cassandra for Timeseries- and Graph-Data
Apache Cassandra for Timeseries- and Graph-DataGuido Schmutz
 
Coastal Urban DEM project - Mapping the vulnerability of Australia's Coast
Coastal Urban DEM project - Mapping the vulnerability of Australia's CoastCoastal Urban DEM project - Mapping the vulnerability of Australia's Coast
Coastal Urban DEM project - Mapping the vulnerability of Australia's CoastFungis Queensland
 
Digital image processing - What is digital image processign
Digital image processing - What is digital image processignDigital image processing - What is digital image processign
Digital image processing - What is digital image processignE2MATRIX
 
Multi Tenancy With Python and Django
Multi Tenancy With Python and DjangoMulti Tenancy With Python and Django
Multi Tenancy With Python and Djangoscottcrespo
 
Python Visualisation for Data Science
Python Visualisation for Data SciencePython Visualisation for Data Science
Python Visualisation for Data ScienceAmit Kapoor
 
Data science-toolchain
Data science-toolchainData science-toolchain
Data science-toolchainJie-Han Chen
 

Destaque (20)

Data visualization by Kenneth Odoh
Data visualization by Kenneth OdohData visualization by Kenneth Odoh
Data visualization by Kenneth Odoh
 
What is a Deployment Tool and How Can it Help Me?
What is a Deployment Tool and How Can it Help Me?What is a Deployment Tool and How Can it Help Me?
What is a Deployment Tool and How Can it Help Me?
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
Visdjango presentation django_boston_oct_2014
Visdjango presentation django_boston_oct_2014Visdjango presentation django_boston_oct_2014
Visdjango presentation django_boston_oct_2014
 
Delineating Cancer Genomics through Data Visualization
Delineating Cancer Genomics through  Data VisualizationDelineating Cancer Genomics through  Data Visualization
Delineating Cancer Genomics through Data Visualization
 
Con-Action Project Midterm Presentation
Con-Action Project Midterm PresentationCon-Action Project Midterm Presentation
Con-Action Project Midterm Presentation
 
Building a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryBuilding a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Using Django for a scientific document analysis (web) application
Using Django for a scientific document analysis (web) applicationUsing Django for a scientific document analysis (web) application
Using Django for a scientific document analysis (web) application
 
Python Científico
Python CientíficoPython Científico
Python Científico
 
Making Sense of Millions of Thoughts: Finding Patterns in the Tweets
Making Sense of Millions of Thoughts: Finding Patterns in the TweetsMaking Sense of Millions of Thoughts: Finding Patterns in the Tweets
Making Sense of Millions of Thoughts: Finding Patterns in the Tweets
 
Adventure in Data: A tour of visualization projects at Twitter
Adventure in Data: A tour of visualization projects at TwitterAdventure in Data: A tour of visualization projects at Twitter
Adventure in Data: A tour of visualization projects at Twitter
 
Data_Visualization_Project
Data_Visualization_ProjectData_Visualization_Project
Data_Visualization_Project
 
Titan and Cassandra at WellAware
Titan and Cassandra at WellAwareTitan and Cassandra at WellAware
Titan and Cassandra at WellAware
 
Apache Cassandra for Timeseries- and Graph-Data
Apache Cassandra for Timeseries- and Graph-DataApache Cassandra for Timeseries- and Graph-Data
Apache Cassandra for Timeseries- and Graph-Data
 
MATLAB Fundamentals (1)
MATLAB Fundamentals (1)MATLAB Fundamentals (1)
MATLAB Fundamentals (1)
 
Coastal Urban DEM project - Mapping the vulnerability of Australia's Coast
Coastal Urban DEM project - Mapping the vulnerability of Australia's CoastCoastal Urban DEM project - Mapping the vulnerability of Australia's Coast
Coastal Urban DEM project - Mapping the vulnerability of Australia's Coast
 
Digital image processing - What is digital image processign
Digital image processing - What is digital image processignDigital image processing - What is digital image processign
Digital image processing - What is digital image processign
 
Multi Tenancy With Python and Django
Multi Tenancy With Python and DjangoMulti Tenancy With Python and Django
Multi Tenancy With Python and Django
 
Python Visualisation for Data Science
Python Visualisation for Data SciencePython Visualisation for Data Science
Python Visualisation for Data Science
 
Data science-toolchain
Data science-toolchainData science-toolchain
Data science-toolchain
 

Semelhante a Data visualization in python/Django

Django tech-talk
Django tech-talkDjango tech-talk
Django tech-talkdtdannen
 
droidQuery: The Android port of jQuery
droidQuery: The Android port of jQuerydroidQuery: The Android port of jQuery
droidQuery: The Android port of jQueryPhDBrown
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsHassan Abid
 
Art & music vs Google App Engine
Art & music vs Google App EngineArt & music vs Google App Engine
Art & music vs Google App Enginethomas alisi
 
Relevance trilogy may dream be with you! (dec17)
Relevance trilogy  may dream be with you! (dec17)Relevance trilogy  may dream be with you! (dec17)
Relevance trilogy may dream be with you! (dec17)Woonsan Ko
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJoaquim Rocha
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCpootsbook
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019Matt Raible
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django IntroductionGanga Ram
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology updateDoug Domeny
 
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseEclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseHeiko Behrens
 

Semelhante a Data visualization in python/Django (20)

Django tech-talk
Django tech-talkDjango tech-talk
Django tech-talk
 
JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
 
droidQuery: The Android port of jQuery
droidQuery: The Android port of jQuerydroidQuery: The Android port of jQuery
droidQuery: The Android port of jQuery
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
 
Art & music vs Google App Engine
Art & music vs Google App EngineArt & music vs Google App Engine
Art & music vs Google App Engine
 
huhu
huhuhuhu
huhu
 
Android best practices
Android best practicesAndroid best practices
Android best practices
 
Data Science on Google Cloud Platform
Data Science on Google Cloud PlatformData Science on Google Cloud Platform
Data Science on Google Cloud Platform
 
Django crush course
Django crush course Django crush course
Django crush course
 
Relevance trilogy may dream be with you! (dec17)
Relevance trilogy  may dream be with you! (dec17)Relevance trilogy  may dream be with you! (dec17)
Relevance trilogy may dream be with you! (dec17)
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019
 
Spring boot
Spring boot Spring boot
Spring boot
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
 
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseEclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
 

Mais de kenluck2001

Salt Identification Challenge
Salt Identification ChallengeSalt Identification Challenge
Salt Identification Challengekenluck2001
 
Compressed Sensing using Generative Model
Compressed Sensing using Generative ModelCompressed Sensing using Generative Model
Compressed Sensing using Generative Modelkenluck2001
 
Tutorial on Cryptography
Tutorial on CryptographyTutorial on Cryptography
Tutorial on Cryptographykenluck2001
 
Landmark Retrieval & Recognition
Landmark Retrieval & RecognitionLandmark Retrieval & Recognition
Landmark Retrieval & Recognitionkenluck2001
 
Tracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First PrinciplesTracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First Principleskenluck2001
 
Tracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First PrinciplesTracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First Principleskenluck2001
 

Mais de kenluck2001 (7)

Salt Identification Challenge
Salt Identification ChallengeSalt Identification Challenge
Salt Identification Challenge
 
Compressed Sensing using Generative Model
Compressed Sensing using Generative ModelCompressed Sensing using Generative Model
Compressed Sensing using Generative Model
 
Tutorial on Cryptography
Tutorial on CryptographyTutorial on Cryptography
Tutorial on Cryptography
 
Landmark Retrieval & Recognition
Landmark Retrieval & RecognitionLandmark Retrieval & Recognition
Landmark Retrieval & Recognition
 
Tracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First PrinciplesTracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First Principles
 
Tracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First PrinciplesTracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First Principles
 
Kaggle kenneth
Kaggle kennethKaggle kenneth
Kaggle kenneth
 

Último

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Último (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Data visualization in python/Django

  • 1. Data Visualization in Python/Django By KENNETH EMEKA ODOH By KENNETH EMEKA ODOH
  • 3. Introduction  My background  Requirements ( Python, Django, Matplotlib, ajax ) and other third-party libraries.  What this talk is not about ( we are not trying to re-implement Google analytics ).  Source codes are available at ( https://github.com/kenluck2001/PyCon2012 _Talk ). "Everything should be made as simple as
  • 4. MOTIVATION There is a need to represent the business analytic data in a graphical form. This because a picture speaks more than a thousand words. Source: en.wikipedia.org
  • 5. Where do we find data? Source: en.wikipedia.org
  • 6. Sources of Data • CSV • DATABASES
  • 7. Data Processing  Identify the data source.  Preprocessing of the data ( removing nulls, wide characters ) e.g. Google refine.  Actual data processing.  Present the clean data in descriptive format. i.e. Data visualization See Appendix 1
  • 8. Visual Representation of data  Charts / Diagram format  Texts format Tables Log files Source: devk2.wordpress.com Source: elementsdatabase.com
  • 9. Categorization of data Real-time See Appendix 2 Batch-based See Appendix 2
  • 10. Rules of Data Collection  Keep data in the easiest processable form e.g database, csv  Keep data collected with timestamp.  Gather data that are relevant to the business needs.  Remove old data
  • 11. Where is the data visualization done?  Server See Appendix from 2 - 6  Client Examples of Javascript library DS.js ( http://d3js.org/ ) gRaphael.js ( http://g.raphaeljs.com/ )
  • 12. Factors to Consider for Choice of Visualization  Where do we perform the visualization processing?  Is it Server or Client? It depends  Security  Scalability
  • 13. Tools needed for data analysis  Csvkit ( http://csvkit.readthedocs.org/en/latest/ )  networkx ( http://networkx.lanl.gov/ )  pySAL ( http://code.google.com/p/pysal/ )
  • 14. Appendices Let the codes begin Source: caseinsights.com
  • 15. Appendix 1 ## This describes a scatter plot of solar radiation against the month. This aim to describe the steps of data gathering.CSV file from data science hackathon website. The source code is available in a folder named “plotCode” import csv from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure def prepareList(month_most_common_list): ''' Prepare the input for process by removing all unnecessary values. Replace "NA" with 0''„ output_list = [] for x in month_most_common_list: if x != 'NA': output_list.append(x) else: output_list.append(0) return output_list
  • 16. Appendix 1 def plotSolarRadiationAgainstMonth(filename): contd. trainRowReader = csv.reader(open(filename, 'rb'), delimiter=',') month_most_common_list = [] Solar_radiation_64_list = [] for row in trainRowReader: month_most_common = row[3] Solar_radiation_64 = row[6] month_most_common_list.append(month_most_common) Solar_radiation_64_list.append(Solar_radiation_64) #convert all elements in the list to float while skipping the first element for the 1st element is a description of the field. month_most_common_list = [float(i) for i in prepareList(month_most_common_list)[1:] ] Solar_radiation_64_list = [float(i) for i in prepareList(Solar_radiation_64_list)[1:] ] fig=Figure() ax=fig.add_subplot(111) title='Scatter Diagram of solar radiation against month of the year' ax.set_xlabel('Most common month') ax.set_ylabel('Solar Radiation') fig.suptitle(title, fontsize=14) try: ax.scatter(month_most_common_list, Solar_radiation_64_list) #it is possible to make other kind of plots e.g bar charts, pie charts, histogram except ValueError: pass canvas = FigureCanvas(fig) canvas.print_figure('solarRadMonth.png',dpi=500) if __name__ == "__main__": plotSolarRadiationAgainstMonth('TrainingData.csv')
  • 17.
  • 18. Appendix 2 From the project in folder named WebMonitor class LoadEvent: … def fillMonitorModel(self): for monObj in self.monitorObjList: mObj = Monitor(url = monObj[2], httpStatus = monObj[0], responseTime = monObj[1], contentStatus = monObj[5]) mObj.save() #also see the following examples in project named YAAStasks.py This shows how the analytic tables are loaded with real-time data.
  • 19. Appendix 3 from django.http import HttpResponse from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvasfrom matplotlib.figure import Figurefrom YAAS.stats.models import RegisteredUser, OnlineUser, StatBid #scatter diagram of number of bids made against number of online users # weekly report @staff_member_required def weeklyScatterOnlinUsrBid(request, week_no): page_title='Weekly Scatter Diagram based on Online user verses Bid' weekno=week_no fig=Figure() ax=fig.add_subplot(111) year=stat.getYear() onlUserObj = OnlineUser.objects.filter(week=weekno).filter(year=year) bidObj = StatBid.objects.filter(week=weekno).filter(year=year) onlUserlist = list(onlUserObj.values_list('no_of_online_user', flat=True)) bidlist = list(bidObj.values_list('no_of_bids', flat=True)) title='Scatter Diagram of number of online User against number of bids (week {0}){1}'.format(weekno,year) ax.set_xlabel('Number of online Users') ax.set_ylabel('Number of Bids') fig.suptitle(title, fontsize=14) try: ax.scatter(onlUserlist, bidlist) except ValueError: pass canvas = FigureCanvas(fig) response = HttpResponse(content_type='image/png') canvas.print_png(response) return response More info. can be found in YAAS/graph/The folder named "graph"
  • 20. Appendix 4 # Example of how database may be deleted to recover some space. From folder named “YAAS”. Check task.py @periodic_task(run_every=crontab(hour=1, minute=30, day_of_week= 0)) def deleteOldItemsandBids(): hunderedandtwentydays = datetime.today() - datetime.timedelta(days=120) myItem = Item.objects.filter(end_date__lte=hunderedandtwentydays ).delete() myBid = Bid.objects.filter(end_date__lte=hunderedandtwentydays ).delete()#populate the registereduser and onlineuser model at regular intervals
  • 21. Appendix 5 Check project in YAAS/stats/ for more information on statistical processing
  • 22. Appendix 6 # how to refresh the views in django. To keep the charts. updated. See WebMonitor project {% extends "base.html" %} {% block site_wrapper %} <div id="messages">Updating tables ...</div> <script> function refresh() { $.ajax({ url: "/monitor/", success: function(data) { $('#messages').html(data); } }); setInterval("refresh()", 100000); } $(function(){ refresh(); }); </script> {% endblock %}
  • 23. References  Python documentation ( http://www.python.org/ )  Django documentation ( https://www.djangoproject.com/ )  Stack overflow ( http://stackoverflow.com/ )  Celery documentation (http://ask.github.com/celery/) Pictures  email logo ( http:// ambrosedesigns.co.uk )  blog logo ( http:// sociolatte.com )
  • 24. Thanks for listening Follow me using any of @kenluck2001 kenluck2001@yahoo.com http://kenluck2001.tumblr.com / https://github.com/kenluck200 1