Unnamed: 0
int64
0
16k
text_prompt
stringlengths
110
62.1k
code_prompt
stringlengths
37
152k
11,100
Given the following text description, write Python code to implement the functionality described below step by step Description: Snapshotting with Devito using the ConditionalDimension This notebook intends to introduce new Devito users (especially with a C or FORTRAN background) to the best practice on saving snapsho...
Python Code: #NBVAL_IGNORE_OUTPUT %reset -f import numpy as np import matplotlib.pyplot as plt %matplotlib inline Explanation: Snapshotting with Devito using the ConditionalDimension This notebook intends to introduce new Devito users (especially with a C or FORTRAN background) to the best practice on saving snapshots...
11,101
Given the following text description, write Python code to implement the functionality described below step by step Description: Corrupt known signal with point spread The aim of this tutorial is to demonstrate how to put a known signal at a desired location(s) in a Step1: First, we set some parameters. Step2: Load...
Python Code: import os.path as op import numpy as np import mne from mne.datasets import sample from mne.minimum_norm import read_inverse_operator, apply_inverse from mne.simulation import simulate_stc, simulate_evoked Explanation: Corrupt known signal with point spread The aim of this tutorial is to demonstrate how to...
11,102
Given the following text description, write Python code to implement the functionality described below step by step Description: ensegment Step1: Documentation Write some beautiful documentation of your program here.
Python Code: from default import * Explanation: ensegment: default program End of explanation Pw = Pdist(data=datafile("data/count_1w.txt")) segmenter = Segment(Pw) with open("data/input/dev.txt") as f: for line in f: print(" ".join(segmenter.segment(line.strip()))) Explanation: Documentation Write some bea...
11,103
Given the following text description, write Python code to implement the functionality described below step by step Description: Feature Selection Step1: Data Split Idealy, we'd perform stratified 5x4 fold cross validation, however, given the timeframe, we'll stick with a single split. We'll use an old chunck of data...
Python Code: %matplotlib inline import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import bokeh from bokeh.io import output_notebook output_notebook() import os DATA_STREETLIGHT_CASES_URL = 'https://data.sfgov.org/api/views/c53t-rr3f/rows.json?accessType=DOWNLOAD' DATA_STREETLI...
11,104
Given the following text description, write Python code to implement the functionality described below step by step Description: <a href="https Step1: Defining network architecture (we use Arch-2) We also define some functions to make training convinent here. Step2: Mounting folder from Google Drive Step3: Verify t...
Python Code: # This program will not generate the jet images, it will only train the autoencoder # and evaluate the results. The jet images can be found in: # https://drive.google.com/drive/folders/1i5DY9duzDuumQz636u5YQeYQEt_7TYa8?usp=sharing # Please download those images to your google drive and use the colab - driv...
11,105
Given the following text description, write Python code to implement the functionality described below step by step Description: Plot single trial activity, grouped by ROI and sorted by RT This will produce what is sometimes called an event related potential / field (ERP/ERF) image. The EEGLAB example file, which cont...
Python Code: # Authors: Jona Sassenhagen <jona.sassenhagen@gmail.com> # # License: BSD (3-clause) import mne from mne.event import define_target_events from mne.channels import make_1020_channel_selections print(__doc__) Explanation: Plot single trial activity, grouped by ROI and sorted by RT This will produce what is ...
11,106
Given the following text description, write Python code to implement the functionality described below step by step Description: Examples Step1: Building on our discussion of modules from last week, we'll use the my_dataset module that I have prepared as a basis. This module is largely identical to what we have buil...
Python Code: %matplotlib inline Explanation: Examples: Week 7 This week, we will apply some of our discussions around filtering, splitting and so on to build out comparisons between different variables within the World Bank Economic Indicators dataset. This dataset, which covers 1960-2016, 264 countries and 1452 variab...
11,107
Given the following text description, write Python code to implement the functionality described below step by step Description: MMTL Basics Tutorial The purpose of this tutorial is to introduce the basic classes and flow of the MMTL package within Snorkel MeTaL (not necessarily to motivate or explain multi-task learn...
Python Code: # Confirm we can import from metal import sys sys.path.append('../../metal') import metal # Import other dependencies import torch import torch.nn as nn import torch.nn.functional as F # Set random seed for notebook SEED = 123 %load_ext autoreload %autoreload 2 %matplotlib inline Explanation: MMTL Basics T...
11,108
Given the following text description, write Python code to implement the functionality described below step by step Description: Errors and Exceptions While executing a python program we may encounter errors. There are 2 types of errors Step1: Exceptions Step2: Built-in Exceptions Python creates an Exception object ...
Python Code: print('Hello) Explanation: Errors and Exceptions While executing a python program we may encounter errors. There are 2 types of errors: Syntax Errors - When you don't follow the proper structure of the python program (Like missing a quote during initialising a string). Exceptions - Sometimes even when the ...
11,109
Given the following text description, write Python code to implement the functionality described below step by step Description: Log-Normal or Over-Dispersed Poisson? We replicate the empirical applications in Harnau (2018a) in Section 2 and Section 6. The work on this vignette was supported by the European Research C...
Python Code: import apc # Turn off FutureWarnings import warnings warnings.simplefilter('ignore', FutureWarning) Explanation: Log-Normal or Over-Dispersed Poisson? We replicate the empirical applications in Harnau (2018a) in Section 2 and Section 6. The work on this vignette was supported by the European Research Counc...
11,110
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright 2018 The TensorFlow Authors. Step1: Treine sua primeira rede neural Step2: Importe a base de dados Fashion MNIST Esse tutorial usa a base de dados Fashion MNIST que contém 70,000...
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...
11,111
Given the following text description, write Python code to implement the functionality described below step by step Description: Introduction In this analysis report I would like to find some patterns or characteristics that make some players the best.<br> After analysing the data I will use data analysis and statisti...
Python Code: # import libraries import os import sys import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from IPython.display import display %pylab inline from bokeh.io import output_notebook, show from bkcharts import Donut output_notebook() Explanation: Introduction In this an...
11,112
Given the following text description, write Python code to implement the functionality described below step by step Description: Step1: Project Euler Step2: Now write a set of assert tests for your number_to_words function that verifies that it is working as expected. Step4: Now define a count_letters(n) that return...
Python Code: def number_to_words(n): Given a number n between 1-1000 inclusive return a list of words for the number. x = [] a = {1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten', 11:'eleven',12:'twelve',13:'thirteen',14:'fourteen',15:'fifteen',16:'sixteen',...
11,113
Given the following text description, write Python code to implement the functionality described below step by step Description: automaton.shuffle(a1, ...) The (accessible part of the) shuffle product of automata. Preconditions Step1: Boolean Automata The shuffle product of automata computes the shuffling of their la...
Python Code: import vcsn Explanation: automaton.shuffle(a1, ...) The (accessible part of the) shuffle product of automata. Preconditions: - all the labelsets are letterized See also: - automaton.conjunction - automaton.infiltration - expression.shuffle Examples End of explanation std = lambda exp: vcsn.B.expression(exp...
11,114
Given the following text description, write Python code to implement the functionality described below step by step Description: Working with Streaming Data Learning Objectives 1. Learn how to process real-time data for ML models using Cloud Dataflow 2. Learn how to serve online predictions using real-time data Intr...
Python Code: import numpy as np import os import shutil import tensorflow as tf from google.cloud import aiplatform from google.cloud import bigquery from google.protobuf import json_format from google.protobuf.struct_pb2 import Value from matplotlib import pyplot as plt from tensorflow import keras from tensorflow.ker...
11,115
Given the following text description, write Python code to implement the functionality described below step by step Description: Part 2 - Core Query Builder Functions Step1: Query builders match_field Forge has many helper functions to make constructing queries easier. The simplest of the helpers is match_field(). To...
Python Code: from mdf_forge.forge import Forge mdf = Forge() Explanation: Part 2 - Core Query Builder Functions End of explanation mdf.match_field("material.elements", "Al") Explanation: Query builders match_field Forge has many helper functions to make constructing queries easier. The simplest of the helpers is match_...
11,116
Given the following text description, write Python code to implement the functionality described below step by step Description: Evaluation of classified contacts between rods and bipolar cells This notebook contains the code to reproduce all plots in figure 6 showing statistics about the rod-BC contacts Step1: Numbe...
Python Code: import numpy as np import scipy.linalg from scipy.stats import itemfreq import matplotlib import matplotlib.pyplot as plt from scipy.io import loadmat import pandas as pd import seaborn as sns from sklearn import cross_validation from sklearn import svm %matplotlib inline matplotlib.rc('font',**{'family':'...
11,117
Given the following text description, write Python code to implement the functionality described below step by step Description: FICHEROS En Python, para abrir un fichero usaremos la función open, que recibe el nombre del archivo a abrir. Por defecto, si no indicamos nada, el fichero se abre en modo lectura. OPEN Step...
Python Code: %pwd fichero = open("../datos/cuna.txt") Explanation: FICHEROS En Python, para abrir un fichero usaremos la función open, que recibe el nombre del archivo a abrir. Por defecto, si no indicamos nada, el fichero se abre en modo lectura. OPEN: MODO LECTURA End of explanation ls "../datos" fichero= open("../da...
11,118
Given the following text description, write Python code to implement the functionality described below step by step Description: Part3 Using the models.ldamodel module from the gensim library, run topic modeling over the corpus. Explore different numbers of topics (varying from 5 to 50), and settle for the parameter w...
Python Code: # imports import pandas as pd import numpy as np from nltk.corpus import stopwords from gensim import corpora, models, utils from nltk.stem import WordNetLemmatizer data = pd.read_csv('hillary-clinton-emails/Emails.csv', index_col=0).dropna() texts = pd.concat((data.ExtractedBodyText ,data.ExtractedSubject...
11,119
Given the following text description, write Python code to implement the functionality described below step by step Description: ES-DOC CMIP6 Model Properties - Land MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributors Step3: Document Publication Specify do...
Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-mm', 'land') Explanation: ES-DOC CMIP6 Model Properties - Land MIP Era: CMIP6 Institute: NCC Source ID: NORESM2-MM Topic: Land Sub-Topics: Soil, Snow, Vegetation, Energ...
11,120
Given the following text description, write Python code to implement the functionality described below step by step Description: Examples of plots and calculations using the tmm and colorpy package This example uses tmm and colorpy package to calculate the surface of stacked layers. Note that tmm and colorpy packages ...
Python Code: from __future__ import division, print_function, absolute_import %load_ext autoreload %autoreload 2 from pypvcell.tmm_core import (coh_tmm, unpolarized_RT, ellips, absorp_in_each_layer, position_resolved, find_in_structure_with_inf) from numpy import pi, linspace, inf, array import n...
11,121
Given the following text description, write Python code to implement the functionality described below step by step Description: 1. Party game Step1: 'numbers' is a list of lists. Using a list comprehension, flatten 'numbers' so it is a list of only numbers (not list of lists). use the newly flattened 'numbers' and f...
Python Code: numbers = [[1,2,3],[4,5,6],[7,8,9]] words = ['if','i','could','just','go','outside','and','have','an','ice','cream'] Explanation: 1. Party game: squeezed One guessing game, called “squeezed”, is very common in parties. It consists of a player, the chooser, who writes down a number between 00–99. The other ...
11,122
Given the following text description, write Python code to implement the functionality described below step by step Description: Mesh examples this notebook illustrates the basic ways of interacting with the pyro2 mesh module. We create some data that lives on a grid and show how to fill the ghost cells. The pretty_...
Python Code: from __future__ import print_function import numpy as np import mesh.boundary as bnd import mesh.patch as patch import matplotlib.pyplot as plt %matplotlib inline # for unit testing, we want to ensure the same random numbers np.random.seed(100) Explanation: Mesh examples this notebook illustrates the basic...
11,123
Given the following text description, write Python code to implement the functionality described below step by step Description: Reversible (Diffusion-limited) This is for an integrated test of E-Cell4. Here, we test a simple reversible association/dissociation model in volume. Step1: Parameters are given as follows....
Python Code: %matplotlib inline from ecell4.prelude import * Explanation: Reversible (Diffusion-limited) This is for an integrated test of E-Cell4. Here, we test a simple reversible association/dissociation model in volume. End of explanation D = 1 radius = 0.005 N_A = 60 U = 0.5 ka_factor = 10 # 10 is for diffusion-l...
11,124
Given the following text description, write Python code to implement the functionality described below step by step Description: Homework Part 2 Step1: Load 120 seconds of an audio file Step2: Plot the time-domain waveform of the audio signal Step3: Play the audio file Step4: Step 2 Step5: Scale the features to h...
Python Code: filename1 = 'brahms_hungarian_dance_5.mp3' url = "http://audio.musicinformationretrieval.com/" + filename1 if not os.path.exists(filename1): urllib.urlretrieve(url, filename=filename1) Explanation: Homework Part 2: Genre Classification Goals Extract features from an audio signal. Train a genre classifi...
11,125
Given the following text description, write Python code to implement the functionality described below step by step Description: Step1: PWC-Net-small model training (with multisteps learning rate schedule) In this notebook, we Step2: TODO Step3: Pre-train on FlyingChairs+FlyingThings3DHalfRes mix Load the dataset St...
Python Code: pwcnet_train.ipynb PWC-Net model training. Written by Phil Ferriere Licensed under the MIT License (see LICENSE for details) Tensorboard: [win] tensorboard --logdir=E:\\repos\\tf-optflow\\tfoptflow\\pwcnet-sm-6-2-multisteps-chairsthingsmix [ubu] tensorboard --logdir=/media/EDrive/repos/tf-optflow/t...
11,126
Given the following text description, write Python code to implement the functionality described below step by step Description: Fitting a diagonal covariance Gaussian mixture model to text data In a previous assignment, we explored k-means clustering for a high-dimensional Wikipedia dataset. We can also model this da...
Python Code: import graphlab Explanation: Fitting a diagonal covariance Gaussian mixture model to text data In a previous assignment, we explored k-means clustering for a high-dimensional Wikipedia dataset. We can also model this data with a mixture of Gaussians, though with increasing dimension we run into two importa...
11,127
Given the following text description, write Python code to implement the functionality described below step by step Description: Explicit feedback movie recommendations In this example, we'll build a quick explicit feedback recommender system Step1: The dataset object is an instance of an Interactions class, a fairly...
Python Code: import numpy as np from spotlight.datasets.movielens import get_movielens_dataset dataset = get_movielens_dataset(variant='100K') print(dataset) Explanation: Explicit feedback movie recommendations In this example, we'll build a quick explicit feedback recommender system: that is, a model that takes into a...
11,128
Given the following text description, write Python code to implement the functionality described below step by step Description: Anna KaRNNa In this notebook, we'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 re import numpy as np import tensorflow as tf Explanation: Anna KaRNNa In this notebook, we'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. Th...
11,129
Given the following text description, write Python code to implement the functionality described below step by step Description: Notebook 6 Step1: Download the sequence data Sequence data for this study are archived on the NCBI sequence read archive (SRA). Below I read in SraRunTable.txt for this project which contai...
Python Code: ### Notebook 6 ### Data set 6 (Finches) ### Authors: DaCosta & Sorenson (2016) ### Data Location: SRP059199 Explanation: Notebook 6: This is an IPython notebook. Most of the code is composed of bash scripts, indicated by %%bash at the top of the cell, otherwise it is IPython code. This notebook includes co...
11,130
Given the following text description, write Python code to implement the functionality described below step by step Description: ES-DOC CMIP6 Model Properties - Ocnbgchem 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', 'cmcc', 'cmcc-esm2-hr5', 'ocnbgchem') Explanation: ES-DOC CMIP6 Model Properties - Ocnbgchem MIP Era: CMIP6 Institute: CMCC Source ID: CMCC-ESM2-HR5 Topic: Ocnbgchem Sub-Topics: Tracer...
11,131
Given the following text description, write Python code to implement the functionality described below step by step Description: Aiida and the aiida-plugins 1. aiida-v0.12.1 installation (released in Jan 2018) aiida-v0.12.1 was released in Summer, 2018, hence I removed the previous v0.11.0 in my mac, and installed the...
Python Code: conda create -n aiida-debug python=2.7 #set a veritual environment conda activate aiida-debug #sometimes in mac, such a command might be requested # sudo ln -s /Users/ywfang/miniconda3/etc/profile.d/conda.sh /etc/profile.d/conda.sh conda install postgresql Explanation: Aiida and the aiida-plugins 1. aiida-...
11,132
Given the following text description, write Python code to implement the functionality described below step by step Description: Section 6.5.1 Hantush wells introduction type curves IHE, module transient groundwater Olsthoorn, 2019-01-03 Hantush (1956) considered the transient flow due to a well with a constant extrac...
Python Code: from scipy.special import exp1 from scipy.integrate import quad import numpy as np import matplotlib.pyplot as plt Explanation: Section 6.5.1 Hantush wells introduction type curves IHE, module transient groundwater Olsthoorn, 2019-01-03 Hantush (1956) considered the transient flow due to a well with a cons...
11,133
Given the following text description, write Python code to implement the functionality described below step by step Description: Topological Sorting The function topo_sort implements <em style="color Step1: Graphical Representation Step2: The function toDot(Edges, Order) takes two arguments Step3: Testing
Python Code: def topo_sort(T, D): Parents = { t: set() for t in T } # dictionary of parents Children = { t: set() for t in T } # dictionary of children for s, t in D: Children[s].add(t) Parents [t].add(s) Orphans = { t for (t, P) in Parents.items() if len(P) == 0 } Sorted = [] ...
11,134
Given the following text description, write Python code to implement the functionality described below step by step Description: 그래프를 그리기 위해서 matplotlib을 임포트 합니다. %matplotlib inline은 새로운 창을 띄우지 않고 주피터 노트북 안에 이미지를 삽입하여 줍니다. Step1: 텐서플로우를 tf 란 이름으로 임포트 하세요. tf.Session()을 사용하여 세션 객체를 하나 만드세요. sess = tf.Session() 임의의 샘플 ...
Python Code: import matplotlib.pyplot as plt %matplotlib inline Explanation: 그래프를 그리기 위해서 matplotlib을 임포트 합니다. %matplotlib inline은 새로운 창을 띄우지 않고 주피터 노트북 안에 이미지를 삽입하여 줍니다. End of explanation x_raw = ... x = ... Explanation: 텐서플로우를 tf 란 이름으로 임포트 하세요. tf.Session()을 사용하여 세션 객체를 하나 만드세요. sess = tf.Session() 임의의 샘플 데이터를 만들려고...
11,135
Given the following text description, write Python code to implement the functionality described below step by step Description: Visualize Source time courses This tutorial focuses on visualization of stcs. Surface Source Estimates First, we get the paths for the evoked data and the time courses (stcs). Step1: Then, ...
Python Code: import os import mne from mne.datasets import sample from mne.minimum_norm import apply_inverse, read_inverse_operator from mne import read_evokeds data_path = sample.data_path() sample_dir = os.path.join(data_path, 'MEG', 'sample') subjects_dir = os.path.join(data_path, 'subjects') fname_evoked = data_pat...
11,136
Given the following text description, write Python code to implement the functionality described below step by step Description: Fitting a Mixture Model with Gibbs Sampling Step1: Suppose we receive some data that looks like the following Step2: It appears that these data exist in three separate clusters. We want to...
Python Code: %matplotlib inline import pandas as pd import numpy as np import random import matplotlib.pyplot as plt from scipy import stats from collections import namedtuple, Counter Explanation: Fitting a Mixture Model with Gibbs Sampling End of explanation data = pd.Series.from_csv("clusters.csv") _=data.hist(bins=...
11,137
Given the following text description, write Python code to implement the functionality described below step by step Description: Epoching and averaging (ERP/ERF) Step1: In MNE, epochs refers to a collection of single trials or short segments of time locked raw data. If you haven't already, you might want to check out...
Python Code: import os.path as op import numpy as np import mne Explanation: Epoching and averaging (ERP/ERF) End of explanation data_path = mne.datasets.sample.data_path() fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_raw.fif') raw = mne.io.read_raw_fif(fname) raw.set_eeg_reference('average', projection=T...
11,138
Given the following text description, write Python code to implement the functionality described below step by step Description: The Inspection Paradox is Everywhere Allen Downey 2019 MIT License Step1: Class size Here's the data summarizing the distribution of undergraduate class sizes at Purdue University in 2013-1...
Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns from empiricaldist import Pmf from utils import decorate # set the random seed so we get the same results every time np.random.seed(17) # make the directory for the figures import os if not os.path.exists('inspecti...
11,139
Given the following text description, write Python code to implement the functionality described below step by step Description: <a href="http Step1: Molecules Let's start with something relaxing. Execute each cell by selecting it and pressing Shift + Return Step2: You've just created your first molecule in buckybal...
Python Code: # This cell sets up both the python and notebook environments %matplotlib inline import moldesign as mdt # import the buckyball package from moldesign import units as u # import the buckyball unit system Explanation: <a href="http://moldesign.bionano.autodesk.com" target="_blank"><img src="img/Top.png"...
11,140
Given the following text description, write Python code to implement the functionality described below step by step Description: 神经网络算法实现的核心之一是对代价函数的反向求导,Theano和Tensorflow中都定义了求导的符号函数,同样地,作为深度学习平台,自动求导(autograd)功能在pytorch中也扮演着核心功能,不同的是,pytorch的动态图功能使其更灵活(define by run), 比如甚至在每次迭代中都可以通过改变pytorch中Variable的属性,从而使其加入亦或退出反...
Python Code: x = Variable(T.ones(2,2), requires_grad=True) print x y = T.exp(x + 2) yy = T.exp(-x-2) print y z = (y + yy)/2 out = z.mean() print z, out make_dot(out) out.backward(T.FloatTensor(1), retain_graph=True) x.grad T.randn(1,1) from __future__ import print_function xx = Variable(torch.randn(1,1), requires_grad ...
11,141
Given the following text description, write Python code to implement the functionality described below step by step Description: 6차시 Step1: 2. 학습 데이터 불러오기 Step2: 3. 학습 데이터 살펴보기 Step3: 4. Convolution Neural Network Step4: 5. Transfer Learning Step5: 6. Transfer Learning Finetune
Python Code: # 도구 준비 import os import random import tensorflow as tf # 텐서플로우 import tensorflow_hub as hub import matplotlib.pyplot as plt # 시각화 도구 %matplotlib inline import numpy as np import PIL.Image as Image print(f'Tensorflow 버전을 확인합니다: {tf.__version__}') Explanation: 6차시: 텐서플로우 2.x 활용 전이 학습 이미지 분류 AI 맛보기 6주차: 2020...
11,142
Given the following text description, write Python code to implement the functionality described below step by step Description: OKCupid Clean Data OKCupid's website returns some partially hidden text when it is too long for their layout. Lets skip these and just focus on the fully named places. Step1: Feature Step2:...
Python Code: %matplotlib inline import time import pylab import numpy as np import pandas as pd import pycupid.locations people = pd.read_json('/Users/ajmendez/data/okcupid/random.json') print('Scraping archive found {:,d} random people'.format(len(people))) Explanation: OKCupid Clean Data OKCupid's website returns som...
11,143
Given the following text description, write Python code to implement the functionality described below step by step Description: OP2 Demo The iPython notebook for this demo can be found in Step1: Sets default precision of real numbers for pandas output Step2: As with the BDF, we can use the long form and the short f...
Python Code: import os import copy import numpy as np import pyNastran pkg_path = pyNastran.__path__[0] from pyNastran.utils import print_bad_path from pyNastran.op2.op2 import read_op2 from pyNastran.utils import object_methods, object_attributes import pandas as pd Explanation: OP2 Demo The iPython notebook for this ...
11,144
Given the following text description, write Python code to implement the functionality described below step by step Description: Ch 11 Step1: First, define the constants. Let's say we're dealing with 1-dimensional vectors, and a maximum sequence size of 3. Step2: Next up, define the placeholder(s). We only need on...
Python Code: import tensorflow as tf Explanation: Ch 11: Concept 01 Multi RNN All we need is TensorFlow: End of explanation input_dim = 1 seq_size = 3 Explanation: First, define the constants. Let's say we're dealing with 1-dimensional vectors, and a maximum sequence size of 3. End of explanation input_placeholder = t...
11,145
Given the following text description, write Python code to implement the functionality described below step by step Description: Introduction Step1: What is Data? A dataset consists of multiple data rows. Each row describes an item with its features. Think of features as properties of a sample. E.g. an apple has colo...
Python Code: # importing numpy, pandas & matplotlib import numpy as np import pandas as pd from matplotlib import pyplot as plt import random %matplotlib inline Explanation: Introduction End of explanation # Load Iris dataset from sklearn.datasets import load_iris iris = load_iris() iris.feature_names print(iris.DESCR)...
11,146
Given the following text description, write Python code to implement the functionality described below step by step Description: Neural net painter This notebook demonstrates a fun experiment in training a neural network to do regression from the color (r,g,b) of a pixel in an image, given its (x,y) position in the im...
Python Code: %matplotlib inline import time from PIL import Image import numpy as np import keras from matplotlib.pyplot import imshow, figure from keras.models import Sequential from keras.layers import Dense Explanation: Neural net painter This notebook demonstrates a fun experiment in training a neural network to do...
11,147
Given the following text description, write Python code to implement the functionality described below step by step Description: Author Step1: Preprocess Data For protyping I randomly sampled 10% the original dataset w/ this command Step2: Data preprocessing Step3: Categorical Features Since all the features are ca...
Python Code: import pandas as pd import numpy as np %pylab inline import matplotlib.pyplot as plt Explanation: Author: Alex Egg This is my submission for the Machine Learning Scientist role at Amazon Development Centre (Scotland). I spent about 2 hours on it. Intro My old professor at UCSD, Yoav Freund, is one of the o...
11,148
Given the following text description, write Python code to implement the functionality described below step by step Description: Interact Exercise 2 Imports Step1: Plotting with parameters Write a plot_sin1(a, b) function that plots $sin(ax+b)$ over the interval $[0,4\pi]$. Customize your visualization to make it eff...
Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np from IPython.html.widgets import interact, interactive, fixed from IPython.display import display Explanation: Interact Exercise 2 Imports End of explanation import math as math def plot_sine1(a, b): x = np.linspace(0,4*math.pi,...
11,149
Given the following text description, write Python code to implement the functionality described below step by step Description: Making a movie of reaction-diffusion concentrations We recommend creating and using a virtual environment for NetPyNE tutorials. To do so, enter the following commands into your terminal St...
Python Code: plotArgs = { 'speciesLabel': 'ca', 'regionLabel' : 'ecs', 'saveFig' : 'movie', 'showFig' : False, 'clim' : [1.9997, 2.000], } Explanation: Making a movie of reaction-diffusion concentrations We recommend creating and using a virtual environment for NetPyNE tutorials. To...
11,150
Given the following text description, write Python code to implement the functionality described below step by step Description: Learning from Data Decision Trees are a non-parametric supervised learning method used for classification and regression. The goal is to create a model that predicts the value of a target va...
Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt %matplotlib inline plt.style.use('fivethirtyeight') df = pd.read_csv("data/creditRisk.csv") df.head() df.dtypes Explanation: Learning from Data Decision Trees are a non-parametric supervised learning method used for classification and r...
11,151
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright 2018 The TensorFlow Authors. Step1: 使用 SavedModel 格式 <table class="tfo-notebook-buttons" align="left"> <td data-segment-approved="false"><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...
11,152
Given the following text description, write Python code to implement the functionality described below step by step Description: Regression Week 1 Step1: Load house sales data Dataset is from house sales in King County, the region where the city of Seattle, WA is located. Step2: Split data into training and testing ...
Python Code: import sys sys.path.append('C:\Anaconda2\envs\dato-env\Lib\site-packages') import graphlab Explanation: Regression Week 1: Simple Linear Regression In this notebook we will use data on house sales in King County to predict house prices using simple (one input) linear regression. You will: * Use graphlab SA...
11,153
Given the following text description, write Python code to implement the functionality described below step by step Description: Segmentation Evaluation <a href="https Step2: Utility method for display Step3: Fetch the data Retrieve a single CT scan and three manual delineations of a liver tumor. Visual inspection o...
Python Code: import SimpleITK as sitk import numpy as np %run update_path_to_download_script from downloaddata import fetch_data as fdata %matplotlib inline import matplotlib.pyplot as plt import gui from ipywidgets import interact, fixed Explanation: Segmentation Evaluation <a href="https://mybinder.org/v2/gh/InsightS...
11,154
Given the following text description, write Python code to implement the functionality described below step by step Description: Objective In this notebook I am testing a reduced workflow that will Step1: Import test image. The colormap is Matlab's Jet Step2: Reduce number of colours I use here Scikit-learn segmenta...
Python Code: import numpy as np import matplotlib.pyplot as plt from skimage import data, io, segmentation, color from skimage.future import graph %matplotlib inline import requests from PIL import Image from io import StringIO Explanation: Objective In this notebook I am testing a reduced workflow that will: 1) input ...
11,155
Given the following text description, write Python code to implement the functionality described below step by step Description: W3C prov based provenance storage in Neo4j This notebook tries to provides a nearly complete mapping between a W3C prov standard based provenance descriptions and a Neo4j graph representatio...
Python Code: from IPython.display import display, Image Image(filename='key-concepts.png') Explanation: W3C prov based provenance storage in Neo4j This notebook tries to provides a nearly complete mapping between a W3C prov standard based provenance descriptions and a Neo4j graph representation. The approach taken is a...
11,156
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright 2021 The TensorFlow Authors. Step1: Object Detection with TensorFlow Lite Model Maker <table class="tfo-notebook-buttons" align="left"> <td> <a target="_blank" href="https S...
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...
11,157
Given the following text description, write Python code to implement the functionality described below step by step Description: Advanced Step1: As always, let's do imports and initialize a logger and a new Bundle. Step2: Changing Hierarchies Some of the built-in constraints depend on the system hierarchy, and will ...
Python Code: #!pip install -I "phoebe>=2.4,<2.5" Explanation: Advanced: Constraints and Changing Hierarchies Setup Let's first make sure we have the latest version of PHOEBE 2.4 installed (uncomment this line if running in an online notebook session such as colab). End of explanation import phoebe from phoebe import u ...
11,158
Given the following text description, write Python code to implement the functionality described below step by step Description: Time series prediction using RNNs + Estimators This notebook illustrates how to Step1: Describing the data set and the model We're using a weather dataset....[DESCRIBE DATA SET, HOW THE DAT...
Python Code: #!/usr/bin/env python # Copyright 2017 Google Inc. 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 # # Un...
11,159
Given the following text description, write Python code to implement the functionality described below step by step Description: Theano A language in a language Dealing with weights matrices and gradients can be tricky and sometimes not trivial. Theano is a great framework for handling vectors, matrices and high dimen...
Python Code: import theano import theano.tensor as T Explanation: Theano A language in a language Dealing with weights matrices and gradients can be tricky and sometimes not trivial. Theano is a great framework for handling vectors, matrices and high dimensional tensor algebra. Most of this tutorial will refer to Thea...
11,160
Given the following text description, write Python code to implement the functionality described below step by step Description: Content Glossary 1. Somename Next Step1: Import section specific modules
Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline from IPython.display import HTML HTML('../style/course.css') #apply general CSS Explanation: Content Glossary 1. Somename Next: 1.2 Somename 3 Import standard modules: End of explanation pass Explanation: Import section specific modul...
11,161
Given the following text description, write Python code to implement the functionality described below step by step Description: VectorView and OPM resting state datasets Here we compute the resting state from raw for data recorded using a Neuromag VectorView system and a custom OPM system. The pipeline is meant to mo...
Python Code: # sphinx_gallery_thumbnail_number = 14 # Authors: Denis Engemann <denis.engemann@gmail.com> # Luke Bloy <luke.bloy@gmail.com> # Eric Larson <larson.eric.d@gmail.com> # # License: BSD (3-clause) import os.path as op from mne.filter import next_fast_len from mayavi import mlab import mne pr...
11,162
Given the following text description, write Python code to implement the functionality described below step by step Description: Introduction This notebook demostrates the core functionality of pymatgen, including the core objects representing Elements, Species, Lattices, and Structures. By convention, we import pyma...
Python Code: import pymatgen as mg Explanation: Introduction This notebook demostrates the core functionality of pymatgen, including the core objects representing Elements, Species, Lattices, and Structures. By convention, we import pymatgen as mg. End of explanation si = mg.Element("Si") print("Atomic mass of Si is {...
11,163
Given the following text description, write Python code to implement the functionality described below step by step Description: Asymmetric Encryption Use hard math problems called “Trapdoor Functions” Example Step1: Risk Attacker can use known plaintext and A's public Ke to test a generated private key. Computation ...
Python Code: #Lets test this idea... import cProfile, pstats, StringIO Prime1=307 #Try some others 7907 15485857 7919 15485863 Prime2=293 #or get some big primes from here:https://primes.utm.edu/ def factors(n): return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n...
11,164
Given the following text description, write Python code to implement the functionality described below step by step Description: Installation Follow directions at the PySAL-ArcGIS-Toolbox Git Repository [https Step1: Example Step2: Use the PySAL-ArcGIS Utilities to Read in Spatial Weights Files Step3: Run the Auto ...
Python Code: import arcpy as ARCPY import arcgisscripting as ARC import SSDataObject as SSDO import SSUtilities as UTILS import WeightsUtilities as WU import numpy as NUM import scipy as SCIPY import pysal as PYSAL import os as OS import pandas as PANDAS Explanation: Installation Follow directions at the PySAL-ArcGIS-T...
11,165
Given the following text description, write Python code to implement the functionality described below step by step Description: Analyze Issue Label Bot This notebook is used to compute metrics to evaluate performance of the issue label bot. Step2: Setup Authorization If you are using a service account run %%bash Act...
Python Code: import altair as alt import collections import importlib import logging import sys import os import datetime from dateutil import parser as dateutil_parser import glob import json import numpy as np import pandas as pd from pandas.io import gbq # A bit of a hack to set the path correctly sys.path = [os.pat...
11,166
Given the following text description, write Python code to implement the functionality described below step by step Description: Ch 08 Step1: Define an abstract class called DecisionPolicy Step2: Here's one way we could implement the decision policy, called a random decision policy Step3: That's a good baseline. No...
Python Code: %matplotlib inline from yahoo_finance import Share from matplotlib import pyplot as plt import numpy as np import random import tensorflow as tf import random Explanation: Ch 08: Concept 01 Reinforcement learning The states are previous history of stock prices, current budget, and current number of shares ...
11,167
Given the following text description, write Python code to implement the functionality described below step by step Description: Step1: Genetic Algorithm Workshop In this workshop we will code up a genetic algorithm for a simple mathematical optimization problem. Genetic Algorithm is a * Meta-heuristic * Inspired by N...
Python Code: %matplotlib inline # All the imports from __future__ import print_function, division from math import * import random import sys import matplotlib.pyplot as plt # TODO 1: Enter your unity ID here __author__ = "sbiswas4" class O: Basic Class which - Helps dynamic updates - Pretty P...
11,168
Given the following text description, write Python code to implement the functionality described below step by step Description: PmodTMP2 Sensor example In this example, the Pmod temperature sensor is initialized and set to log a reading every 1 second. This examples required the PmodTMP2 sensor, and assumed it is at...
Python Code: from pynq import Overlay Overlay("base.bit").download() from pynq.iop import Pmod_TMP2 from pynq.iop import PMODB mytmp = Pmod_TMP2(PMODB) temperature = mytmp.read() print(str(temperature) + " C") Explanation: PmodTMP2 Sensor example In this example, the Pmod temperature sensor is initialized and set to lo...
11,169
Given the following text description, write Python code to implement the functionality described below step by step Description: Logarithmic Parameters This notebook explores Bayesian optimisation of a function who's parameter is best thought of logarithmically (the order of magnitude is more important than the value ...
Python Code: %load_ext autoreload %autoreload 2 from IPython.core.debugger import Tracer # debugging from IPython.display import clear_output, display import time %matplotlib inline #%config InlineBackend.figure_format = 'svg' import matplotlib.pyplot as plt import seaborn as sns; sns.set() # prettify matplotlib import...
11,170
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright 2020 The TensorFlow Authors. Step1: Fairness Indicators Lineage Case Study <table class="tfo-notebook-buttons" align="left"> <td> <a target="_blank" href="https Step2: Down...
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...
11,171
Given the following text description, write Python code to implement the functionality described below step by step Description: On this notebook the best models and input parameters will be searched for. The problem at hand is predicting the price of any stock symbol 7 days ahead, assuming one model for all the symbo...
Python Code: # Basic imports import os import pandas as pd import matplotlib.pyplot as plt import numpy as np import datetime as dt import scipy.optimize as spo import sys from time import time from sklearn.metrics import r2_score, median_absolute_error %matplotlib inline %pylab inline pylab.rcParams['figure.figsize'] ...
11,172
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright 2021 The TensorFlow Authors. Step1: Data validation using TFX Pipeline and TensorFlow Data Validation Note Step2: Install TFX Step3: Did you restart the runtime? If you are usin...
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...
11,173
Given the following text description, write Python code to implement the functionality described below step by step Description: Numpy Exercise 4 Imports Step1: Complete graph Laplacian In discrete mathematics a Graph is a set of vertices or nodes that are connected to each other by edges or lines. If those edges don...
Python Code: import numpy as np %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns Explanation: Numpy Exercise 4 Imports End of explanation import networkx as nx K_5=nx.complete_graph(5) nx.draw(K_5) Explanation: Complete graph Laplacian In discrete mathematics a Graph is a set of vertices or node...
11,174
Given the following text description, write Python code to implement the functionality described below step by step Description: Keywords Stuff Step1: Documetns with similar sets of keywords should have similar content a document can be represented by a vector indicating whether a keyword is present or absent for the...
Python Code: from collections import defaultdict keycounts = defaultdict(int) def updateKeycounts(kws): for kw in kws: keycounts[kw] += 1 _ = keywords.apply(lambda x: updateKeycounts(x.keywords), axis=1) keycounts = pandas.DataFrame({"word" : [w for w in keycounts.keys()], "cou...
11,175
Given the following text description, write Python code to implement the functionality described below step by step Description: for d in ds[1 Step1: with open("models/bar_models", "rb") as f
Python Code: # !say "Finished" eval_complex_model(a) save_model(a, "attempt_two/zero_models") Explanation: for d in ds[1:]: trainerer(a,d[:10], 1000,l_r = 0.006, batches= 5 ) trainerer(a,ds_three[:200], 1000,l_r = 0.002, batches= 1 ) End of explanation trainerer(a,ds_twos[:100], 10,l_r = 0.002, batches = 5) vs = Co...
11,176
Given the following text description, write Python code to implement the functionality described below step by step Description: A Simple Autoencoder We'll start off by building a simple autoencoder to compress the MNIST dataset. With autoencoders, we pass input data through an encoder that makes a compressed represen...
Python Code: %matplotlib inline import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', validation_size=0) Explanation: A Simple Autoencoder We'll start off by building a simple autoencoder to c...
11,177
Given the following text description, write Python code to implement the functionality described below step by step Description: Clustering with KMeans in Shogun Machine Learning Toolbox Notebook by Parijat Mazumdar (GitHub ID Step1: The toy data created above consists of 4 gaussian blobs, having 200 points each, cen...
Python Code: from numpy import concatenate, array from numpy.random import randn import os SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data') num = 200 d1 = concatenate((randn(1,num),10.*randn(1,num)),0) d2 = concatenate((randn(1,num),10.*randn(1,num)),0)+array([[10.],[0.]]) d3 = concatenate((randn(1,num),10...
11,178
Given the following text description, write Python code to implement the functionality described below step by step Description: In this little experiment, I printed the likelihoods after each iteration. The test case was failing with 10% probability and the history had 10 locations. And I requested a certainty for te...
Python Code: with open('example_run.csv') as f: s = f.read() N = 10 runs = [[1/N for _ in range(N)]] for line in s.split('\n'): line = line.strip('[]') if len(line) > 0: li = [float(i) for i in line.split(',')] runs.append(li) Explanation: In this little experiment, I printed the likelihoods aft...
11,179
Given the following text description, write Python code to implement the functionality described below step by step Description: Aufgabe 2 Step1: First we create a training set of size num_samples and num_features. Step2: Next we run a performance test on the created data set. Therefor we train a random forest class...
Python Code: # imports from sklearn.datasets import make_classification from sklearn.ensemble import RandomForestClassifier import time import matplotlib.pyplot as plt import seaborn as sns Explanation: Aufgabe 2: Classification A short test to examine the performance gain when using multiple cores on sklearn's esemble...
11,180
Given the following text description, write Python code to implement the functionality described below step by step Description: Examples reproduced from http Step1: Example 2 Step2: Example 3 Exception The function2 plot_with_table1() and plot_with_table2() are exceptions with respect to the idea of this module Ste...
Python Code: df = hc.sample.df_timeseries(N=2, Nb_bd=15+0*3700) #<=473 df.info() display(df.head()) display(df.tail()) g = hc.Highstock() g.chart.width = 650 g.chart.height = 550 g.legend.enabled = True g.legend.layout = 'horizontal' g.legend.align = 'center' g.legend.maxHeight = 100 g.tooltip.enabled = True g.tooltip....
11,181
Given the following text description, write Python code to implement the functionality described below step by step Description: <p> <img src="http Step1: Step2: Step3:
Python Code: from itertools import repeat from sympy import * #from type_system import * %run ../../src/commons.py %run ./type-system.py Explanation: <p> <img src="http://www.cerm.unifi.it/chianti/images/logo%20unifi_positivo.jpg" alt="UniFI logo" style="float: left; width: 20%; height: 20%;"> <div align="righ...
11,182
Given the following text description, write Python code to implement the functionality described below step by step Description: Tutorial Step1: basics Step2: A print and a plot function are implemented to represent kernel objects. Step3: Implemented kernels Many kernels are already implemented in GPy. The follow...
Python Code: import GPy import numpy as np Explanation: Tutorial : A kernel overview Nicolas Durrande and James Hensman, 2013, 2014 The aim of this tutorial is to give a better understanding of the kernel objects in GPy and to list the ones that are already implemented. First we import the libraries we will need End of...
11,183
Given the following text description, write Python code to implement the functionality described below step by step Description: It Starts with a Dataset Step1: Transforming Text to Numbers Example Predictions Step2: Creating the Input Data Step3: And now we can initialize our (empty) input layer as vector of 0s. W...
Python Code: def pretty_print_review_and_label(i): print(labels[i] + "\t:\t" + reviews[i][:80] + "...") g = open('reviews.txt','r') reviews = list(map(lambda x:x[:-1],g.readlines())) g.close() g = open('labels.txt','r') labels = list(map(lambda x:x[:-1].upper(),g.readlines())) g.close() reviews[0] labels[0] print("...
11,184
Given the following text description, write Python code to implement the functionality described below step by step Description: Create a training set, a test set and a set to predict for Step1: Inspect the features, I know these features (at leasr spectral indices) are correlated but also have high variance, I could...
Python Code: features=wisps.INDEX_NAMES Explanation: Create a training set, a test set and a set to predict for End of explanation #remove infinities and nans def remove_infinities_and_nans(array): array=np.log10(array) infinbools=np.isinf(array) nanbools=np.isnan(array) mask=np.logical_or(infinbools, n...
11,185
Given the following text description, write Python code to implement the functionality described below step by step Description: Clipper Tutorial Step1: Extract the images Now, we must extract the data into a format we can load. This will make use of the provided extract_cifar.py This dataset has 50,000 training data...
Python Code: cifar_loc = "" %run ./download_cifar.py $cifar_loc Explanation: Clipper Tutorial: Part 1 This tutorial will walk you through the process of starting Clipper, creating and querying a Clipper application, and deploying models to Clipper. In the first part of the demo, you will set up Clipper and create an ap...
11,186
Given the following text description, write Python code to implement the functionality described. Description: Replace each element of Array with it 's corresponding rank Function to assign rank to array elements ; Copy input array into newArray ; Sort newArray [ ] in ascending order ; Dictionary to store the rank of t...
Python Code: def changeArr(input1 ) : newArray = input1 . copy() newArray . sort() ranks = { } rank = 1 for index in range(len(newArray ) ) : element = newArray[index ] ; if element not in ranks : ranks[element ] = rank rank += 1   for index in range(len(input1 ) ) : element = input1[index ]...
11,187
Given the following text description, write Python code to implement the functionality described below step by step Description: Rewriting rules in ReGraph In the context of ReGraph, by rewriting rules we mean the rules of sesqui-pushout rewriting (see more details here). A rewriting rule consists of the three graphs ...
Python Code: from regraph import NXGraph, Rule, plot_rule Explanation: Rewriting rules in ReGraph In the context of ReGraph, by rewriting rules we mean the rules of sesqui-pushout rewriting (see more details here). A rewriting rule consists of the three graphs: $p$ – preserved part, $lhs$ – left hand side, $rhs$ – righ...
11,188
Given the following text description, write Python code to implement the functionality described below step by step Description: 验证码识别 简单版本 Step1: 生成验证码 Step2: 模型 Step3: 模型一共有36.5万参数。
Python Code: import time import os from multiprocessing import Pool from captcha.image import ImageCaptcha import numpy as np import skimage.io as io import tensorflow as tf import matplotlib.pylab as plt %matplotlib inline Explanation: 验证码识别 简单版本 End of explanation IMG_H = 64 IMG_W = 160 IMG_CHANNALS = 1 CAPTCHA_SIZE ...
11,189
Given the following text description, write Python code to implement the functionality described below step by step Description: Paragraph to mem prototype Import modules Step1: Define some constant variables Chagne path to your books! all_books Step2: Harry paragraphs We define the harryness of a paragraph as the ...
Python Code: #import sys #sys.path.append('/Users/michaellomnitz/Documents/CDIPS-AI/pensieve/pensieve') import pensieve as pens import textacy from collections import defaultdict from random import random import numpy as np import matplotlib.pyplot as plt Explanation: Paragraph to mem prototype Import modules End of ex...
11,190
Given the following text description, write Python code to implement the functionality described below step by step Description: Host-guest complex setup and simulation using SMIRNOFF This notebook takes a SMILES string for a guest and a 3D structure for a host, and generates an initial structure of the complex using ...
Python Code: # NBVAL_SKIP from openeye import oechem # OpenEye Python toolkits import oenotebook as oenb # Check license print("Is your OEChem licensed? ", oechem.OEChemIsLicensed()) from openeye import oeomega # Omega toolkit from openeye import oequacpac #Charge toolkit from openeye import oedocking # Docking toolkit...
11,191
Given the following text description, write Python code to implement the functionality described below step by step Description: Step1: Wet Bulb Calculation Analysis Common/Helper Methods Step2: Ranges and Sensor Accuracy Analysis Assumptions Step3: Sensor Errors Step4: Tim Brice and Todd Hall Wet Bulb calculation ...
Python Code: %matplotlib inline import math from numpy import * import matplotlib.pyplot as plt from matplotlib import cm from pylab import * from operator import itemgetter import hygrometry def frange(x, y, jump): Like range(), but works with floats. x=float(x) y=float(y) jump = float(jump) while ...
11,192
Given the following text description, write Python code to implement the functionality described below step by step Description: Proof of work for framework migrations Jupyter Notebook Demo with Python, pandas and matplotlib. Context This analysis shows the progress of the rewrite work from Technical Requirement AB311...
Python Code: import pandas as pd log = pd.read_csv("../dataset/git_log_refactoring_simple.csv", parse_dates=[3]) log.head() Explanation: Proof of work for framework migrations Jupyter Notebook Demo with Python, pandas and matplotlib. Context This analysis shows the progress of the rewrite work from Technical Requiremen...
11,193
Given the following text description, write Python code to implement the functionality described below step by step Description: Planar Point Patterns in PySAL Author Step1: Creating Point Patterns From lists We can build a point pattern by using Python lists of coordinate pairs $(s_0, s_1,\ldots, s_m)$ as follows St...
Python Code: import pysal.lib as ps import numpy as np from pysal.explore.pointpats import PointPattern Explanation: Planar Point Patterns in PySAL Author: Serge Rey &#115;&#106;&#115;&#114;&#101;&#121;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109; and Wei Kang &#119;&#101;&#105;&#107;&#97;&#110;&#103;&#57;&#...
11,194
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright 2020 The TensorFlow Authors. Step1: Better ML Engineering with ML Metadata <table class="tfo-notebook-buttons" align="left"> <td> <a target="_blank" href="https Step2: Inst...
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...
11,195
Given the following text description, write Python code to implement the functionality described below step by step Description: Working with data files Reading and writing data files is a common task, and Python offers native support for working with many kinds of data files. Today, we're going to be working mainly w...
Python Code: import csv Explanation: Working with data files Reading and writing data files is a common task, and Python offers native support for working with many kinds of data files. Today, we're going to be working mainly with CSVs. Import the csv module We're going to be working with delimited text files, so the f...
11,196
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: Blur Image Step3: View Image
Python Code: # Load image import cv2 import numpy as np from matplotlib import pyplot as plt Explanation: Title: Blurring Images Slug: blurring_images Summary: How to blurring images using OpenCV in Python. Date: 2017-09-11 12:00 Category: Machine Learning Tags: Preprocessing Images Authors: Chris Albon Preliminar...
11,197
Given the following text description, write Python code to implement the functionality described below step by step Description: Vertex SDK Step1: Install the latest GA version of google-cloud-storage library as well. Step2: Note Step3: Restart the kernel Once you've installed the additional packages, you need to r...
Python Code: import os # Google Cloud Notebook if os.path.exists("/opt/deeplearning/metadata/env_version"): USER_FLAG = "--user" else: USER_FLAG = "" ! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG Explanation: Vertex SDK: Custom Training Tabular Regression Models for Online Prediction and Explainab...
11,198
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright 2019 The TensorFlow Authors. Step1: Post-training weight quantization <table class="tfo-notebook-buttons" align="left"> <td> <a target="_blank" href="https Step2: Train a T...
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...
11,199
Given the following text description, write Python code to implement the functionality described below step by step Description: Ordinary Differential Equations Exercise 3 Imports Step1: Damped, driven nonlinear pendulum The equations of motion for a simple pendulum of mass $m$, length $l$ are Step4: Write a functio...
Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import seaborn as sns from scipy.integrate import odeint from IPython.html.widgets import interact, fixed Explanation: Ordinary Differential Equations Exercise 3 Imports End of explanation g = 9.81 # m/s^2 l = 0.5 # length of pendul...