Unnamed: 0 int64 0 16k | text_prompt stringlengths 110 62.1k | code_prompt stringlengths 37 152k |
|---|---|---|
6,900 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<a href='http
Step1: Universal Array Functions
Numpy comes with many universal array functions, which are essentially just mathematical operations you can use to perform the operation acros... | Python Code:
import numpy as np
arr = np.arange(0, 10)
arr + arr
arr * arr
arr - arr
# Warning on division by zero, but not an error!
# Just replaced with nan
arr / arr
# Also warning, but not an error instead infinity
1 / arr
arr ** 3
Explanation: <a href='http://www.pieriandata.com'> <img src='../Pierian_Data_Logo.pn... |
6,901 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Cascade (HD-CNN Model Deriative)
Objective
This notebook demonstrates building a hierachical image classifer based on a HD-CNN deriative which uses cascading classifers to predict the class ... | Python Code:
!gsutil cp gs://cloud-samples-data/air/fruits360/fruits360-combined.zip .
!ls
!unzip -qn fruits360-combined.zip
Explanation: Cascade (HD-CNN Model Deriative)
Objective
This notebook demonstrates building a hierachical image classifer based on a HD-CNN deriative which uses cascading classifers to predict th... |
6,902 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Siu expression autocompletion
Step2: In this ADR, I will review how we can find the right DataFrame to autocomplete, the state of autocompletion in IPython, and three potential solutions.
K... | Python Code:
from siuba.siu import _
dir(_)[:6]
Explanation: Siu expression autocompletion: _.cyl.\<tab>
Note: this is document is based on PR 248 by @tmastny, and all the discussion there!
(Drafted on 7 August 2020)
tl;dr. Implementing autocompletion requires 3 components: identifying the DataFrame to complete, unders... |
6,903 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Cross-Validation and scoring methods
In the previous sections and notebooks, we split our dataset into two parts, a training set and a test set. We used the training set to fit our model, an... | Python Code:
from sklearn.datasets import load_iris
from sklearn.neighbors import KNeighborsClassifier
iris = load_iris()
X, y = iris.data, iris.target
classifier = KNeighborsClassifier()
Explanation: Cross-Validation and scoring methods
In the previous sections and notebooks, we split our dataset into two parts, a tra... |
6,904 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Intro to Thinc's Model class, model definition and methods
Thinc follows a functional-programming approach to model definition. Its approach is especially effective for complicated network a... | Python Code:
!pip install "thinc>=8.0.0"
Explanation: Intro to Thinc's Model class, model definition and methods
Thinc follows a functional-programming approach to model definition. Its approach is especially effective for complicated network architectures, and use cases where different data types need to be passed thr... |
6,905 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h3 STYLE="background
Step1: <h3 STYLE="background
Step2: <h3 STYLE="background
Step3: <h3 STYLE="background
Step4: matplotlib で定義済みのカラーマップで彩色できます。次の例では、quality に応じて coolwarm に従った彩色を行います... | Python Code:
# 数値計算やデータフレーム操作に関するライブラリをインポートする
import numpy as np
import pandas as pd
# URL によるリソースへのアクセスを提供するライブラリをインポートする。
# import urllib # Python 2 の場合
import urllib.request # Python 3 の場合
# 図やグラフを図示するためのライブラリをインポートする。
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
from matplo... |
6,906 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Appendix D – Autodiff
This notebook contains toy implementations of various autodiff techniques, to explain how they works.
<table align="left">
<td>
<a target="_blank" href="https
Ste... | Python Code:
# To support both python 2 and python 3
from __future__ import absolute_import, division, print_function, unicode_literals
Explanation: Appendix D – Autodiff
This notebook contains toy implementations of various autodiff techniques, to explain how they works.
<table align="left">
<td>
<a target="_bla... |
6,907 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Parsing events from raw data
This tutorial describes how to read experimental events from raw recordings,
and how to convert between the two different representations of events within
MNE-Py... | Python Code:
import os
import numpy as np
import mne
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file)
raw.crop(tmax=60).load_data()
Ex... |
6,908 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Running and Weight Data Cleaning
Four disparate sources
Each have different features and formats, units, etc.
Work through to figure out requisite steps for processing and combining
Once don... | Python Code:
%matplotlib inline
import pandas as pd
import numpy as np
Explanation: Running and Weight Data Cleaning
Four disparate sources
Each have different features and formats, units, etc.
Work through to figure out requisite steps for processing and combining
Once done, wrap all steps up into concise functions fo... |
6,909 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Two Layer QG Model Example
Here is a quick overview of how to use the two-layer model. See the
Step1: Initialize and Run the Model
Here we set up a model which will run for 10 years and sta... | Python Code:
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline
import pyqg
Explanation: Two Layer QG Model Example
Here is a quick overview of how to use the two-layer model. See the
:py:class:pyqg.QGModel api documentation for further details.
First import numpy, matplotlib, and pyqg:
End of e... |
6,910 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Finding the right capcha with Keras
Step1: We first define a function to prepare the datas in the format of keras (theano). The function also reduces the size of the imagesfrom 100X100 to 3... | Python Code:
import os
import numpy as np
import tools as im
from matplotlib import pyplot as plt
from skimage.transform import resize
%matplotlib inline
path=os.getcwd()+'/' # finds the path of the folder in which the notebook is
path_train=path+'images/train/'
path_test=path+'images/test/'
path_real=path+'images/real... |
6,911 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Test Access to Earth Engine
Run the code blocks below to test if the notebook server is authorized to communicate with the Earth Engine backend servers.
First, check if the IPython Widgets l... | Python Code:
# Code to check the IPython Widgets library.
try:
import ipywidgets
print('The IPython Widgets library (version {0}) is available on this server.'.format(
ipywidgets.__version__
))
except ImportError:
print('The IPython Widgets library is not available on this server.\n'
'Please see... |
6,912 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
I. Basics
All the toolbox is a package tree.
You need to import the __init__.py file at the root of each package add the toolbox toplevel to your path.
Step1: Database
The voc database is i... | Python Code:
import __init__
Explanation: I. Basics
All the toolbox is a package tree.
You need to import the __init__.py file at the root of each package add the toolbox toplevel to your path.
End of explanation
import cpLib.conceptDB as db
Explanation: Database
The voc database is instanciated with a given voc stored... |
6,913 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h1>Training Keras model on Cloud AI Platform</h1>
<h2>Learning Objectives</h2>
<ol>
<li>Create model arguments for hyperparameter tuning</li>
<li>Create the model and specify checkpoints du... | Python Code:
# change these to try this notebook out
BUCKET = 'cloud-training-demos-ml'
PROJECT = 'cloud-training-demos'
REGION = 'us-central1'
import os
os.environ['BUCKET'] = BUCKET
os.environ['PROJECT'] = PROJECT
os.environ['REGION'] = REGION
os.environ['TFVERSION'] = '2.0' # not used in this notebook
%%bash
gcloud... |
6,914 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<center>
<h1> ILI285 - Computación Científica I / INF285 - Computación Científica </h1>
<h2> Newton's Method in $\mathbb{R}^n$ </h2>
<h2> <a href="#acknowledgements"> [S]cientif... | Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from ipywidgets import interact
Explanation: <center>
<h1> ILI285 - Computación Científica I / INF285 - Computación Científica </h1>
<h2> Newton's Method in $\mathbb{R}^n$ </h2>
<h2> <a href="#acknowledgements"> [S]cientific... |
6,915 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Scikit-Learn
scikit-learn is a Python library that provides many machine learning algorithms via a consistent API known as the estimator.
Step1: Validation Data
Using validation data, we av... | Python Code:
import numpy as np
Explanation: Scikit-Learn
scikit-learn is a Python library that provides many machine learning algorithms via a consistent API known as the estimator.
End of explanation
from sklearn.model_selection import train_test_split
# Let X be our input data consisting of
# 5 samples and 2 feature... |
6,916 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
The Neverending Search for Periodicity
Step1: Problem 1b
Create a function gen_periodic_data that returns
$$y = C + A\cos\left(\frac{2\pi x}{P}\right) + \sigma_y$$
where $C$, $A$, and $P$ ... | Python Code:
ncores = # adjust to number of CPUs on your machine
np.random.seed(23)
Explanation: The Neverending Search for Periodicity: Techniques Beyond Lomb-Scargle
Version 0.1
By AA Miller 28 Apr 2018
In this lecture we will examine alternative methods to search for periodic signals in astronomical time se... |
6,917 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step1: For this problem set, we'll be using the Jupyter notebook
Step4: Your function should print [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] for $n=10$. Check that it does
Step6: Part B (1 po... | Python Code:
def squares(n):
Compute the squares of numbers from 1 to n, such that the
ith element of the returned list equals i^2.
### BEGIN SOLUTION
if n < 1:
raise ValueError("n must be greater than or equal to 1")
return [i ** 2 for i in range(1, n + 1)]
### END SOLUTION
E... |
6,918 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2020 The TensorFlow Authors.
Step1: TensorFlow graph optimization with Grappler
<table class="tfo-notebook-buttons" align="left">
<td>
<a target="_blank" href="https
Step2: ... | Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# dist... |
6,919 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
notation for differentation
We'll mostly use Lagrange's notation, the first three deriviatives of a function $f$ are denoted $f'$, $f''$ and $f'''$. After that we'll use $f^{(4)}, f^{(5)}, \... | Python Code:
c1 = lambda x: x + 1
c2 = lambda x: -x + 2
x1 = np.linspace(0.01, 2, 10)
x2 = np.linspace(-2, -0.01, 10)
plt.plot(x1, c1(x1), label=r"$y = x + 1$")
plt.plot(x2, c2(x2), label=r"$y = -x + 2$")
plt.plot(0, 2, 'wo', markersize=7)
plt.plot(0, 1, 'wo', markersize=7)
ax = plt.axes()
ax.set_ylim(0, 4)
plt.legend(... |
6,920 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2019 The TensorFlow Authors.
Step1: TensorBoard Scalars
Step2: Set up data for a simple regression
You're now going to use Keras to calculate a regression, i.e., find the best li... | Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# dist... |
6,921 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
4.a Plot type - xy
Our first plot example is a simple xy-plot and the graphics output format is PNG.
Step1: To use Numpy arrays we need to import the module.
Define x- and y-values
Step2: ... | Python Code:
import Ngl
wks = Ngl.open_wks('png', 'plot_xy')
Explanation: 4.a Plot type - xy
Our first plot example is a simple xy-plot and the graphics output format is PNG.
End of explanation
import numpy as np
x = np.arange(0,5)
y = np.arange(0,10,2)
plot = Ngl.xy(wks, x, y)
Explanation: To use Numpy arrays we need ... |
6,922 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h1>PDBbind Database</h1>
Step1: Download a dataset from PDBbind and unpack (I used core-set 2016).
Step2: We will use the pdbbind class.
Step3: You can get one target or iterate over all... | Python Code:
from __future__ import print_function, division, unicode_literals
import oddt
from oddt.datasets import pdbbind
oddt.toolkit.image_size = (400, 400)
print(oddt.__version__)
Explanation: <h1>PDBbind Database</h1>
End of explanation
%%bash
wget -qO- http://www.pdbbind.org.cn/download/pdbbind_v2016_core.tar.g... |
6,923 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Phoenix BT-Settl Bolometric Corrections
Figuring out the best method of handling Phoenix bolometric correction files.
Step1: Change to directory containing bolometric correction files.
Step... | Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import scipy.interpolate as scint
Explanation: Phoenix BT-Settl Bolometric Corrections
Figuring out the best method of handling Phoenix bolometric correction files.
End of explanation
cd /Users/grefe950/Projects/starspot/starspot/color/t... |
6,924 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Seismic NMO Widget
Using the Notebook
This is the <a href="https
Step1: Two common-mid-point (CMP) gathers
Step2: Step 2
Step3: Step 3
Step4: Step 4 | Python Code:
%pylab inline
from geoscilabs.seismic.NMOwidget import ViewWiggle, InteractClean, InteractNosiy, NMOstackthree
from SimPEG.utils import download
# Define path to required data files
synDataFilePath = 'http://github.com/geoscixyz/geosci-labs/raw/master/assets/seismic/syndata1.npy'
obsDataFilePath = 'https:/... |
6,925 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
XML
Die Extensible Markup Language ist ein Format und ein Metasprache für (primär) hierarchische Sprachen. Da XML in einigen anderen Lehrveranstaltungen verwendet wird, gehe ich hier nicht n... | Python Code:
import xml.etree.ElementTree as ET
Explanation: XML
Die Extensible Markup Language ist ein Format und ein Metasprache für (primär) hierarchische Sprachen. Da XML in einigen anderen Lehrveranstaltungen verwendet wird, gehe ich hier nicht näher darauf ein, sondern möchte nur kurz zeigen, wie man XML mit Pyth... |
6,926 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Introduction
You have the tools to obtain data from a single table in whatever format you want it. But what if the data you want is spread across multiple tables?
That's where JOIN comes in!... | Python Code:
#$HIDE_INPUT$
from google.cloud import bigquery
# Create a "Client" object
client = bigquery.Client()
# Construct a reference to the "github_repos" dataset
dataset_ref = client.dataset("github_repos", project="bigquery-public-data")
# API request - fetch the dataset
dataset = client.get_dataset(dataset_ref... |
6,927 | Given the following text problem statement, write Python code to implement the functionality described below in problem statement
Problem:
I am using KMeans in sklearn on a data set which have more than 5000 samples. And I want to get the 50 samples(not just index but full data) closest to "p" (e.g. p=2), a cluster cen... | Problem:
import numpy as np
import pandas as pd
from sklearn.cluster import KMeans
p, X = load_data()
assert type(X) == np.ndarray
km = KMeans()
km.fit(X)
d = km.transform(X)[:, p]
indexes = np.argsort(d)[::][:50]
closest_50_samples = X[indexes] |
6,928 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Reading and Writing Models
Cobrapy supports reading and writing models in SBML (with and without FBC), JSON, MAT, and pickle formats. Generally, SBML with FBC version 2 is the preferred form... | Python Code:
import cobra.test
import os
from os.path import join
data_dir = cobra.test.data_directory
print("mini test files: ")
print(", ".join(i for i in os.listdir(data_dir)
if i.startswith("mini")))
textbook_model = cobra.test.create_test_model("textbook")
ecoli_model = cobra.test.create_test_model... |
6,929 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<center>
<img src="https
Step1: 1.4 Creating cells
To create a new code cell, click "Insert > Insert Cell [Above or Below]". A code cell will automatically be created.
To create a new markd... | Python Code:
# Hit shift + enter or use the run button to run this cell and see the results
print 'Hello PyLadies'
# The last line of every code cell will be displayed by default,
# even if you don't print it. Run this cell to see how this works.
2 + 2 # The result of this line will not be displayed
3 + 3 # The result... |
6,930 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Well near a straight river
Step1: Consider a well in the middle aquifer of a three aquifer system located at $(x,y)=(0,0)$. The well starts pumping at time $t=0$ at a discharge of $Q=1000$ ... | Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from ttim import *
Explanation: Well near a straight river
End of explanation
ml = ModelMaq(kaq=[1, 20, 2], z=[25, 20, 18, 10, 8, 0], c=[1000, 2000],
Saq=[0.1, 1e-4, 1e-4], Sll=[0, 0], phreatictop=True,
tmin=0... |
6,931 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Standard pandas imports
Step1: We'll be working with data from the bike rental setup
Step2: Let's inspect it
Step3: That must be the only numeric value, let's try again
Step4: Wow, those... | Python Code:
from pandas import DataFrame, Series
import pandas as pd
import numpy as np
Explanation: Standard pandas imports
End of explanation
weather = pd.read_table('daily_weather.tsv', parse_dates=['date'])
stations = pd.read_table('stations.tsv')
usage = pd.read_table('usage_2012.tsv', parse_dates=['time_start', ... |
6,932 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Pandas offers a powerful interface for data
manipulation and analysis, but the dataframe can be an opaque object that’s
hard to reason about in terms of its data types and other properties. ... | Python Code:
import logging
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from collections import OrderedDict
from IPython.display import display, Markdown
from sodapy import Socrata
logging.disable(logging.WARNING)
# utility function to print python output as markdown snippets
def print_out... |
6,933 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
3章 ニューラルネットワーク
パーセプトロンは複雑な関数を表現できるが、重みは人力で設定する必要があった。
ニューラルネットワークでは適切な重みパラメータをデータから自動で学習できる性質が備わっている
3.1 パーセプトロンからニューラルネットワークへ
3.1.1 ニューラルネットワークの例
例として下図のようなネットワークがある。中間層は隠れ層とも呼ばれる。入力層から出力層へ... | Python Code:
import matplotlib.pyplot as plt
from matplotlib.image import imread
from graphviz import Digraph
f = Digraph(format="png")
f.attr(rankdir='LR')
f.attr('node', shape='circle')
f.node('x1','')
f.node('x2','')
f.node('s1','')
f.node('s2','')
f.node('s3','')
f.node('y1','')
f.node('y2','')
with f.subgraph(name... |
6,934 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Django-Geo-SPaaS - GeoDjango framework for Satellite Data Management
First of all we need to initialize Django to work. Let's do some 'magic'
Step1: Now we can import our models
Step2: Now... | Python Code:
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'geospaas_project.settings'
sys.path.insert(0, '/vagrant/shared/course_vm/geospaas_project/')
import django
django.setup()
from django.conf import settings
Explanation: Django-Geo-SPaaS - GeoDjango framework for Satellite Data Management
First of all we... |
6,935 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<img src="http
Step1: Second, the instantiation of the class.
Step2: The following is an example list object containing datetime objects.
Step3: The call of the method get_forward_reates(... | Python Code:
from dx import *
me = market_environment(name='me', pricing_date=dt.datetime(2015, 1, 1))
me.add_constant('initial_value', 0.01)
me.add_constant('volatility', 0.1)
me.add_constant('kappa', 2.0)
me.add_constant('theta', 0.05)
me.add_constant('paths', 1000)
me.add_constant('frequency', 'M')
me.add_constant('... |
6,936 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Introduction
Simply the first step to prepare the data for the following notebooks
Step1: Data source is http
Step2: Can also migrate it to a sqlite database
Step3: Can perform queries | Python Code:
import Quandl
import pandas as pd
import numpy as np
import blaze as bz
Explanation: Introduction
Simply the first step to prepare the data for the following notebooks
End of explanation
with open('../.quandl_api_key.txt', 'r') as f:
api_key = f.read()
db = Quandl.get("EOD/DB", authtoken=api_key)
bz.od... |
6,937 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
PCA主元分析
假设数据符合高斯分布,目标是得到一组正交基,使得数据在这组正交基上分布放方差最大,PCA最大的用途是数据降维。
已知一组数据$(X_1, X_2, ..., X_N)$,其中每个数据$X_i$都是n维列向量,利用矩阵分解求解PCA的步骤如下
1. 计算均值
$X_{mean} = \frac{1}{N}\sum_{i=1}^N X_i$
2. 去中心化... | Python Code:
import cv2
import sys,os
import numpy as np
sample_size = (64//2,64//2)
smallset_size = 10 #每类下采样,方便调试
flag_debug = True
def load_mnist(num_per_class, dataset_root="C:/dataset/mnist/",resize=sample_size):
data_pairs = []
labeldict = {}
ds_root = os.path.join(dataset_root,'train')
for rdir, ... |
6,938 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
HTML Bias CV view
showing ["institution", "institute_id", "bc_method", "bc_method_id",
"institute_id"-"bc_method_id", "terms_of_use", "CORDEX_domain",
"reference", "pack... | Python Code:
result = web.jsonfile_to_dict("/home/stephan/Repos/ENES-EUDAT/cordex/CORDEX_adjust_register.json")
html_out = web.generate_bias_table(result)
HTML(html_out)
Explanation: HTML Bias CV view
showing ["institution", "institute_id", "bc_method", "bc_method_id",
"institute_id"-"bc_method_id", "terms_of... |
6,939 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
The Return of the Functions
1) Rappels sur les fonctions
Quand a t'on besoin d'une fonction ?
dB or not dB ?
Définir ou Utiliser ?
1.1) Quand à t'on besoin d'ecrire une fonction ?
Pas toujo... | Python Code:
'''
De nombreuses fonction existent déjà
Python permet aussi d'appeller des fonction nouvelles
D'abord nous allons voire les appels au sytème,
puis des fonctions comme print que nous utilisions toujours
print(VARIABLE)
'''
A=!date
# ici A est à un type "IPython.utils.text.SList" c'est une liste
print(A... |
6,940 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Response Distributions
Lets look at the answer distributions for each of the 3 questions in out survey.
Step1: Load and Prep Data
Step2: Q1 Information Depth
I am reading this article to .... | Python Code:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import inspect, os
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
os.sys.path.insert(0,parentdir)
from data_generation.join_traces_and_survey import load_survey_dfs
from re... |
6,941 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
author = "Peter J Usherwood"
Estas tutorias são um introdução para Python no contexto de ciência de dados. Elas não assumem conhecimento prévio de Python ou programação de computadors, comec... | Python Code:
lista = [1,2,23,4,2]
lista.sort()
lista
# Instanciando
# A variável "a" é um numero com valor 7
a = 7
# A variável "name" é cadeia, ele pode tem qualquer caracteres no teclado
nome = 'Felipe'
print('O valor da "a" é:', a) # Aqui "print()" e "type()" são funções, vou explicar sobre elas mais tarde
print('O... |
6,942 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Handwritten Number Recognition with TFLearn and MNIST
In this notebook, we'll be building a neural network that recognizes handwritten numbers 0-9.
This kind of neural network is used in a ... | Python Code:
# Import Numpy, TensorFlow, TFLearn, and MNIST data
import numpy as np
import tensorflow as tf
import tflearn
import tflearn.datasets.mnist as mnist
Explanation: Handwritten Number Recognition with TFLearn and MNIST
In this notebook, we'll be building a neural network that recognizes handwritten numbers 0-... |
6,943 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Chapter 9 Convolutional Networks
Convolution is a specialized kind of linear operation.
9.1 The Convolution Operation
\begin{align}
s(t) &= \int x(a) w(t-a) \mathrm{d}a \
&= (x ... | Python Code:
show_image("fig9_1.png", figsize=(8, 8))
Explanation: Chapter 9 Convolutional Networks
Convolution is a specialized kind of linear operation.
9.1 The Convolution Operation
\begin{align}
s(t) &= \int x(a) w(t-a) \mathrm{d}a \
&= (x \ast w)(t)
\end{align}
where $x$ is the input, $w$ is the kerne... |
6,944 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Semana 1
Step1: Este código faz com que primeiramente toda a primeira linha seja preenchida, em seguida a segunda e assim sucessivamente. Se nós quiséssemos que a primeira coluna fosse pree... | Python Code:
def cria_matriz(tot_lin, tot_col, valor):
matriz = [] #lista vazia
for i in range(tot_lin):
linha = []
for j in range(tot_col):
linha.append(valor)
matriz.append(linha)
return matriz
x = cria_matriz(2, 3, 99)
x
def cria_matriz(tot_lin, tot_col, valor):
... |
6,945 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
This is a notebook to explore opSim outputs in different ways, mostly useful to supernova analysis. We will look at the opsim output called Enigma_1189
Step1: Read in OpSim output for moder... | Python Code:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
# Required packages sqlachemy, pandas (both are part of anaconda distribution, or can be installed with a python installer)
# One step requires the LSST stack, can be skipped for a particular OPSIM database in question
import OpSimSumma... |
6,946 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Linear Shell solution
Init symbols for sympy
Step1: Tymoshenko theory
$u_1 \left( \alpha_1, \alpha_2, \alpha_3 \right)=u\left( \alpha_1 \right)+\alpha_3\gamma \left( \alpha_1 \right) $
$u_2... | Python Code:
from sympy import *
from geom_util import *
from sympy.vector import CoordSys3D
import matplotlib.pyplot as plt
import sys
sys.path.append("../")
%matplotlib inline
%reload_ext autoreload
%autoreload 2
%aimport geom_util
# Any tweaks that normally go in .matplotlibrc, etc., should explicitly go here
%confi... |
6,947 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Team members have produced a list of know database tables.
I'm going to try to represent those in machine-readable format, and run tests against the API for existence and row-count
Table Nam... | Python Code:
import requests
import io
import pandas
from itertools import chain
def makeurl(tablename,start,end):
return "https://iaspub.epa.gov/enviro/efservice/{tablename}/JSON/rows/{start}:{end}".format_map(locals())
def table_count(tablename):
url= "https://iaspub.epa.gov/enviro/efservice/{tablename}/COUNT... |
6,948 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Title
Step1: Generate Features And Target Data
Step2: Create Logistic Regression
Step3: Cross-Validate Model Using Recall | Python Code:
# Load libraries
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import make_classification
Explanation: Title: Recall
Slug: recall
Summary: How to evaluate a Python machine learning using recall.
Date: 2017-09-15 12:00
Categor... |
6,949 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
SBML Parsing Example
Step1: Biomodels repository hosts a number of published models.
We can download one of them to our working directory
Step2: This model can be parsed into MEANS Model o... | Python Code:
import means
Explanation: SBML Parsing Example
End of explanation
import urllib
__ = urllib.urlretrieve("http://www.ebi.ac.uk/biomodels/models-main/publ/"
"BIOMD0000000010/BIOMD0000000010.xml.origin",
filename="autoreg.xml")
Explanation: Biomodels repository... |
6,950 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2020 The TensorFlow Authors.
Step1: Word Embeddings and Sentiment
<table class="tfo-notebook-buttons" align="left">
<td>
<a target="_blank" href="https
Step2: Get the datas... | Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# dist... |
6,951 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Names
Step1: 1. Background Information
1.1 Introduction to the Second Half of the Class
The remainder of this course will be divided into three two week modules, each dealing with a differe... | Python Code:
#various things that we will need
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import scipy.stats as st
Explanation: Names: [Insert Your Names Here]
Lab 9 - Data Investigation 1 (Week 1) - Educational Research Data
Lab 9 Contents
Background Information
Intro to ... |
6,952 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h1>Using pre-trained embeddings with TensorFlow Hub</h1>
This notebook illustrates
Step1: Install the TensorFlow Hub library
Step2: <h2>TensorFlow Hub Concepts</h2>
TensorFlow Hub is a li... | Python Code:
# change these to try this notebook out
BUCKET = 'cloud-training-demos-ml'
PROJECT = 'cloud-training-demos'
REGION = 'us-central1'
Explanation: <h1>Using pre-trained embeddings with TensorFlow Hub</h1>
This notebook illustrates:
<ol>
<li>How to instantiate a TensorFlow Hub module</li>
<li>How to f... |
6,953 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
7. Fixed Loops
In the previous lesson we studied conditional loops. Now it is time to see fixed loops.
What's the difference?
With a fixed loop, you know how many times you are going to rep... | Python Code:
for star in range(5):
print("*")
Explanation: 7. Fixed Loops
In the previous lesson we studied conditional loops. Now it is time to see fixed loops.
What's the difference?
With a fixed loop, you know how many times you are going to repeat the loop in advance. This is not the case with conditional loops... |
6,954 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Examples and Exercises from Think Stats, 2nd Edition
http
Step2: The estimation game
Root mean squared error is one of several ways to summarize the average error of an estimation process.
... | Python Code:
from __future__ import print_function, division
%matplotlib inline
import numpy as np
import brfss
import thinkstats2
import thinkplot
Explanation: Examples and Exercises from Think Stats, 2nd Edition
http://thinkstats2.com
Copyright 2016 Allen B. Downey
MIT License: https://opensource.org/licenses/MIT
End... |
6,955 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Working with EPA CEMS data
CEMS or <a href='https
Step1: The following settings and variables may be changed to impact the processing of this notebook
Step2: <a id='access'></a>
Accessing ... | Python Code:
%load_ext autoreload
%autoreload 2
# Standard libraries
import logging
import sys
import os
import pathlib
# 3rd party libraries
import geopandas as gpd
import dask.dataframe as dd
from dask.distributed import Client
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
import pandas ... |
6,956 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Eye traces in pipeline
Step1: Eye tracking traces are in EyeTracking and in its part table EyeTracking.Frame. EyeTracking is a grouping table that refers to one scan and one eye video, wher... | Python Code:
%pylab inline
pylab.rcParams['figure.figsize'] = (6, 6)
%matplotlib inline
import datajoint as dj
from pipeline import vis, preprocess
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
Explanation: Eye traces in pipeline
End of explanation
(dj.ERD.from_sequence([preprocess.EyeTrackin... |
6,957 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
As of this writing, the L1 h(t) data has a very large dynamic range at low frequencies. We need to remove this before doing anything.
Step1: Below are three options for bandpasses.
The firs... | Python Code:
data_dt=1.e20*data.astype(float64).detrend()
filt=sig.firwin(int(8*srate)-1,9./nyquist,pass_zero=False,window='hann')
data_hp=fir_filter(data_dt,filt)
Explanation: As of this writing, the L1 h(t) data has a very large dynamic range at low frequencies. We need to remove this before doing anything.
End of ex... |
6,958 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Naive Bayes
Vamos criar a classe Naive Bayes para representar o nosso algoritmo.
O método init representa o construtor, inicializando as variáveis do nosso modelo.
O modelo gerado é formado ... | Python Code:
from collections import defaultdict
from functools import reduce
import math
class NaiveBayes:
def __init__(self):
self.freqFeature = defaultdict(int)
self.freqLabel = defaultdict(int)
# condFreqFeature[label][feature]
self.condFreqFeature = defaultdict(lambda: defaultdi... |
6,959 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
sat-search
This notebook is a tutorial on how to use sat-search to search STAC APIs, save the results, and download assets.
Sat-search is built using sat-stac which provides the core Python ... | Python Code:
from satsearch import Search
search = Search(bbox=[-110, 39.5, -105, 40.5])
print('bbox search: %s items' % search.found())
search = Search(datetime='2018-02-12T00:00:00Z/2018-03-18T12:31:12Z')
print('time search: %s items' % search.found())
search = Search(query={'eo:cloud_cover': {'lt': 10}})
print('clou... |
6,960 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Updated Voce-Chaboche Model Fitting Example 1
An example of fitting the updated Voce-Chaboche (UVC) model to a set of test data is provided.
Documentation for all the functions used in this ... | Python Code:
import RESSPyLab as rpl
import numpy as np
Explanation: Updated Voce-Chaboche Model Fitting Example 1
An example of fitting the updated Voce-Chaboche (UVC) model to a set of test data is provided.
Documentation for all the functions used in this example can be found by either looking at docstrings for any ... |
6,961 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Rossiter-McLaughlin Effect
Setup
Let's first make sure we have the latest version of PHOEBE 2.3 installed (uncomment this line if running in an online notebook session such as colab).
Step1:... | Python Code:
#!pip install -I "phoebe>=2.3,<2.4"
Explanation: Rossiter-McLaughlin Effect
Setup
Let's first make sure we have the latest version of PHOEBE 2.3 installed (uncomment this line if running in an online notebook session such as colab).
End of explanation
import phoebe
import numpy as np
b = phoebe.default_bin... |
6,962 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Title
Step1: Load Image As Greyscale
Step2: Apply Adaptive Thresholding
Step3: View Image | Python Code:
# Load image
import cv2
import numpy as np
from matplotlib import pyplot as plt
Explanation: Title: Binarize Images
Slug: binarize_image
Summary: How to binarize images using OpenCV in Python.
Date: 2017-09-11 12:00
Category: Machine Learning
Tags: Preprocessing Images
Authors: Chris Albon
Preliminari... |
6,963 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Anna KaRNNa
In this notebook, I'll build a character-wise RNN trained on Anna Karenina, one of my all-time favorite books. It'll be able to generate new text based on the text from the book.... | Python Code:
import time
from collections import namedtuple
import numpy as np
import tensorflow as tf
Explanation: Anna KaRNNa
In this notebook, I'll build a character-wise RNN trained on Anna Karenina, one of my all-time favorite books. It'll be able to generate new text based on the text from the book.
This network ... |
6,964 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Table of Contents
<p><div class="lev1 toc-item"><a href="#Overview" data-toc-modified-id="Overview-1"><span class="toc-item-num">1 </span>Overview</a></div><div class="lev2 toc-it... | Python Code:
!pwd
Explanation: Table of Contents
<p><div class="lev1 toc-item"><a href="#Overview" data-toc-modified-id="Overview-1"><span class="toc-item-num">1 </span>Overview</a></div><div class="lev2 toc-item"><a href="#pwd---Print-Working-Directory" data-toc-modified-id="pwd---Print-Working-Directory-11... |
6,965 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Cortical Signal Suppression (CSS) for removal of cortical signals
This script shows an example of how to use CSS
Step1: Load sample subject data
Step2: Find patches (labels) to activate
St... | Python Code:
# Author: John G Samuelsson <johnsam@mit.edu>
import numpy as np
import matplotlib.pyplot as plt
import mne
from mne.datasets import sample
from mne.simulation import simulate_sparse_stc, simulate_evoked
Explanation: Cortical Signal Suppression (CSS) for removal of cortical signals
This script shows an exa... |
6,966 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Tutorial 2
Step1: These variables do not change anything in the simulation engine, but
are just standard Python variables. They are used to increase the
readability and flexibility of the s... | Python Code:
from __future__ import print_function
from espressomd import System, electrostatics, features
import espressomd
import numpy
import matplotlib.pyplot as plt
plt.ion()
# Print enabled features
required_features = ["EXTERNAL_FORCES", "MASS", "ELECTROSTATICS", "LENNARD_JONES"]
espressomd.assert_features(requi... |
6,967 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Sentiment Analysis with an RNN
In this notebook, you'll implement a recurrent neural network that performs sentiment analysis. Using an RNN rather than a feedfoward network is more accurate ... | Python Code:
import numpy as np
import tensorflow as tf
with open('reviews.txt', 'r') as f:
reviews = f.read()
with open('labels.txt', 'r') as f:
labels = f.read()
reviews[:2000]
Explanation: Sentiment Analysis with an RNN
In this notebook, you'll implement a recurrent neural network that performs sentiment ana... |
6,968 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Tutorial-1
The first thing to do to use the python wrappers is to import the package. PyDealII is only a shell and importing it will only allow you to call
python
help(PyDealII)
PyDealII i... | Python Code:
%matplotlib inline
import PyDealII.Debug as dealii
Explanation: Tutorial-1
The first thing to do to use the python wrappers is to import the package. PyDealII is only a shell and importing it will only allow you to call
python
help(PyDealII)
PyDealII is composed of two libraries:
- PyDealII.Debug which... |
6,969 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Filters
By Evgenia "Jenny" Nitishinskaya, Dr. Aidan O'Mahony, and Delaney Granizo-Mackenzie. Algorithms by David Edwards.
Kalman Filter Beta Estimation Example from Dr. Aidan O'Mahony's blog... | Python Code:
from SimPEG import *
%pylab inline
# Import a Kalman filter and other useful libraries
from pykalman import KalmanFilter
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import poly1d
Explanation: Filters
By Evgenia "Jenny" Nitishinskaya, Dr. Aidan O'Mahony, and Delaney Gra... |
6,970 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Model Selection Tutorial with Yellowbrick
In this tutorial, we are going to look at scores for a variety of scikit-learn models and compare them using visual diagnostic tools from Yellowbric... | Python Code:
from yellowbrick.datasets import load_mushroom
X, y = load_mushroom()
print(X[:5]) # inspect the first five rows
Explanation: Model Selection Tutorial with Yellowbrick
In this tutorial, we are going to look at scores for a variety of scikit-learn models and compare them using visual diagnostic tools from Y... |
6,971 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2019 The TensorFlow Hub Authors.
Licensed under the Apache License, Version 2.0 (the "License");
Step1: Exploring the TF-Hub CORD-19 Swivel Embeddings
<table class="tfo-notebook-b... | Python Code:
# Copyright 2019 The TensorFlow Hub Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless re... |
6,972 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Getting Started
This notebook gives a whirlwind overview of the ionchannelABC library and can be used for testing purposes of a first installation. The notebook follows the workflow for para... | Python Code:
# Importing standard libraries
import numpy as np
import pandas as pd
Explanation: Getting Started
This notebook gives a whirlwind overview of the ionchannelABC library and can be used for testing purposes of a first installation. The notebook follows the workflow for parameter inference of a generic T-typ... |
6,973 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Neural Networks
Lecture 3.
Augmenting the width (number of neurons) of the network allows to take more different combinations of the inputs, so somehow increases the dimensionality of the of... | Python Code:
%config InlineBackend.figure_format='retina'
%matplotlib inline
# Silence warnings
import warnings
warnings.simplefilter(action="ignore", category=FutureWarning)
warnings.simplefilter(action="ignore", category=UserWarning)
warnings.simplefilter(action="ignore", category=RuntimeWarning)
import numpy as np
n... |
6,974 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Import required python package and set the Cloudant credentials
flightPredict is a helper package used to train and run Spark MLLib models for predicting flight delays based on Weather data
... | Python Code:
sc.addPyFile("https://github.com/ibm-watson-data-lab/simple-data-pipe-connector-flightstats/raw/master/flightPredict/training.py")
sc.addPyFile("https://github.com/ibm-watson-data-lab/simple-data-pipe-connector-flightstats/raw/master/flightPredict/run.py")
import training
import run
%matplotlib inline
from... |
6,975 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Atmoschem
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Speci... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'nerc', 'ukesm1-0-mmh', 'atmoschem')
Explanation: ES-DOC CMIP6 Model Properties - Atmoschem
MIP Era: CMIP6
Institute: NERC
Source ID: UKESM1-0-MMH
Topic: Atmoschem
Sub-Topics: Transpor... |
6,976 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h1 align="center">API Examples</h1>
<h3 align="center">Author
Step1: 2. Create CFNCluster
Notice
Step2: After you verified the project information, you can execute the pipeline. When the ... | Python Code:
import os
import sys
sys.path.append(os.getcwd().replace("notebooks", "cfncluster"))
## S3 input and output address.
s3_input_files_address = "s3://path/to/input folder"
s3_output_files_address = "s3://path/to/output folder"
## CFNCluster name
your_cluster_name = "testonco"
## The private key pair for acce... |
6,977 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<img style='float
Step1: Connect to server
Step2: <hr> Sizing individual plots
The Lightning client let's you easily control plot size by specifying the width in pixels. Let's try a few si... | Python Code:
import os
from lightning import Lightning
from numpy import random
Explanation: <img style='float: left' src="http://lightning-viz.github.io/images/logo.png"> <br> <br> Controlling size in <a href='http://lightning-viz.github.io/'><font color='#9175f0'>Lightning</font></a>
<hr... |
6,978 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Dark Matter Substructure from Strong Lenses
Contact
Step3: Constants and Defaults
We start by defining several constants and defaults. Specifically, we are interested in the following param... | Python Code:
# General imports
%matplotlib inline
import logging
import numpy as np
import pylab as plt
from scipy import stats
from scipy import integrate
from scipy.integrate import simps,trapz,quad,nquad
from scipy.interpolate import interp1d
from scipy.misc import factorial
Explanation: Dark Matter Substructure fro... |
6,979 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Reading TSV files
Step1: transforming the "Pvalue_MMAP_V2_..." into danger score
Testing the function danger_score
Step3: QUESTION pour Guillaume
Step5: To be or not to be a CNV
Step6: R... | Python Code:
CWD = osp.join(osp.expanduser('~'), 'documents','grants_projects','roberto_projects', \
'guillaume_huguet_CNV','File_OK')
filename = 'Imagen_QC_CIA_MMAP_V2_Annotation.tsv'
fullfname = osp.join(CWD, filename)
arr = np.loadtxt(fullfname, dtype='str', comments=None, delimiter='\Tab',
... |
6,980 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Introduction to artifacts and artifact detection
Since MNE supports the data of many different acquisition systems, the
particular artifacts in your data might behave very differently from t... | Python Code:
import numpy as np
import mne
from mne.datasets import sample
from mne.preprocessing import create_ecg_epochs, create_eog_epochs
# getting some data ready
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif'
raw = mne.io.read_raw_fif(raw_fname, preload=True)
Explanatio... |
6,981 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Process the global variogram
Step1: STOP HERE This will calculate the variogram with chunks
Step2: Now the global variogram
For doing this I need to take a weighted average.
Or.. you can r... | Python Code:
# Load Biospytial modules and etc.
%matplotlib inline
import sys
sys.path.append('/apps')
import django
django.setup()
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
## Use the ggplot style
plt.style.use('ggplot')
from external_plugins.spystats import tools
%run ../testvariogram.py
... |
6,982 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2018 Google LLC.
Licensed under the Apache License, Version 2.0 (the "License");
Step1: Android Management API - Quickstart
If you have not yet read the Android Management API Cod... | Python Code:
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed un... |
6,983 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Lab 7
1) Scrieti un program care la fiecare x secunde unde x va fi aleator ales la fiecare iteratie (din intervalul [a, b] , unde a, b sunt date ca argumente) afiseaza de cate minute ruleaza... | Python Code:
import time
import random
#import sys
#a = int(sys.argv[1])
#b = int(sys.argv[2])
def wait(x):
time.sleep(x)
def time_cron(a,b):
time_interval = random.uniform(a,b)
# while(1):
# measure process time
t0 = time.clock()
wait(time_interval)
print time.clock() - t0, "seconds process... |
6,984 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Hour of Code 2015
For Mr. Clifford's Class (5C)
Perry Grossman
December 2015
Introduction
From the Hour of Code to the Power of Code
How to use programming skills for data analysis, or "data... | Python Code:
# you can also access this directly:
from PIL import Image
im = Image.open("DataScienceProcess.jpg")
im
#path=\'DataScienceProcess.jpg'
#image=Image.open(path)
Explanation: Hour of Code 2015
For Mr. Clifford's Class (5C)
Perry Grossman
December 2015
Introduction
From the Hour of Code to the Power of Code
H... |
6,985 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Examples and Exercises from Think Stats, 2nd Edition
http
Step1: Hypothesis testing
The following is a version of thinkstats2.HypothesisTest with just the essential methods
Step2: And here... | Python Code:
from __future__ import print_function, division
%matplotlib inline
import numpy as np
import random
import thinkstats2
import thinkplot
Explanation: Examples and Exercises from Think Stats, 2nd Edition
http://thinkstats2.com
Copyright 2016 Allen B. Downey
MIT License: https://opensource.org/licenses/MIT
En... |
6,986 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
This model buils a simple Hierarchial mixed effect model to look at dose response from 5 clinical trials.
In this example we are model the mean response from 5 different clinical trials. The... | Python Code:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
from pymc3 import Model, Normal, Lognormal, Uniform, trace_to_dataframe, df_summary
Explanation: This model buils a simple Hierarchial mixed effect model to look at dose response from 5 clinical... |
6,987 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
This notebook was created by Sergey Tomin for Workshop
Step1: Outline
Preliminaries
Step2: <a id="tutorial1"></a>
Tutorial N1. Double Bend Achromat.
We designed a simple lattice to demonst... | Python Code:
from IPython.display import Image
#Image(filename='gui_example.png')
Explanation: This notebook was created by Sergey Tomin for Workshop: Designing future X-ray FELs. Source and license info is on GitHub. August 2016.
An Introduction to Ocelot
Ocelot is a multiphysics simulation toolkit designed for study... |
6,988 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
OLGA tpl files, examples and howto
For an tpl file the following methods are available
Step1: Trend selection
A tpl file may contain hundreds of trends, in particular for complex networks. ... | Python Code:
tpl_path = '../../pyfas/test/test_files/'
fname = '11_2022_BD.tpl'
tpl = fa.Tpl(tpl_path+fname)
Explanation: OLGA tpl files, examples and howto
For an tpl file the following methods are available:
<b>filter_data</b> - return a filtered subset of trends
<b>extract</b> - extract a single trend variable
<b>to... |
6,989 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
.. _tut_viz_raw
Step1: The visualization module (
Step2: The channels are color coded by channel type. Generally MEG channels are
colored in different shades of blue, whereas EEG channels ... | Python Code:
import os.path as op
import mne
data_path = op.join(mne.datasets.sample.data_path(), 'MEG', 'sample')
raw = mne.io.read_raw_fif(op.join(data_path, 'sample_audvis_raw.fif'))
events = mne.read_events(op.join(data_path, 'sample_audvis_raw-eve.fif'))
Explanation: .. _tut_viz_raw:
Visualize Raw data
End of expl... |
6,990 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Doc2Vec Model
Introduces Gensim's Doc2Vec model and demonstrates its use on the
Lee Corpus <https
Step1: Doc2Vec is a core_concepts_model that represents each
core_concepts_document as a... | Python Code:
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
Explanation: Doc2Vec Model
Introduces Gensim's Doc2Vec model and demonstrates its use on the
Lee Corpus <https://hekyll.services.adelaide.edu.au/dspace/bitstream/2440/28910/1/hdl_28910.pdf>__.
E... |
6,991 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Exercice 1
Dans cet exercice, nous allons créer un fichier csv qui contiendra deux colonnes. La première est relative au nom du fichier et la deuxième à son identifiant. Nous allons dans une... | Python Code:
import sys, os
import re
from os import listdir
from os.path import isfile, join
Explanation: Exercice 1
Dans cet exercice, nous allons créer un fichier csv qui contiendra deux colonnes. La première est relative au nom du fichier et la deuxième à son identifiant. Nous allons dans une première étape parcour... |
6,992 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<img alt="sbmlutils logo" src="./images/sbmlutils-logo-small.png" style="height
Step1: SBML model creator
helper functions for generation of SBML models
constructors with all fields
patter... | Python Code:
from sbmlutils.report import sbmlreport
sbmlreport.create_sbml_report('./examples/glucose/Hepatic_glucose_3.xml',
out_dir='./examples/glucose', validate=True)
Explanation: <img alt="sbmlutils logo" src="./images/sbmlutils-logo-small.png" style="height: 60px;" />
sbmlutils: Py... |
6,993 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h1> Lax–Wendroff Method
The scalar advection equation
\begin{equation}
u_t+au_x=0
\end{equation}
has the standard Lax–Wendroff method
\begin{equation}
U^{n+1}_j = U_j^n - \frac{ak}{2h}\left... | Python Code:
# --------------------/
%matplotlib inline
# --------------------/
import math
import numpy as np
import matplotlib.pyplot as plt
from pylab import *
from scipy import *
from ipywidgets import *
Explanation: <h1> Lax–Wendroff Method
The scalar advection equation
\begin{equation}
u_t+au_x=0
\end{equation}
h... |
6,994 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Initial Data Analysis
Step 1
Step1: 1. What does the data describe?
The data describes SAT scores for verbal and math sections in 2001 across the US. It does appear to be complete, except f... | Python Code:
import scipy as sci
import pandas as pd
from scipy import stats
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# Remember that for specific functions, the array function in numpy
# can be useful in listing out the elements in a list (example would
# be for finding the mode.)
with... |
6,995 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<!-- dom
Step1: With $\boldsymbol{\beta}\in {\mathbb{R}}^{p\times 1}$, it means that we will hereafter write our equations for the approximation as
$$
\boldsymbol{\tilde{y}}= \boldsymbol{X}... | Python Code:
%matplotlib inline
# Common imports
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from IPython.display import display
import os
# Where to save the figures and data files
PROJECT_ROOT_DIR = "Results"
FIGURE_ID = "Results/FigureFiles"
DATA_ID = "DataFiles/"
if not os.path.exists(PRO... |
6,996 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Technical Specification Support
How imports work
Imports can be used in different ways depending on the use case and support levels.
People who want to support the latest version of STIX 2 w... | Python Code:
import stix2
stix2.Indicator()
Explanation: Technical Specification Support
How imports work
Imports can be used in different ways depending on the use case and support levels.
People who want to support the latest version of STIX 2 without having to make changes, can implicitly use the latest version:<div... |
6,997 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Importing the large datasets to a postgresql server and computing their metrics
It is not possible to load the larger data sets in the memory of a local machine therefeore an alternative is ... | Python Code:
import timeit
def stopwatch(function):
start_time = timeit.default_timer()
result = function()
print('Elapsed time: %i sec' % int(timeit.default_timer() - start_time))
return result
Explanation: Importing the large datasets to a postgresql server and computing their metrics
It is not possib... |
6,998 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Overview of the Settings Attribute
OpenPNM objects all include a settings attribute which contains certain information used by OpenPNM. The best example is the algorithm classes, which often... | Python Code:
import openpnm as op
pn = op.network.Cubic([4, 4,])
geo = op.geometry.SpheresAndCylinders(network=pn, pores=pn.Ps, throats=pn.Ts)
air = op.phases.Air(network=pn)
phys = op.physics.Basic(network=pn, phase=air, geometry=geo)
Explanation: Overview of the Settings Attribute
OpenPNM objects all include a settin... |
6,999 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
TRYING OUT DIFFERENT ITERATIONS TO FIND THE BEST ONE
Step1: FOUND THAT ACCURACY IS BETTER WITH ~26K ITERATIONS
Step2: PART B
Step3: WHEN WE ADD A HIDDEN LAYER WITH SAME NUMBER OF ITERATIO... | Python Code:
#find out for different iterations to find out the optimal iterations
iter1=10000
iter2=15000
iter3=26000
learningRate = tf.train.exponential_decay(learning_rate=0.0008,
global_step= 1,
decay_steps=trainX.shape[0],
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.