This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************* | |
* Basic Doppler Frequency motion sensing program: * | |
* A program to process an input waveform from a Doppler motion * | |
* sensing module, such as the HB100 or Parallax X-Band Radar * | |
* motion detector. It uses the FreqMeasure library, which needs * | |
* digital pin 8 or the Arduino UNO (or 49 on the MEGA) * * | |
* * | |
* Author: B.D. Fraser * | |
* * | |
* Last modified: 12/06/2017 * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************* | |
* Master-unit - nRF24L01+ radio communications * | |
* A program to operate as a master unit that transmits to and * | |
* receives data from three remote slave devices. Each slave * | |
* also has an nrf24l01+ transceiver, and replies with data * | |
* using the Acknowledgement payload facility of the Enhanced * | |
* ShockBurst packet structure. * | |
* * | |
* Author: B.D. Fraser * | |
* * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************* | |
* Remote node - nRF24L01+ radio communications * | |
* A program to operate a remote-node slave device that sends * | |
* data to a command unit on a given request message. The radio * | |
* transceiver used is the nRF24L01+, and it operates using the * | |
* TMRh20 RF24 library. * | |
* * | |
* Author: B.D. Fraser * | |
* * | |
* Last modified: 27/06/2017 * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************* | |
* Remote node - nRF24L01+ radio communications * | |
* A program to operate a remote-node slave device that sends * | |
* data to a command unit on a given request message. The radio * | |
* transceiver used is the nRF24L01+, and it operates using the * | |
* TMRh20 RF24 library. * | |
* * | |
* Author: B.D. Fraser * | |
* * | |
* Last modified: 27/06/2017 * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Arda Mavi | |
import os | |
import numpy as np | |
from os import listdir | |
from scipy.misc import imread, imresize | |
from keras.utils import to_categorical | |
from sklearn.model_selection import train_test_split | |
# Settings: | |
img_size = 64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
# make up random data for bird wingspans and weights for golden eagles and horned owls | |
bird_wingspans = np.concatenate([np.random.randint(170, 230, size = 50)/100.0, | |
np.random.randint(60, 100, size = 50)/100.0]) | |
bird_weights = np.concatenate([(11 - 10)*np.random.randn(50)+10, np.abs(np.random.randn(50))+1]) | |
# combine X vectors into a 2-dimensional array with 100 rows and 2 columns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Perceptron(object): | |
""" Perceptron for demonstrating a binary classifier """ | |
def __init__(self, learn_rate = 0.01, iterations = 100): | |
self.learn_rate = learn_rate | |
self.iterations = iterations | |
def fit(self, X, y, biased_X = False): | |
""" Fit training data to our model """ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Adaline(object): | |
""" Adaline (Adaptive Linear Neuron) for binary classification. | |
Minimises the cost function using gradient descent. """ | |
def __init__(self, learn_rate = 0.01, iterations = 100): | |
self.learn_rate = learn_rate | |
self.iterations = iterations | |
def fit(self, X, y, biased_X = False, standardised_X = False): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nltk.sentiment.vader import SentimentIntensityAnalyzer | |
sent_i = SentimentIntensityAnalyzer() | |
def vadar_sentiment(text): | |
""" Calculate and return the nltk vadar (lexicon method) sentiment """ | |
return sent_i.polarity_scores(text)['compound'] | |
# create new column for vadar compound sentiment score | |
news_sentiments['vadar compound'] = news_sentiments['title'].apply(vadar_sentiment) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
from time import sleep | |
# select Guardian website - Military news and obtain a set of URLs | |
crawl_url = 'https://www.theguardian.com/uk/military?page=' | |
# form a set to store unique urls of all articles | |
guardian_urls = set() |
OlderNewer