Skip to content

Instantly share code, notes, and snippets.

View vb100's full-sized avatar
🎯
Focusing on A.I., ML and Deep Learning

Vytautas Bielinskas vb100

🎯
Focusing on A.I., ML and Deep Learning
View GitHub Profile
@vb100
vb100 / FaceDetection.py
Last active July 11, 2017 19:52
This Python application recognize faces from photo and mark it with green rectangular.
import cv2
face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
img=cv2.imread("news.jpg")
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray_img, scaleFactor=1.1,minNeighbors=5)
@vb100
vb100 / StockAnalysis.py
Last active July 11, 2017 19:52
This Python application read Finance stock data from Google API and represent it in HTML file.
from pandas_datareader import data
import datetime
from bokeh.plotting import figure, show, output_file
x
start = datetime.datetime(2016,11,1)
end = datetime.datetime(2017,2,10)
df = data.DataReader(name="GOOG", data_source="google", start=start, end=end)
#date_increase = df.index[df.Close > df.Open]
#date_decrease = df.index[df.Close < df.Open]
@vb100
vb100 / ParseDataFromWebsiteWithPagination.py
Created July 11, 2017 19:54
This Python application read all data of real estate object directly from webpage. Then wrrite all the data into Panda dataframe and retrieve all the data on terminal.
import requests
from bs4 import BeautifulSoup as bc
l =[] #List
base_url = "http://www.pythonhow.com/real-estate/rock-springs-wy/LCWYROCKSPRINGS/"
r = requests.get(base_url)
c = r.content
soup = bc(c, "html.parser")
@vb100
vb100 / CaptureVideoFromCamera.py
Created July 11, 2017 19:57
Stream live video directly from external camera to Python. Exit with 'Q' key.
import cv2, time
#1. Create an object. Zero for external camera
video=cv2.VideoCapture(0)
#7. Play the video (Indenting)
#8. a variable
a=0
@vb100
vb100 / BatchResizeImages.py
Created July 11, 2017 20:00
Batch resize all JPG images in project folder and save these images as new files in the same folder.
import cv2, glob #glob module - find path names of files
#1. Create a list of files that has extension of JPG
images=glob.glob("*.jpg")
for image in images:
#Read images path
img=cv2.imread(image,1)
#Create a variable where we will store resized image
@vb100
vb100 / TkinterFrontend.py
Last active July 11, 2017 20:05
FrontEnd file read BackEnd with all the functionality and Sqlite3 database, retrieve it and manipulate through Tkinter interface.
from tkinter import *
import backend
def get_selected_row(event):
global selected_tuple
index=list1.curselection()[0]
selected_tuple=list1.get(index)
e1.delete(0,END)
e1.insert(END,selected_tuple[1])
e2.delete(0,END)
@vb100
vb100 / DataVisualizationWeather.py
Created July 11, 2017 20:11
Load Weather Data from URL in CSV, construct this data in Pandas datarame, manipulate data and retrieve data in HTML format. Using Pandas and Bokeh plotting modules.
import pandas
from bokeh.plotting import figure, output_file, show
df=pandas.read_excel("http://pythonhow.com/verlegenhuken.xlsx",sheetname=0)
df["Temperature"]=df["Temperature"]/10
df["Pressure"]=df["Pressure"]/10
p=figure(plot_width=500,plot_height=400)
@vb100
vb100 / WebsiteBlocker.py
Last active July 11, 2017 20:14
This test Python application blocking specific websites (in this example - Facebook.com) during works hours (8 AM - 5 PM) and allow to open these websites only after work.
import time
from datetime import datetime as dt
#Host to temporary file
host_temp="hosts"
#Host to original path file
hosts_path=r"C:\Windows\System32\drivers\etc\hosts"
redirect="127.0.0.1"
website_list=["www.facebook.com", "facebook.com"]
@vb100
vb100 / MapVolcanoesUSAData.py
Last active July 11, 2017 20:24
Load Volcanoes_USA.txt data to application, read Longitudes & Latitudes, load web map and retrieve all the data directly on map with fully customization and controll. All Volcano's points are colored regarding it's elevator.Using Pandas and Folium libraries.
import folium, pandas
df=pandas.read_csv("Volcanoes_USA.txt")
map=folium.Map(location=[df['LAT'].mean(),df['LON'].mean()],zoom_start=6, tiles='Mapbox bright')
def color(elev):
minimum=int(min(df['ELEV']))
step=int((max(df['ELEV'])-min(df['ELEV']))/3)
if elev in range(minimum,minimum+step):
@vb100
vb100 / OpenStreetMapAPIFindLotLat.py
Created July 11, 2017 20:30
This Python application correctly generate Longitude and Latitude of an any spatial object that is defined by it's address features in Pandas (Python module) dataframe by using OpenStreetMap API that is very friendly with Python environment and add those Longitudes and Latitudes to an existing data table.
import pandas, os
os.listdir()
df1=pandas.read_csv('supermarkets.csv')
import geopy
dir(geopy)
from geopy.geocoders import Nominatim