markdown
stringlengths
0
1.02M
code
stringlengths
0
832k
output
stringlengths
0
1.02M
license
stringlengths
3
36
path
stringlengths
6
265
repo_name
stringlengths
6
127
--- Step 6: Test Your AlgorithmIn this section, you will take your new algorithm for a spin! What kind of dog does the algorithm think that _you_ look like? If you have a dog, does it predict your dog's breed accurately? If you have a cat, does it mistakenly think that your cat is a dog? (IMPLEMENTATION) Test Your A...
## COMPLETED: Execute your algorithm from Step 6 on ## at least 6 images on your computer. ## Feel free to use as many code cells as needed. ## suggested code, below for file in np.hstack((human_files[:3], dog_files[:3])): run_app(file) import numpy as np from glob import glob # load filenames files = np.array(gl...
_____no_output_____
MIT
dog_app.ipynb
blackcisne10/Dog-Breed-Classifier
VacationPy---- Note* Instructions have been included for each segment. You do not have to follow them exactly, but they are included to help you think through the steps.
# Dependencies and Setup import matplotlib.pyplot as plt import pandas as pd import numpy as np import requests import gmaps import os # Import API key api_key = "c280ce5700cf1679dcce087b5b74f838"
_____no_output_____
ADSL
starter_code/VacationPy.ipynb
DiamondN97/python-api-challenge
Store Part I results into DataFrame* Load the csv exported in Part I to a DataFrame
weather_data = pd.read_csv('')
_____no_output_____
ADSL
starter_code/VacationPy.ipynb
DiamondN97/python-api-challenge
Humidity Heatmap* Configure gmaps.* Use the Lat and Lng as locations and Humidity as the weight.* Add Heatmap layer to map. Create new DataFrame fitting weather criteria* Narrow down the cities to fit weather conditions.* Drop any rows will null values. Hotel Map* Store into variable named `hotel_df`.* Add a "Hotel ...
# NOTE: Do not change any of the code in this cell # Using the template add the hotel marks to the heatmap info_box_template = """ <dl> <dt>Name</dt><dd>{Hotel Name}</dd> <dt>City</dt><dd>{City}</dd> <dt>Country</dt><dd>{Country}</dd> </dl> """ # Store the DataFrame Row # NOTE: be sure to update with your DataFrame na...
_____no_output_____
ADSL
starter_code/VacationPy.ipynb
DiamondN97/python-api-challenge
UNIVERSIDADE FEDERAL DO PIAUÍCURSO DE GRADUAÇÃO EM ENGENHARIA ELÉTRICADISCIPLINA: TÉCNICAS DE OTIMIZAÇÃODOCENTE: ALDIR SILVA SOUSADISCENTE: MARIANA DE SOUSA MOURAAtividade 3: Otimização Irrestrita pelo Método de Newton MultivariávelResolva os exercícios usando o método de Descida Gradiente. **Método da Descida Gradie...
import numpy as np import sympy as sym #Para criar variáveis simbólicas. class Params: def __init__(self,f,vars,eps,a,b): self.f = f self.a = a self.b = b self.vars = vars #variáveis simbólicas self.eps = eps def eval(sym_f,vars,x): map = dict() map[vars[0]] = x return sym_f.subs(...
_____no_output_____
MIT
Exercicios_Steepest_Descent.ipynb
marianasmoura/tecnicas-de-otimizacao
Calcula o gradiente e permite a substituição de valores em variáveis nas funções
# Função para o cálculo do gradiente import sympy as sym #Para criar variáveis simbólicas. def gradiente_simbolico(funcao,variaveis): g1 = [sym.diff(funcao,x) for x in variaveis] return g1 # Função para substituição dos valores nas variáveis simbólicas def eval_simbolica(f,variaveis,x): mp = dict() fo...
_____no_output_____
MIT
Exercicios_Steepest_Descent.ipynb
marianasmoura/tecnicas-de-otimizacao
Parâmetros que serõ utilizados pela função
import numpy as np import sympy as sym class Parametros: def __init__(self,f,d1f,vars,m,eps,nmax): self.f = f self.d1f = d1f self.m = m self.eps = eps self.nmax = nmax self.vars = vars
_____no_output_____
MIT
Exercicios_Steepest_Descent.ipynb
marianasmoura/tecnicas-de-otimizacao
Código para a otimização a partir da Descida Gradiente
import pandas as pd import math lmbd = sym.Symbol('lmbd') def steepestDescent(p): f = p.f d1f = p.d1f m = p.m eps = p.eps vars= p.vars nmax = p.nmax k = 0 v = [0 for i in vars] cols = ['x','grad(x)','lambda'] table = pd.DataFrame([], columns=cols)...
_____no_output_____
MIT
Exercicios_Steepest_Descent.ipynb
marianasmoura/tecnicas-de-otimizacao
**1.** Considere o seguinte problema:Minimizar $\sum_{i=2}^{n} [100(x_i-x^2_{i-1})^2 + (1-x_{i-1})^2]$Resolva para n = 5, 10, e 50. Iniciando do ponto $x_0 = [-1.2,1.0,-1.2,1.0,...]$
# Para n = 5 import numpy as np import sympy as sym variaveis = list(sym.symbols("x:5")) c = variaveis def f1(c): fo = 0 for i in range(1,5): fo = fo + 100*(c[i] - c[i-1]**2)**2 + (1 - c[i-1])**2 return fo x = [] for i in range(1,6): if (i%2 != 0): x.append(-1.2) else: ...
_____no_output_____
MIT
Exercicios_Steepest_Descent.ipynb
marianasmoura/tecnicas-de-otimizacao
**2.** Resolva:Minimizar $(x_1 - x^3_2)^2 + 3(x_1 - x_2)^4$
import numpy as np import sympy as sym x1 = sym.Symbol('x1') x2 = sym.Symbol('x2') variaveis = [x1,x2] c = variaveis fo = 0 def fo(c): return (c[0] - c[1]**3)**2 + 3*(c[0] - c[1])**4 x = [1.2,1.5] eps = 1e-3 nmax = 500 d1f = gradiente_simbolico(fo(c),c) p = Parametros(fo,d1f,c,x,eps,nmax) m,df = steepestDesc...
_____no_output_____
MIT
Exercicios_Steepest_Descent.ipynb
marianasmoura/tecnicas-de-otimizacao
**3.** Resolva:$2(x_1 - 2)^4 + (2x_1 - x_2)^2 = 4$
import numpy as np import sympy as sym x1 = sym.Symbol('x1') x2 = sym.Symbol('x2') variaveis = [x1,x2] c = variaveis fo = 0 def fo(c): return (2*(c[0] - 2)**4 + (2*c[0] - c[1])**2 - 4)**2 x = [1.2,0.5] eps = 1e-3 nmax = 300 d1f = gradiente_simbolico(fo(c),c) p = Parametros(fo,d1f,c,x,eps,nmax) m,df = steepes...
_____no_output_____
MIT
Exercicios_Steepest_Descent.ipynb
marianasmoura/tecnicas-de-otimizacao
**4** Resolva:Minimizar $(x_1 - 3)^4 + (x_1 - 3x_2)^2$
import numpy as np import sympy as sym x1 = sym.Symbol('x1') x2 = sym.Symbol('x2') variaveis = [x1,x2] c = variaveis def f4(c): return (c[0] - 3)**4 + (c[0] - 3*c[1])**2 x = [1.5,1] eps = 1e-4 nmax = 300 d1f = gradiente_simbolico(f4(c),c) p = Parametros(f4,d1f,c,x,eps,nmax) n,t = steepestDescent(p) t n
_____no_output_____
MIT
Exercicios_Steepest_Descent.ipynb
marianasmoura/tecnicas-de-otimizacao
Building your Deep Neural Network: Step by StepWelcome to your week 4 assignment (part 1 of 2)! You have previously trained a 2-layer Neural Network (with a single hidden layer). This week, you will build a deep neural network, with as many layers as you want!- In this notebook, you will implement all the functions re...
import numpy as np import h5py import matplotlib.pyplot as plt from testCases_v4 import * from dnn_utils_v2 import sigmoid, sigmoid_backward, relu, relu_backward %matplotlib inline plt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plots plt.rcParams['image.interpolation'] = 'nearest' plt.rcParams['imag...
The autoreload extension is already loaded. To reload it, use: %reload_ext autoreload
MIT
deepl/Building+your+Deep+Neural+Network+-+Step+by+Step+v8.ipynb
stepinski/machinelearning
2 - Outline of the AssignmentTo build your neural network, you will be implementing several "helper functions". These helper functions will be used in the next assignment to build a two-layer neural network and an L-layer neural network. Each small helper function you will implement will have detailed instructions tha...
# GRADED FUNCTION: initialize_parameters def initialize_parameters(n_x, n_h, n_y): """ Argument: n_x -- size of the input layer n_h -- size of the hidden layer n_y -- size of the output layer Returns: parameters -- python dictionary containing your parameters: W1 --...
W1 = [[ 0.01624345 -0.00611756 -0.00528172] [-0.01072969 0.00865408 -0.02301539]] b1 = [[ 0.] [ 0.]] W2 = [[ 0.01744812 -0.00761207]] b2 = [[ 0.]]
MIT
deepl/Building+your+Deep+Neural+Network+-+Step+by+Step+v8.ipynb
stepinski/machinelearning
**Expected output**: **W1** [[ 0.01624345 -0.00611756 -0.00528172] [-0.01072969 0.00865408 -0.02301539]] **b1** [[ 0.] [ 0.]] **W2** [[ 0.01744812 -0.00761207]] **b2** [[ 0.]] 3.2 - L-layer Neural NetworkThe initialization for a deeper L-layer neural n...
# GRADED FUNCTION: initialize_parameters_deep def initialize_parameters_deep(layer_dims): """ Arguments: layer_dims -- python array (list) containing the dimensions of each layer in our network Returns: parameters -- python dictionary containing your parameters "W1", "b1", ..., "WL", "bL": ...
W1 = [[ 0.01788628 0.0043651 0.00096497 -0.01863493 -0.00277388] [-0.00354759 -0.00082741 -0.00627001 -0.00043818 -0.00477218] [-0.01313865 0.00884622 0.00881318 0.01709573 0.00050034] [-0.00404677 -0.0054536 -0.01546477 0.00982367 -0.01101068]] b1 = [[ 0.] [ 0.] [ 0.] [ 0.]] W2 = [[-0.01185047 -0.002056...
MIT
deepl/Building+your+Deep+Neural+Network+-+Step+by+Step+v8.ipynb
stepinski/machinelearning
**Expected output**: **W1** [[ 0.01788628 0.0043651 0.00096497 -0.01863493 -0.00277388] [-0.00354759 -0.00082741 -0.00627001 -0.00043818 -0.00477218] [-0.01313865 0.00884622 0.00881318 0.01709573 0.00050034] [-0.00404677 -0.0054536 -0.01546477 0.00982367 -0.01101068]] **b1** [[ 0...
# GRADED FUNCTION: linear_forward def linear_forward(A, W, b): """ Implement the linear part of a layer's forward propagation. Arguments: A -- activations from previous layer (or input data): (size of previous layer, number of examples) W -- weights matrix: numpy array of shape (size of current la...
Z = [[ 3.26295337 -1.23429987]]
MIT
deepl/Building+your+Deep+Neural+Network+-+Step+by+Step+v8.ipynb
stepinski/machinelearning
**Expected output**: **Z** [[ 3.26295337 -1.23429987]] 4.2 - Linear-Activation ForwardIn this notebook, you will use two activation functions:- **Sigmoid**: $\sigma(Z) = \sigma(W A + b) = \frac{1}{ 1 + e^{-(W A + b)}}$. We have provided you with the `sigmoid` function. This function returns **two** ...
# GRADED FUNCTION: linear_activation_forward def linear_activation_forward(A_prev, W, b, activation): """ Implement the forward propagation for the LINEAR->ACTIVATION layer Arguments: A_prev -- activations from previous layer (or input data): (size of previous layer, number of examples) W -- weigh...
With sigmoid: A = [[ 0.96890023 0.11013289]] With ReLU: A = [[ 3.43896131 0. ]]
MIT
deepl/Building+your+Deep+Neural+Network+-+Step+by+Step+v8.ipynb
stepinski/machinelearning
**Expected output**: **With sigmoid: A ** [[ 0.96890023 0.11013289]] **With ReLU: A ** [[ 3.43896131 0. ]] **Note**: In deep learning, the "[LINEAR->ACTIVATION]" computation is counted as a single layer in the neural network, not two layers. d) L-Layer Model For even more c...
# GRADED FUNCTION: L_model_forward def L_model_forward(X, parameters): """ Implement forward propagation for the [LINEAR->RELU]*(L-1)->LINEAR->SIGMOID computation Arguments: X -- data, numpy array of shape (input size, number of examples) parameters -- output of initialize_parameters_deep() ...
AL = [[ 0.03921668 0.70498921 0.19734387 0.04728177]] Length of caches list = 3
MIT
deepl/Building+your+Deep+Neural+Network+-+Step+by+Step+v8.ipynb
stepinski/machinelearning
**AL** [[ 0.03921668 0.70498921 0.19734387 0.04728177]] **Length of caches list ** 3 Great! Now you have a full forward propagation that takes the input X and outputs a row vector $A^{[L]}$ containing your predictions. It also records all intermediate values in "caches". Using $A^{[L]}$...
# GRADED FUNCTION: compute_cost def compute_cost(AL, Y): """ Implement the cost function defined by equation (7). Arguments: AL -- probability vector corresponding to your label predictions, shape (1, number of examples) Y -- true "label" vector (for example: containing 0 if non-cat, 1 if cat), sh...
cost = 0.41493159961539694
MIT
deepl/Building+your+Deep+Neural+Network+-+Step+by+Step+v8.ipynb
stepinski/machinelearning
**Expected Output**: **cost** 0.41493159961539694 6 - Backward propagation moduleJust like with forward propagation, you will implement helper functions for backpropagation. Remember that back propagation is used to calculate the gradient of the loss function with respect to the parameters. **Reminder...
# GRADED FUNCTION: linear_backward def linear_backward(dZ, cache): """ Implement the linear portion of backward propagation for a single layer (layer l) Arguments: dZ -- Gradient of the cost with respect to the linear output (of current layer l) cache -- tuple of values (A_prev, W, b) coming from ...
dA_prev = [[ 0.51822968 -0.19517421] [-0.40506361 0.15255393] [ 2.37496825 -0.89445391]] dW = [[-0.10076895 1.40685096 1.64992505]] db = [[ 0.50629448]]
MIT
deepl/Building+your+Deep+Neural+Network+-+Step+by+Step+v8.ipynb
stepinski/machinelearning
**Expected Output**: **dA_prev** [[ 0.51822968 -0.19517421] [-0.40506361 0.15255393] [ 2.37496825 -0.89445391]] **dW** [[-0.10076895 1.40685096 1.64992505]] **db** [[ 0.50629448]] 6.2 - Linear-Activation backwardNext, you will create a...
# GRADED FUNCTION: linear_activation_backward def linear_activation_backward(dA, cache, activation): """ Implement the backward propagation for the LINEAR->ACTIVATION layer. Arguments: dA -- post-activation gradient for current layer l cache -- tuple of values (linear_cache, activation_cache)...
sigmoid: dA_prev = [[ 0.11017994 0.01105339] [ 0.09466817 0.00949723] [-0.05743092 -0.00576154]] dW = [[ 0.10266786 0.09778551 -0.01968084]] db = [[-0.05729622]] relu: dA_prev = [[ 0.44090989 -0. ] [ 0.37883606 -0. ] [-0.2298228 0. ]] dW = [[ 0.44513824 0.37371418 -0.10478989]] db = [[-0...
MIT
deepl/Building+your+Deep+Neural+Network+-+Step+by+Step+v8.ipynb
stepinski/machinelearning
**Expected output with sigmoid:** dA_prev [[ 0.11017994 0.01105339] [ 0.09466817 0.00949723] [-0.05743092 -0.00576154]] dW [[ 0.10266786 0.09778551 -0.01968084]] db [[-0.05729622]] **Expected output with relu:** dA_prev ...
# GRADED FUNCTION: L_model_backward def L_model_backward(AL, Y, caches): """ Implement the backward propagation for the [LINEAR->RELU] * (L-1) -> LINEAR -> SIGMOID group Arguments: AL -- probability vector, output of the forward propagation (L_model_forward()) Y -- true "label" vector (contain...
dW1 = [[ 0.41010002 0.07807203 0.13798444 0.10502167] [ 0. 0. 0. 0. ] [ 0.05283652 0.01005865 0.01777766 0.0135308 ]] db1 = [[-0.22007063] [ 0. ] [-0.02835349]] dA1 = [[ 0.12913162 -0.44014127] [-0.14175655 0.48317296] [ 0.01663708 -0.05670698]]
MIT
deepl/Building+your+Deep+Neural+Network+-+Step+by+Step+v8.ipynb
stepinski/machinelearning
**Expected Output** dW1 [[ 0.41010002 0.07807203 0.13798444 0.10502167] [ 0. 0. 0. 0. ] [ 0.05283652 0.01005865 0.01777766 0.0135308 ]] db1 [[-0.22007063] [ 0. ] [-0.02835349]] dA1 [[ 0.12913162 -0.44...
# GRADED FUNCTION: update_parameters def update_parameters(parameters, grads, learning_rate): """ Update parameters using gradient descent Arguments: parameters -- python dictionary containing your parameters grads -- python dictionary containing your gradients, output of L_model_backward ...
W1 = [[-0.59562069 -0.09991781 -2.14584584 1.82662008] [-1.76569676 -0.80627147 0.51115557 -1.18258802] [-1.0535704 -0.86128581 0.68284052 2.20374577]] b1 = [[-0.04659241] [-1.28888275] [ 0.53405496]] W2 = [[-0.55569196 0.0354055 1.32964895]] b2 = [[-0.84610769]]
MIT
deepl/Building+your+Deep+Neural+Network+-+Step+by+Step+v8.ipynb
stepinski/machinelearning
Strategy Based on Labels vs BH
dfDetail = pd.read_csv("./GOOGL_weekly_return_volatility_detailed.csv") dfYear2 = dfDetail[dfDetail.Year == 2020] year2.label = labelYear2 ## Add label to detail labelMap = {} for (y, w, l) in zip(year2.Year, year2.Week_Number, year2.label): key = (y, w) value = l labelMap[key] = value temp = [] for (y, w...
Using Label: 215.85697376702737 Buy on first day and Sell on last day: 121.17033527942765
MIT
Assignment_5/kNN_logistic_stocks/.ipynb_checkpoints/KNN-checkpoint.ipynb
KyleLeePiupiupiu/CS677_Assignment
2.3 Arithmetic Multiplication (`*`)
7 * 4
_____no_output_____
MIT
examples/ch02/snippets_ipynb/02_03.ipynb
eltechno/python_course
Exponentiation (`**`)
2 ** 10 9 ** (1 / 2)
_____no_output_____
MIT
examples/ch02/snippets_ipynb/02_03.ipynb
eltechno/python_course
True Division (`/`) vs. Floor Division (`//`)
7 / 4 7 // 4 3 // 5 14 // 7 -13 / 4 -13 // 4
_____no_output_____
MIT
examples/ch02/snippets_ipynb/02_03.ipynb
eltechno/python_course
Exceptions and Tracebacks
123 / 0 z + 7
_____no_output_____
MIT
examples/ch02/snippets_ipynb/02_03.ipynb
eltechno/python_course
Remainder Operator
17 % 5 7.5 % 3.5
_____no_output_____
MIT
examples/ch02/snippets_ipynb/02_03.ipynb
eltechno/python_course
Grouping Expressions with Parentheses
10 * (5 + 3) 10 * 5 + 3 ########################################################################## # (C) Copyright 2019 by Deitel & Associates, Inc. and # # Pearson Education, Inc. All Rights Reserved. # # ...
_____no_output_____
MIT
examples/ch02/snippets_ipynb/02_03.ipynb
eltechno/python_course
Task 11 - Motor Control Introduction to modeling and simulation of human movementhttps://github.com/BMClab/bmc/blob/master/courses/ModSim2018.md * Task (for Lecture 11):Change the derivative of the contractile element length function. The new function must compute the derivative according to the article from Thelen(20...
import numpy as np #import pandas as pd import matplotlib.pyplot as plt import math %matplotlib notebook
_____no_output_____
MIT
courses/modsim2018/tasks/Desiree/Task11_MotorControl.ipynb
desireemiraldo/bmc
Muscle properties
Lslack = .223 Umax = .04 Lce_o = .093 #optmal l width = .63#*Lce_o Fmax = 3000 a = 1 #b = .25*10#*Lce_o
_____no_output_____
MIT
courses/modsim2018/tasks/Desiree/Task11_MotorControl.ipynb
desireemiraldo/bmc
Initial conditions
Lnorm_ce = .087/Lce_o #norm t0 = 0 tf = 2.99 h = 1e-3 t = np.arange(t0,tf,h) F = np.empty(t.shape) Fkpe = np.empty(t.shape) FiberLen = np.empty(t.shape) TendonLen = np.empty(t.shape)
_____no_output_____
MIT
courses/modsim2018/tasks/Desiree/Task11_MotorControl.ipynb
desireemiraldo/bmc
Simulation - Series for i in range (len(t)): ramp if t[i]<=1: Lm = 0.31 elif t[i]>1 and t[i]<2: Lm = .31 + .1*(t[i]-1) print(Lm) shortening at 4cm/s Lsee = Lm - Lce if Lsee<Lslack: F[i] = 0 else: F[i] = Fmax*((Lsee-Lslack)/(Umax*Lslack))**2 ...
def TendonForce (Lnorm_see,Lslack, Lce_o): ''' Compute tendon force Inputs: Lnorm_see = normalized tendon length Lslack = slack length of the tendon (non-normalized) Lce_o = optimal length of the fiber Output: Fnorm_tendon = normalized tendon force ''' ...
_____no_output_____
MIT
courses/modsim2018/tasks/Desiree/Task11_MotorControl.ipynb
desireemiraldo/bmc
def ContractileElementDot(F0, Fnorm_CE, a, b): ''' Compute Contractile Element Derivative Inputs: F0 = Force-Length Curve Fce = Contractile element force Output: Lnorm_cedot = normalized contractile element length derivative ''' if Fnorm_CE>F0: print('Error: cannot do...
def ContractileElementDot(F0, Fnorm_CE, a): ''' Compute Contractile Element Derivative Inputs: F0 = Force-Length Curve Fce = Contractile element force Output: Lnorm_cedot = normalized contractile element length derivative ''' FMlen = 1.4 # young adults ...
_____no_output_____
MIT
courses/modsim2018/tasks/Desiree/Task11_MotorControl.ipynb
desireemiraldo/bmc
Simulation - Parallel
#Normalizing for i in range (len(t)): #ramp if t[i]<=1: Lm = 0.31 elif t[i]>1 and t[i]<2: Lm = .31 - .04*(t[i]-1) #print(Lm) #shortening at 4cm/s Lnorm_see = tendonLength(Lm,Lce_o,Lnorm_ce) Fnorm_tendon = TendonForce (Lnorm_see,Lslack, Lce_o) Fnorm_k...
_____no_output_____
MIT
courses/modsim2018/tasks/Desiree/Task11_MotorControl.ipynb
desireemiraldo/bmc
Plots
fig, ax = plt.subplots(1, 1, figsize=(6,6), sharex=True) ax.plot(t,F,c='red') plt.grid() plt.xlabel('time (s)') plt.ylabel('Force (N)') ax.legend() fig, ax = plt.subplots(1, 1, figsize=(6,6), sharex=True) ax.plot(t,FiberLen, label = 'fiber') ax.plot(t,TendonLen, label = 'tendon') plt.grid() plt.xlabel('time (s)') p...
_____no_output_____
MIT
courses/modsim2018/tasks/Desiree/Task11_MotorControl.ipynb
desireemiraldo/bmc
Creation of annotations from unannotated noise recordings Purpose of this notebookThis notebook describes the steps involved in automatically creating noise annotations from non-annotated noise recordings. This notebook is used for creating noise annotations from data provided by the Universty of Aberdeen in Scotland....
from ecosound.core.annotation import Annotation from ecosound.core.metadata import DeploymentInfo from ecosound.core.audiotools import Sound from ecosound.core.tools import filename_to_datetime import os import pandas as pd import numpy as np import uuid from datetime import datetime def create_noise_annot(audio_dir, ...
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Dataset 1: UK-UAberdeen-MorayFirth-201904_986-110Definition of all the paths of all folders with the raw annotation and audio files for this deployment.
audio_dir = r'C:\Users\xavier.mouy\Documents\GitHub\minke-whale-dataset\datasets\UK-UAberdeen-MorayFirth-201904_986-110' deployment_file = r'deployment_info.csv' file_ext = 'wav' annot_dur_sec = 60 # duration of the noise annotations in seconds label_class = 'NN' # label to use for the noise class label_subclass = ...
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Now we can create annotations for all audio files in that folder.
annot = create_noise_annot(audio_dir, deployment_file, file_ext, annot_dur_sec, label_class, label_subclass)
Depl986_1678036995.190402110017.wav Depl986_1678036995.190406225930.wav Depl986_1678036995.190410165901.wav
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Let's look at the summary of annotations that were created:
annot.summary()
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
The dataset can now be saved as a Raven annotation file and netcdf4 file:
annot.to_netcdf(os.path.join(audio_dir, 'Annotations_dataset_' + annot.data['deployment_ID'][0] +' annotations.nc')) annot.to_raven(audio_dir, outfile='Annotations_dataset_' + annot.data['deployment_ID'][0] +'.Table.1.selections.txt', single_file=True)
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Here is what the annotations look like in Raven:![noiseScotland.png](img/noiseScotland.png) Dataset 2: UK-UAberdeen-MorayFirth-201904_1027-235Definition of all the paths of all folders with the raw annotation and audio files for this deployment.
audio_dir = r'C:\Users\xavier.mouy\Documents\GitHub\minke-whale-dataset\datasets\UK-UAberdeen-MorayFirth-201904_1027-235' deployment_file = r'deployment_info.csv' file_ext = 'wav' annot_dur_sec = 60 # duration of the noise annotations in seconds label_class = 'NN' # label to use for the noise class label_subclass =...
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Now we can create annotations for all audio files in that folder.
annot = create_noise_annot(audio_dir, deployment_file, file_ext, annot_dur_sec, label_class, label_subclass)
Depl1027_1677725722.190403115956.wav Depl1027_1677725722.190411055855.wav Depl1027_1677725722.190415235822.wav
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Let's look at the summary of annotations that were created:
annot.summary()
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
The dataset can now be saved as a Raven annotation file and netcdf4 file:
annot.to_netcdf(os.path.join(audio_dir, 'Annotations_dataset_' + annot.data['deployment_ID'][0] +' annotations.nc')) annot.to_raven(audio_dir, outfile='Annotations_dataset_' + annot.data['deployment_ID'][0] +'.Table.1.selections.txt', single_file=True)
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Dataset 3: UK-UAberdeen-MorayFirth-201904_1029-237Definition of all the paths of all folders with the raw annotation and audio files for this deployment.
audio_dir = r'C:\Users\xavier.mouy\Documents\GitHub\minke-whale-dataset\datasets\UK-UAberdeen-MorayFirth-201904_1029-237' deployment_file = r'deployment_info.csv' file_ext = 'wav' annot_dur_sec = 60 # duration of the noise annotations in seconds label_class = 'NN' # label to use for the noise class label_subclass =...
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Now we can create annotations for all audio files in that folder.
annot = create_noise_annot(audio_dir, deployment_file, file_ext, annot_dur_sec, label_class, label_subclass)
Depl1029_134541352.190403235927.wav Depl1029_134541352.190404175922.wav Depl1029_134541352.190409115847.wav
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Let's look at the summary of annotations that were created:
annot.summary()
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
The dataset can now be saved as a Raven annotation file and netcdf4 file:
annot.to_netcdf(os.path.join(audio_dir, 'Annotations_dataset_' + annot.data['deployment_ID'][0] +' annotations.nc')) annot.to_raven(audio_dir, outfile='Annotations_dataset_' + annot.data['deployment_ID'][0] +'.Table.1.selections.txt', single_file=True)
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Dataset 4: UK-UAberdeen-MorayFirth-202001_1092-112 (seismic)Definition of all the paths of all folders with the raw annotation and audio files for this deployment.
audio_dir = r'C:\Users\xavier.mouy\Documents\GitHub\minke-whale-dataset\datasets\UK-UAberdeen-MorayFirth-202001_1092-112' deployment_file = r'deployment_info.csv' file_ext = 'wav' annot_dur_sec = 60 # duration of the noise annotations in seconds label_class = 'NN' # label to use for the noise class label_subclass =...
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Now we can create annotations for all audio files in that folder.
annot = create_noise_annot(audio_dir, deployment_file, file_ext, annot_dur_sec, label_class, label_subclass)
Depl1092_1678036995.200101014914.wav Depl1092_1678036995.200104224914.wav Depl1092_1678036995.200104234914.wav Depl1092_1678036995.200111084914.wav Depl1092_1678036995.200119004914.wav Depl1092_1678036995.200119034914.wav Depl1092_1678036995.200121014914.wav Depl1092_1678036995.200121214914.wav Depl1092_1678036995.2001...
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Let's look at the summary of annotations that were created:
annot.summary()
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
The dataset can now be saved as a Raven annotation file and netcdf4 file:
annot.to_netcdf(os.path.join(audio_dir, 'Annotations_dataset_' + annot.data['deployment_ID'][0] +' annotations.nc')) annot.to_raven(audio_dir, outfile='Annotations_dataset_' + annot.data['deployment_ID'][0] +'.Table.1.selections.txt', single_file=True)
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Dataset 5: UK-UAberdeen-MorayFirth-202001_1093-164 (seismic)Definition of all the paths of all folders with the raw annotation and audio files for this deployment.
audio_dir = r'C:\Users\xavier.mouy\Documents\GitHub\minke-whale-dataset\datasets\UK-UAberdeen-MorayFirth-202001_1093-164' deployment_file = r'deployment_info.csv' file_ext = 'wav' annot_dur_sec = 60 # duration of the noise annotations in seconds label_class = 'NN' # label to use for the noise class label_subclass =...
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Now we can create annotations for all audio files in that folder.
annot = create_noise_annot(audio_dir, deployment_file, file_ext, annot_dur_sec, label_class, label_subclass)
Depl1093_1677725722.200104205913.wav Depl1093_1677725722.200110095913.wav Depl1093_1677725722.200110115913.wav Depl1093_1677725722.200111205913.wav Depl1093_1677725722.200119035913.wav Depl1093_1677725722.200121195913.wav Depl1093_1677725722.200121235913.wav Depl1093_1677725722.200123235913.wav Depl1093_1677725722.2001...
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Let's look at the summary of annotations that were created:
annot.summary()
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
The dataset can now be saved as a Raven annotation file and netcdf4 file:
annot.to_netcdf(os.path.join(audio_dir, 'Annotations_dataset_' + annot.data['deployment_ID'][0] +' annotations.nc')) annot.to_raven(audio_dir, outfile='Annotations_dataset_' + annot.data['deployment_ID'][0] +'.Table.1.selections.txt', single_file=True)
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Dataset 6: UK-UAberdeen-MorayFirth-202101_1136-164Definition of all the paths of all folders with the raw annotation and audio files for this deployment.
audio_dir = r'C:\Users\xavier.mouy\Documents\GitHub\minke-whale-dataset\datasets\UK-UAberdeen-MorayFirth-202101_1136-164' deployment_file = r'deployment_info.csv' file_ext = 'wav' annot_dur_sec = 60 # duration of the noise annotations in seconds label_class = 'NN' # label to use for the noise class label_subclass =...
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Now we can create annotations for all audio files in that folder.
annot = create_noise_annot(audio_dir, deployment_file, file_ext, annot_dur_sec, label_class, label_subclass)
Depl1136_1677725722.210102130002.wav Depl1136_1677725722.210103230002.wav Depl1136_1677725722.210105030002.wav Depl1136_1677725722.210105110002.wav Depl1136_1677725722.210119110002.wav Depl1136_1677725722.210119180002.wav Depl1136_1677725722.210208180002.wav Depl1136_1677725722.210216140002.wav Depl1136_1677725722.2102...
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Let's look at the summary of annotations that were created:
annot.summary()
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
The dataset can now be saved as a Raven annotation file and netcdf4 file:
annot.to_netcdf(os.path.join(audio_dir, 'Annotations_dataset_' + annot.data['deployment_ID'][0] +' annotations.nc')) annot.to_raven(audio_dir, outfile='Annotations_dataset_' + annot.data['deployment_ID'][0] +'.Table.1.selections.txt', single_file=True)
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Dataset 7: UK-UAberdeen-MorayFirth-202101_1137-112Definition of all the paths of all folders with the raw annotation and audio files for this deployment.
audio_dir = r'C:\Users\xavier.mouy\Documents\GitHub\minke-whale-dataset\datasets\UK-UAberdeen-MorayFirth-202101_1137-112' deployment_file = r'deployment_info.csv' file_ext = 'wav' annot_dur_sec = 60 # duration of the noise annotations in seconds label_class = 'NN' # label to use for the noise class label_subclass =...
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Now we can create annotations for all audio files in that folder.
annot = create_noise_annot(audio_dir, deployment_file, file_ext, annot_dur_sec, label_class, label_subclass)
Depl1137_1678508072.210107040002.wav Depl1137_1678508072.210108160002.wav Depl1137_1678508072.210113150002.wav Depl1137_1678508072.210114040002.wav Depl1137_1678508072.210116170002.wav Depl1137_1678508072.210119040002.wav Depl1137_1678508072.210122000002.wav Depl1137_1678508072.210123040002.wav Depl1137_1678508072.2101...
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
Let's look at the summary of annotations that were created:
annot.summary()
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
The dataset can now be saved as a Raven annotation file and netcdf4 file:
annot.to_netcdf(os.path.join(audio_dir, 'Annotations_dataset_' + annot.data['deployment_ID'][0] +' annotations.nc')) annot.to_raven(audio_dir, outfile='Annotations_dataset_' + annot.data['deployment_ID'][0] +'.Table.1.selections.txt', single_file=True)
_____no_output_____
Apache-2.0
dataset_preparation_noise.ipynb
xaviermouy/minke-whale-dataset
import tensorflow as tf from tensorflow.keras.datasets import mnist from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense from tensorflow.keras.layers import BatchNormalization from tensorflow.keras.layers import Dropout from tensorflow.keras.utils import to_categorical # Load mnist...
_____no_output_____
MIT
Neural Networks/03_Deep_Net_in_tensorflow_mnist_classification.ipynb
kishore145/AI-ML-Foundations
CT scan UNet demoThis notebook creates a UNet for a minified dataset of animal CTs.If you are on Google Colab, make this train quicker by swapping to a GPU runtime. This is done by clicking `Runtime`, then `Change runtime type`, then selecting `GPU`:![01](https://github.com/pymedphys/pymedphys/blob/85b8434dc2f11bf20b3...
import pathlib import urllib.request import shutil import collections import numpy as np import matplotlib.pyplot as plt import tensorflow as tf import tensorflow.keras.backend as K import imageio import skimage.filters zip_url = 'https://zenodo.org/record/4448689/files/minified-animal-patient-brain-orbits.zip?downloa...
_____no_output_____
Apache-2.0
prototyping/auto-segmentation/sb/05-mini-data-take-2/072-score-with-scharr.ipynb
dg1an3/pymedphys
Load Packages
import pandas as pd import matplotlib.pyplot as plt from matplotlib import rcParams rcParams['figure.figsize'] = [20, 10]
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Gathering Data Load Datasets, Toxicity & Aggression
filepath = "../../../Documents/" aggression = filepath+"Aggression/" toxicity = filepath+"Toxicity/" toxic_annotated_comments = pd.read_csv(toxicity+"toxicity_annotated_comments.tsv", sep='\t') toxic_annotations = pd.read_csv(toxicity+"toxicity_annotations.tsv", sep='\t') toxic_demographics = pd.read_csv(toxicity+"toxi...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
What is inside the [Datasets](https://meta.wikimedia.org/wiki/Research:Detox/Data_Release)?
toxic_df = toxic_annotations.merge(toxic_annotated_comments, on= 'rev_id', how = 'left').merge(toxic_demographics, on = 'worker_id', how = 'left') toxic_df.head() #Some worker ids not included in toxic demographics len(set(toxic_annotations.worker_id) - set(toxic_demographics.worker_id)) aggressions_df = agg_annotation...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Research Questions How has toxicity and aggression changed over time? Toxicity Toxicity is measured two ways. We can see the ratio of toxic comments vs non toxic comments over time, and the average toxicity score over time. Toxicity is a binary value column that we can do a count over number of rows to find the ra...
toxic_df.head() plt.hist(toxic_df.toxicity_score) plt.title("Toxicity Score Distribution")
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Toxicity Scores appear to have more positive or healthy comments than toxic comments Lets first look at a general time trend of the entire dataset on a per year basis Preprocessing
col_rename = {'rev_id':'count'} toxic_df_trend = toxic_df.groupby('year').agg({'rev_id':'count', 'toxicity':'sum', 'toxicity_score':'mean'}).reset_index().rename(columns = col_rename) toxic_df_trend['toxicity_ratio'] = toxic_df_trend['toxicity'] / toxic_df_trend['count'] toxic_df_trend['toxicity_score_reversed'] = -1 *...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Toxicity Ratio
plt.figure() plt.ticklabel_format(style='plain') plt.plot(toxic_df_trend.year, toxic_df_trend.toxicity_ratio) plt.grid(True) plt.title("Toxicity Ratio Over Time")
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Toxicity Score
plt.figure() plt.ticklabel_format(style='plain') plt.plot(toxic_df_trend.year, toxic_df_trend.toxicity_score_reversed) plt.grid(True) plt.title("Toxicity Score Over Time")
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Interestingly, there appears to be a rapid increase in both the average toxicity score and the ratio of toxic comments from the beginning of the dataset to around 2008. However, the rates appear to flat out remaining consistent in later years.My next question is, how do these results change for a user that was logged ...
col_rename = {'rev_id':'count'} toxic_df_trend_logged_in = toxic_df[toxic_df.logged_in == True].groupby('year').agg({'rev_id':'count', 'toxicity':'sum', 'toxicity_score':'mean'}).reset_index().rename(columns = col_rename) toxic_df_trend_logged_in['toxicity_ratio'] = toxic_df_trend_logged_in['toxicity'] / toxic_df_trend...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Toxicity Ratio Log In
plt.figure() plt.ticklabel_format(style='plain') plt.plot(toxic_df_trend.year, toxic_df_trend.toxicity_ratio, color = 'black', label ='Total') plt.plot(toxic_df_trend_logged_in.year, toxic_df_trend_logged_in.toxicity_ratio, color = 'blue', label ='Logged In') plt.plot(toxic_df_trend_not_logged_in.year, toxic_df_trend_n...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Toxicity Score Log In
plt.figure() plt.ticklabel_format(style='plain') plt.plot(toxic_df_trend.year, toxic_df_trend.toxicity_score_reversed, color = 'black', label ='Total') plt.plot(toxic_df_trend_logged_in.year, toxic_df_trend_logged_in.toxicity_score_reversed, color = 'blue', label ='Logged In') plt.plot(toxic_df_trend_not_logged_in.year...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
There appears to be a big difference in both the scoring and ratio when the user is logged in or not. On the years after 2005 for the not logged in group, the average (reversed) toxicity score turns positive, while remaining a ratio of less than 0.5, indicating that the comments are very high in toxicity for users not...
col_rename = {'rev_id':'count'} toxic_df_trend_blocked = toxic_df[toxic_df['sample'] == 'blocked'].groupby('year').agg({'rev_id':'count', 'toxicity':'sum', 'toxicity_score':'mean'}).reset_index().rename(columns = col_rename) toxic_df_trend_blocked['toxicity_ratio'] = toxic_df_trend_blocked['toxicity'] / toxic_df_trend...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Toxicity Ratio Sampling
plt.figure() plt.ticklabel_format(style='plain') plt.plot(toxic_df_trend.year, toxic_df_trend.toxicity_ratio, color = 'black', label ='Total') plt.plot(toxic_df_trend_random.year, toxic_df_trend_random.toxicity_ratio, color = 'blue', label ='Random') plt.plot(toxic_df_trend_blocked.year, toxic_df_trend_blocked.toxicity...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Toxicity Score Sampling
plt.figure() plt.ticklabel_format(style='plain') plt.plot(toxic_df_trend.year, toxic_df_trend.toxicity_score_reversed, color = 'black', label ='Total') plt.plot(toxic_df_trend_random.year, toxic_df_trend_random.toxicity_score_reversed, color = 'blue', label ='Random') plt.plot(toxic_df_trend_blocked.year, toxic_df_tren...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
There appears to be a big difference in both the scoring and ratio when the sampling is done from blocked sources or when it is collected randomly. When sampled from blocked sources, the toxicity score turns positive right on its peak at 2008, but drops to negative values after 2009. When the sample is picked randoml...
aggressions_df.head()
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Lets first look at a general time trend of the entire dataset on a per year basis Preprocessing
col_rename = {'rev_id':'count'} aggressions_df_trend = aggressions_df.groupby('year').agg({'rev_id':'count', 'aggression':'sum', 'aggression_score':'mean'}).reset_index().rename(columns = col_rename) aggressions_df_trend['aggression_ratio'] = aggressions_df_trend['aggression'] / aggressions_df_trend['count'] aggression...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
While neutral comments are highly dominant in here, there appears to be slightly more aggressive comments than healthy comments. Aggression Ratio
plt.figure() plt.ticklabel_format(style='plain') plt.plot(aggressions_df_trend.year, aggressions_df_trend.aggression_ratio) plt.grid(True) plt.title("Aggression Ratio Over Time")
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Agression Score
plt.figure() plt.ticklabel_format(style='plain') plt.plot(aggressions_df_trend.year, aggressions_df_trend.aggression_score_reversed) plt.grid(True) plt.title("Aggression Score Over Time")
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
The overall trend here is similar to what we saw with toxicity. There appears to be a sharp increase until year 2008 at its peak, plateauing consistently afterwards. The scoress however, appear to reach positive values before its peak at 2005 and remaining positive. While most comments appear to be neutral, there ar...
col_rename = {'rev_id':'count'} aggressions_df_trend_logged_in = aggressions_df[aggressions_df.logged_in == True].groupby('year').agg({'rev_id':'count', 'aggression':'sum', 'aggression_score':'mean'}).reset_index().rename(columns = col_rename) aggressions_df_trend_logged_in['aggression_ratio'] = aggressions_df_trend_lo...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Aggression Ratio Log In
plt.figure() plt.ticklabel_format(style='plain') plt.plot(aggressions_df_trend.year, aggressions_df_trend.aggression_ratio, color = 'black', label ='Total') plt.plot(aggressions_df_trend_logged_in.year, aggressions_df_trend_logged_in.aggression_ratio, color = 'blue', label ='Logged In') plt.plot(aggressions_df_trend_no...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Aggressions dataset appears to not have any data on comments made without logging in after year 2002. Lets look at the difference of blocked vs randomly sampled sources Preprocessing
col_rename = {'rev_id':'count'} aggressions_df_trend_blocked = aggressions_df[aggressions_df['sample'] == 'blocked'].groupby('year').agg({'rev_id':'count', 'aggression':'sum', 'aggression_score':'mean'}).reset_index().rename(columns = col_rename) aggressions_df_trend_blocked['aggression_ratio'] = aggressions_df_trend_b...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Aggression Ratio Sampling
plt.figure() plt.ticklabel_format(style='plain') plt.plot(aggressions_df_trend.year, aggressions_df_trend.aggression_ratio, color = 'black', label ='Total') plt.plot(aggressions_df_trend_random.year, aggressions_df_trend_random.aggression_ratio, color = 'blue', label ='Random') plt.plot(aggressions_df_trend_blocked.yea...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Aggression Score Sampling
plt.figure() plt.ticklabel_format(style='plain') plt.plot(aggressions_df_trend.year, aggressions_df_trend.aggression_score_reversed, color = 'black', label ='Total') plt.plot(aggressions_df_trend_random.year, aggressions_df_trend_random.aggression_score_reversed, color = 'blue', label ='Random') plt.plot(aggressions_df...
_____no_output_____
MIT
data-512-a2/notebook.ipynb
jameslee0920/data-512
Solving `CartPole` Your task:Solve the `CartPole` environment. Which algorithms could you use? As a warm-up, implement first SARSA or Q-Learning in `FrozenLake`. Some starter code is below. Note that if you want to use these algorithms for `CartPole` you need to discretize the state space somehow.
%matplotlib inline import matplotlib.pyplot as plt import numpy as np import gym import math
_____no_output_____
MIT
.ipynb_checkpoints/Exercise - Solving Cart-Pole-checkpoint.ipynb
jpmaldonado/packt-rl
How could you know how to discretize?You can try to sample some elements from the observation space (=state space). Then discretize based on that.
cp_env = gym.make('CartPole-v0') cp_obs = [cp_env.observation_space.sample() for _ in range(10000)] plt.hist([ob[0] for ob in cp_obs] ) plt.title("Observation x") plt.hist([ob[1] for ob in cp_obs] ) plt.title("Observation x_dot") plt.hist([ob[2] for ob in cp_obs] ) plt.title("Observation theta") plt.hist([ob[3] for ob ...
_____no_output_____
MIT
.ipynb_checkpoints/Exercise - Solving Cart-Pole-checkpoint.ipynb
jpmaldonado/packt-rl
Then, we define some limit for the borders.
STATE_BOUNDS = list(zip(cp_env.observation_space.low, cp_env.observation_space.high)) STATE_BOUNDS[1] = [-0.5, 0.5] STATE_BOUNDS[3] = [-math.radians(50), math.radians(50)] NUM_BUCKETS = (3,3,3,3) # state:n_bins pairs def obs_to_state(obs): bucket_indice = [] for i in range(len(obs)): if obs[i] <= STATE_...
WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype. Number of episodes: 100 . Average 100-episode reward: 26.05
MIT
.ipynb_checkpoints/Exercise - Solving Cart-Pole-checkpoint.ipynb
jpmaldonado/packt-rl
Installation - Run these commands - git clone https://github.com/Tessellate-Imaging/Monk_Object_Detection.git - cd Monk_Object_Detection/6_cornernet_lite/installation - Select the right requirements file and run - chmod +x install.sh - ./install.sh About the network1. Paper on CornerNe...
import os import sys sys.path.append("../../6_cornernet_lite/lib/") from train_detector import Detector gtf = Detector(); root_dir = "../sample_dataset"; coco_dir = "kangaroo" img_dir = "/" set_dir = "Images" gtf.Train_Dataset(root_dir, coco_dir, img_dir, set_dir, batch_size=4, use_gpu=True, num_workers=4) gtf.Model(mo...
start_iter = 0 distributed = False world_size = 0 initialize = False batch_size = 4 learning_rate = 0.00025 max_iteration = 1000 stepsize = 800 snapshot = 500 val_iter = 500 display = 100 decay_rate = 10 Process 0: building model... total paramet...
Apache-2.0
example_notebooks/6_cornernet_lite/Train CornerNet-Squeeze.ipynb
jayeshk7/Monk_Object_Detection
Inference
import os import sys sys.path.append("../../6_cornernet_lite/lib/") from infer_detector import Infer gtf = Infer(); class_list = ["kangaroo"] gtf.Model(class_list, base="CornerNet_Squeeze", model_path="./cache/nnet/CornerNet_Squeeze/CornerNet_Squeeze_final.pkl") boxes = gtf.Predict("../sample_data...
_____no_output_____
Apache-2.0
example_notebooks/6_cornernet_lite/Train CornerNet-Squeeze.ipynb
jayeshk7/Monk_Object_Detection
Dataframes: The Basics This tutorial will cover the following topics:* Storing a dataframe as a TileDB 1D dense array to allow fast (out-of-core) slicing on rows* Storing a dataframe as a TileDB ND sparse array to allow fast (out-of-core) execution of column range predicates* Interoperating with Pandas and [Apache Arr...
!wget https://s3.amazonaws.com/nyc-tlc/trip+data/yellow_tripdata_2020-01.csv !ls -alh yellow_tripdata_2020-01.csv
-rw-rw---- 1 stavros staff 566M Jul 30 00:07 yellow_tripdata_2020-01.csv
MIT
tutorials/notebooks/python/dataframes/df_basics.ipynb
TileDB-Inc/TileDB-Examples
InstallationYou need to install [TileDB-Py](https://github.com/TileDB-Inc/TileDB-Py), the Python wrapper of [TileDB Embedded](https://github.com/TileDB-Inc/TileDB), as follows: ```bash Pip:$ pip install tiledb Or Conda:$ conda install -c conda-forge tiledb-py``` The notebook was run using **Pandas 1.1.0**. Note that t...
import tiledb, numpy as np # Version of TileDB core (C++ library) tiledb.libtiledb.version() # Version of TileDB-Py (Python wrapper) tiledb.__version__
_____no_output_____
MIT
tutorials/notebooks/python/dataframes/df_basics.ipynb
TileDB-Inc/TileDB-Examples
Before we start, we create the TileDB context passing a **configuration parameter** around memory allocation during read queries that will be explained in a later tutorial. That needs to be set at the *very beginning* of the code and before any other TileDB function is called.
cfg = tiledb.Ctx().config() cfg.update( { 'py.init_buffer_bytes': 1024**2 * 50 } ) tiledb.default_ctx(cfg)
_____no_output_____
MIT
tutorials/notebooks/python/dataframes/df_basics.ipynb
TileDB-Inc/TileDB-Examples
We also enable the TileDB **stats** so that we can get some insight into performance.
tiledb.stats_enable()
_____no_output_____
MIT
tutorials/notebooks/python/dataframes/df_basics.ipynb
TileDB-Inc/TileDB-Examples
The Dense Case We ingest the `yellow_tripdata_2020-01.csv` CSV file into a TileDB dense array as shown below. The command takes the taxi CSV file and ingests it into a 1D dense array called `taxi_dense_array`. It sets the tile extent to 100K, which means that groups of 100K rows each across every column will comprise ...
%%time tiledb.stats_reset() tiledb.from_csv("taxi_dense_array", "yellow_tripdata_2020-01.csv", tile = 100000, parse_dates=['tpep_dropoff_datetime', 'tpep_pickup_datetime'], fillna={'store_and_fwd_flag': ''}) tiledb.stats_dump()
/opt/miniconda3/envs/tiledb/lib/python3.8/site-packages/IPython/core/magic.py:187: DtypeWarning: Columns (6) have mixed types.Specify dtype option on import or set low_memory=False. call = lambda f, *a, **k: f(*a, **k)
MIT
tutorials/notebooks/python/dataframes/df_basics.ipynb
TileDB-Inc/TileDB-Examples