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 / FlaskWebsite.py
Last active July 11, 2017 20:42
Generate Webpage with Flask module. This application build a DYNAMIC website that consist of separate HTML files that construct whole website structure regarding to defined CSS style.
#Import Fask class from flask library
from flask import Flask, render_template
#Associating that class to a object. __name__ special variable that will get the value of the name of the python script
app=Flask(__name__)
#Python script Python assign the name manin this string to the file
#Case 1: Script executed __name__ = "__main__"
@app.route('/')
@vb100
vb100 / WebpageDatabaseSalaryData.py
Last active July 12, 2017 21:36
This Flask (Python) application read the input data of webpage visitor: email and salary. Then save this record to PostreSQL database and send mail to visitor inbox about average salary of other visitors and other relevant data. Used modules and libraries: Flask, SQAlchemy. Also I wrote an externat Pythoc app for sending a mail. Before testing P…
from flask import Flask, render_template, request
from flask.ext.sqlalchemy import SQLAlchemy
from send_email import send_email
from sqlalchemy.sql import func
app = Flask(__name__)
db = SQLAlchemy(app)
app.config['SQLALCHEMY_DATABASE_URI']='postgresql://postgres:skateboard@localhost/salary_collector'
class Data(db.Model):
@vb100
vb100 / PolynomialRegressionTemplate.py
Last active July 17, 2017 20:01
Polynomial Regression Template for Machine learning in Python programming language. Prediction calculation.
# Regression template
# Importing the Libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('Data.csv')
X = dataset.iloc[:, 1:2].values
@vb100
vb100 / DataPreprocessing.R
Last active July 16, 2017 17:22
Data pre-processing algorithm for R (Data Science)
# Importing the dataset
dataset = read.csv('data.csv')
# Splitting the datase into the Training set and Test set
#install.packages('caTools')
library(caTools)
set.seed(123)
split = sample.split(dataset$DependentVariable, SplitRatio = 0.8)
training_set = subset(dataset, split == TRUE)
test_se = subset(dataset, split == FALSE)
@vb100
vb100 / PolynomialRegressionTemplate.R
Created July 16, 2017 19:14
Polynomial Regression Template for Machine learning in R programming language. Prediction calculation.
# Regression Template
# Importing the dataset
dataset = read.csv('Position_Salaries.csv')
dataset = dataset[2:3] # Take into consideration onle 2 and 3 columns
# Splitting the datase into the Training set and Test set
#install.packages('caTools')
#library(caTools)
#set.seed(123)
@vb100
vb100 / MotionDetection.py
Last active September 24, 2017 18:21
Motion detection application that recognize motion by We camera and record motion time stamp to a HTML file in an interactive chart.
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 / BookingScrapper.py
Last active February 24, 2018 10:00
Booking.com - scraper (primary version). (© Vytautas Bielinskas)
"""This app. will collect the data about Mowbray Court Hotel from Booking.com
Prepared by Vytautas Bielinskas at Ekistics Property Advisors LLP"""
from selenium import webdriver
options = webdriver.chrome.options.Options()
options.add_argument("--disable-extensions")
chrome_path = r"C:\Users\user\Desktop\Python\JSscrapping\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
@vb100
vb100 / BookingPriceTracker.py
Last active February 24, 2018 09:59
This app. will track prices for 365 next days for specific chosen hotel on Booking.com (© Vytautas Bielinskas)
import requests, re
from bs4 import BeautifulSoup
l = []
base_url = 'https://www.booking.com/searchresults.en-gb.html?label=gen173nr-1FCAEoggJCAlhYSDNiBW5vcmVmaIgBiAEBmAEZwgEKd2luZG93cyAxMMgBDNgBAegBAfgBC5ICAXmoAgM;sid=20c42c0b783aafadf5e96bb173c1c595;class_interval=1;dest_id=-2601889;dest_type=city;group_adults=2;group_children=0;label_click=undef;no_rooms=1;raw_dest_type=city;room1=A%2CA;sb_price_type=total;src=index;src_elem=sb;ss=London;ssb=empty;rows=15;offset='
def count_objects(base_url):
r = requests.get(base_url + "00")
c = r.content
@vb100
vb100 / backward_elimination_with_p_values_only.py
Created March 26, 2018 19:28
Automatic implementations of Backward Elimination in Python
import statsmodels.formula.api as sm
def backwardElimination(x, sl):
numVars = len(x[0])
for i in range(0, numVars):
regressor_OLS = sm.OLS(y, x).fit()
maxVar = max(regressor_OLS.pvalues).astype(float)
if maxVar > sl:
for j in range(0, numVars - i):
if (regressor_OLS.pvalues[j].astype(float) == maxVar):
x = np.delete(x, j, 1)
@vb100
vb100 / backward_elimination_p-values_adj_R_squared.py
Created March 26, 2018 19:30
Automatic implementations of Backward Elimination in Python.
import statsmodels.formula.api as sm
def backwardElimination(x, SL):
numVars = len(x[0])
temp = np.zeros((50,6)).astype(int)
for i in range(0, numVars):
regressor_OLS = sm.OLS(y, x).fit()
maxVar = max(regressor_OLS.pvalues).astype(float)
adjR_before = regressor_OLS.rsquared_adj.astype(float)
if maxVar > SL:
for j in range(0, numVars - i):