text_prompt
stringlengths
168
30.3k
code_prompt
stringlengths
67
124k
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Parallel Programming in Python Step2: We then initialize our thread with the Thread class from the threading module. Step3: When we run a prog...
<ASSISTANT_TASK:> Python Code: # code for loading the format for the notebook import os # path : store the current path to convert back to it later path = os.getcwd() os.chdir(os.path.join('..', 'notebook_format')) from formats import load_style load_style(plot_style=False) os.chdir(path) # 1. magic to print version # ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'csir-csiro', 'vresm-1-0', 'ocnbgchem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("na...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Classic Step2: We don't actually have to use the full namespace call that is nx.generators.classic.complete_graph, everythin is under the nx mo...
<ASSISTANT_TASK:> Python Code: import networkx as nx C = nx.generators.classic.complete_graph(5) C.edges() C = nx.complete_graph(5) KC = nx.karate_club_graph() KC.nodes(data=True) DSW = nx.davis_southern_women_graph() DSW.nodes() ER = nx.gnp_random_graph(100,1.0/100) ER.size() ER2 =nx.gnm_random_graph(100,50) ER2...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Зависимость времени и числа итераций от точности Step2: Пример 2 Step3: Зависимость времени и числа итераций от точности
<ASSISTANT_TASK:> Python Code: import liboptpy.constr_solvers as cs import liboptpy.step_size as ss import numpy as np from tqdm import tqdm n = 200 m = 100 A = np.random.randn(m, n) x_true = np.random.rand(n) b = A.dot(x_true) + 0.01 * np.random.randn(m) eigvals = np.linalg.eigvalsh(A.T @ A) L = np.max(eigvals) import...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Build your model Step2: Download the Data Step3: Loading the Data Step4: Now, let's take a look at the data to have a better understanding of...
<ASSISTANT_TASK:> Python Code: %pip install xgboost import datetime import os import pandas as pd import xgboost as xgb import numpy as np from sklearn.base import BaseEstimator, TransformerMixin from sklearn.preprocessing import StandardScaler from sklearn.pipeline import FeatureUnion, make_pipeline import warnings w...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: To specify the experiments, define Step2: Other parameters of the experiment Step3: Load all data Step4: Initialise the experiment Step5: Se...
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np from __future__ import division from __future__ import print_function import math import gym import pandas as pd from gym import spaces from sklearn import neural_network, model_selection from sklearn.neural_network import MLPClassifier f...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.DataFrame({'username': ['john', 'john', 'john', 'john', 'jane', 'jane', 'jane', 'jane'], 'post_id': [1, 2, 3, 4, 7, 8, 9, 10], 'views': [3, 23, 44, 82, 5, 25,46, 56]}) bins = [1, 10, 25, 50, 100] def g(df, bins): groups...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: First, we'll download the dataset to our local machine. The data consists of characters rendered in a variety of fonts on a 28x28 image. The lab...
<ASSISTANT_TASK:> Python Code: # These are all the modules we'll be using later. Make sure you can import them # before proceeding further. from __future__ import print_function import matplotlib.pyplot as plt import numpy as np import os import sys import tarfile from IPython.display import display, Image from scipy i...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import libraries Step7: User-defined functions Step8: Load dataset Step9: Pre-processing data Step10: Fix missing value Step11: Standardize...
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sb %matplotlib inline def remove_na_rows(df, cols=None): remove row with NaN in any column if cols is None: ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Super resolution with TensorFlow Lite Step2: Import dependencies. Step3: Download and convert the ESRGAN model Step4: Download a test image (...
<ASSISTANT_TASK:> 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 writin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: This failed when we provided input that could not be converted to an integer. Step2: You can handle errors in anyway that might be appropriate ...
<ASSISTANT_TASK:> Python Code: n = int(input("Enter an integer: ")) print("Hello " * n) try: n = int(input("Enter an integer: ")) print("Hello " * n) except ValueError: print("That wasn't an integer!") while True: try: n = int(input("Enter an integer: ")) print("Hello " * n) br...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: This notebook presents <em style="color Step2: The function make_string is a helper function that is used to simplify the implementation of __s...
<ASSISTANT_TASK:> Python Code: import graphviz as gv class BinaryTrie: sNodeCount = 0 def __init__(self): BinaryTrie.sNodeCount += 1 self.mID = BinaryTrie.sNodeCount def getID(self): return self.mID # used only by graphviz def _make_string(self, attributes): ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load the text8 dataset, a file of cleaned up Wikipedia articles from Matt Mahoney. The next cell will download the data set to the data folder. ...
<ASSISTANT_TASK:> Python Code: import time import numpy as np import tensorflow as tf import utils from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import zipfile dataset_folder_path = 'data' dataset_filename = 'text8.zip' dataset_name = 'Text8 Dataset' class DLProgress(tq...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Functions in the module accept the following arguments. Step2: The first value (left) is the probability that the first classifier (the left co...
<ASSISTANT_TASK:> Python Code: import numpy as np scores = np.loadtxt('Data/accuracy_nbc_aode.csv', delimiter=',', skiprows=1, usecols=(1, 2)) names = ("NBC", "AODE") import bayesiantests as bt left, within, right = bt.signtest(scores, rope=0.01) print(left, within, right) left, within, right = bt.signtest(scores, ro...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: First we need to import the matplotlib library. Step2: Matplotlib can output graphs using various backend graphics libraries, such as Tk, wxPyt...
<ASSISTANT_TASK:> Python Code: from __future__ import division, print_function, unicode_literals import matplotlib %matplotlib inline # matplotlib.use("TKAgg") # use this instead in your program if you want to use Tk as your graphics backend. import matplotlib.pyplot as plt plt.plot([1, 2, 4, 9, 5, 3]) plt.show() ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1. Illustrate playing a pre-defined melody Step2: 2. Play a piece of music Step3: 3. Generate a tone of desired period and for a desired numbe...
<ASSISTANT_TASK:> Python Code: from pynq import Overlay Overlay("base.bit").download() from pynq.iop import Grove_Buzzer from pynq.iop import PMODB from pynq.iop import PMOD_GROVE_G1 grove_buzzer = Grove_Buzzer(PMODB, PMOD_GROVE_G1) grove_buzzer.play_melody() # Play a tone tone_period = 1200 num_cycles = 500 grove_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Portable Greymap ( .pgm) Format Step2: Task breakdown Step3: The following cell has left out some code where indicated - Fill them in! Step4: ...
<ASSISTANT_TASK:> Python Code: import os import matplotlib.pyplot as plt import matplotlib.cm as cm import numpy as np import sys %matplotlib inline Nx = 72 Ny = 72 img_x = np.linspace(1, 0, Nx) img_y = np.linspace(1, 0, Ny) X, Y = np.meshgrid(img_x, img_y) # Generate the gradient image - this could be stored in .pgm ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Initialize the components with cfg files that, for simplicity, use the same time step and run duration Step2: Store initial values of time, sno...
<ASSISTANT_TASK:> Python Code: from cmt.components import Meteorology, SnowDegreeDay met, sno = Meteorology(), SnowDegreeDay() met.initialize('./input/meteorology-2.cfg') sno.initialize('./input/snow_degree_day-2.cfg') time = [met.get_current_time()] snow_depth = [sno.get_value('snowpack__depth').max()] air_temp = [m...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Contour plots of 2d wavefunctions Step3: The contour, contourf, pcolor and pcolormesh functions of Matplotlib can be used for effective visuali...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np def well2d(x, y, nx, ny, L=1.0): Compute the 2d quantum well wave function. # YOUR CODE HERE s=2/L*np.sin((nx*np.pi*x)/L)*np.sin ((ny*np.pi*y)/L) return s psi = well2d(np.linspace(0,1,10), np.linspace(0...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Data Mining Step2: Building Features Step3: Adding New Columns for Features in Matches DataFrame Step4: Visualizations for Features vs. Respo...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np # imports a fast numerical programming library import matplotlib.pyplot as plt #sets up plotting under plt import pandas as pd #lets us handle data as dataframes #sets up pandas table display pd.set_option('display.width', 500) pd.set_option('display...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Avant-propos Step2: Il y a un rapport de 10 dans le temps d'exécution entre la méthode "user defined" et la méthode "builtin". Step3: Le code...
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() import pyensae.datasource pyensae.datasource.download_data("twitter_for_network_100000.db.zip") import numpy as np def my_sum(l): res = 0 for it in l: res += it return res l = list(range(100000)) a = np.a...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: I am repeating myself here! Wouldn't it be better if we can write something once and use it multiple times? Step2: Now I can write some code wh...
<ASSISTANT_TASK:> Python Code: a = 4 b = 8 c = 9 if a%2 == 0: print('Multiple of 2') else: print('Not a multiple of 2') if b%2 == 0: print('Multiple of 2') else: print('Not a multiple of 2') if c%2 == 0: print('Multiple of 2') else: print('Not a multiple of 2') # The def keyword is used to...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Data Analysis Step2: We assign a shape of [None, 784], where 784 is the dimensionality of a single flattened 28 by 28 pixel MNIST image, and No...
<ASSISTANT_TASK:> Python Code: from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', one_hot=True) import tensorflow as tf x = tf.placeholder(tf.float32, shape=[None, 784]) y_ = tf.placeholder(tf.float32, shape=[None, 10]) x_image = tf.reshape(x, [-1,28,28,1]) de...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Plotting Methods Step2: scikit-rf includes a convenient command to make nicer figures quick Step3: Another common option is to draw admittance...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import skrf as rf from skrf import Network ring_slot = Network('data/ring slot.s2p') ring_slot.plot_s_smith() rf.stylely() # nicer looking. Can be configured with different styles ring_slot.plot_s_smith() ring_slot.plot_s_smith(draw_labels=True) ring_slot.plot_s_smi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Initiate experiment with this input file Step2: Before we start to draw random realisations of the model, we should first store the base state ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline # here the usual imports. If any of the imports fails, # make sure that pynoddy is installed # properly, ideally with 'python setup.py develop' # or 'python setup.py install' import sys, os import matplotlib.pyplot as plt import numpy as np # adjust some settings for ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: We just defined a JulianDay class that takes one argument of type string or binary, and returns a float. Step 2 Step3: Interlude Step4: Step 3...
<ASSISTANT_TASK:> Python Code: import ibis.expr.datatypes as dt import ibis.expr.rules as rlz from ibis.expr.operations import ValueOp from ibis.expr.signature import Argument as Arg class JulianDay(ValueOp): arg = Arg(rlz.string) output_type = rlz.shape_like('arg', 'float') from ibis.expr.types import StringV...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Create Parametrized Model Step2: Search for the Critical Boron Concentration Step3: Finally, the openmc.search_for_keff function also provided...
<ASSISTANT_TASK:> Python Code: # Initialize third-party libraries and the OpenMC Python API import matplotlib.pyplot as plt import numpy as np import openmc import openmc.model %matplotlib inline # Create the model. `ppm_Boron` will be the parametric variable. def build_model(ppm_Boron): # Create the pin materials...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load the data Step2: Setup source space and compute forward Step3: From here on, standard inverse imaging methods can be used! Step4: Get an ...
<ASSISTANT_TASK:> Python Code: import os.path as op import numpy as np import mne from mne.datasets import eegbci from mne.datasets import fetch_fsaverage # Download fsaverage files fs_dir = fetch_fsaverage(verbose=True) subjects_dir = op.dirname(fs_dir) # The files live in: subject = 'fsaverage' trans = 'fsaverage' #...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The numpy.random module adds to the standard built-in Python random functions for generating efficiently whole arrays of sample values with many...
<ASSISTANT_TASK:> Python Code: import numpy as np samples = np.random.normal(size=(4,4)) samples import random N = 10000000 %timeit samples = [random.normalvariate(0,1) for i in range(N)] import matplotlib.pyplot as plt %matplotlib inline #plt.plot(INSERT THE NAME OF THE VARIABLE CONTAINING THE PATH) #plt.plot(INSE...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Contour plots of 2d wavefunctions Step3: The contour, contourf, pcolor and pcolormesh functions of Matplotlib can be used for effective visuali...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np def well2d(x, y, nx, ny, L=1.0): Compute the 2d quantum well wave function. return (2/L)*np.sin(nx * np.pi * x/L)*np.sin(ny * np.pi * y/L) psi = well2d(np.linspace(0,1,10), np.linspace(0,1,10), 1, 1) assert len...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Motivation and Discretizing Step2: Running the Program Step3: Checking the Forcing Step4: The velocity field over time Step5: Variations on ...
<ASSISTANT_TASK:> Python Code: # Import clusters from scipy import sparse #Allows me to create sparse matrices (i.e. not store all of the zeros in the 'A' matrix) import scipy.sparse.linalg as spla #To solve each time iteration, as my SOR code (below) grows exponentially when attempting to solve with negative values on...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: You can see it already has various tags identifying its structure (indeed enough to uniquely identify each gate) Step2: The core object describ...
<ASSISTANT_TASK:> Python Code: V = circ.uni V.graph(color=['U3', gate2], show_inds=True) V.graph(color=[f'ROUND_{i}' for i in range(depth)], show_inds=True) V.graph(color=[f'I{i}' for i in range(n)], show_inds=True) # the hamiltonian H = qu.ham_ising(n, jz=1.0, bx=0.7, cyclic=False) # the propagator for the hamiltonia...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Les instructions SQL s'écrivent d'une manière qui ressemble à celle de phrases ordinaires en anglais. Cette ressemblance voulue vise à faciliter...
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() import sqlite3 # on va se connecter à une base de données SQL vide # SQLite stocke la BDD dans un simple fichier filepath = "./DataBase.db" open(filepath, 'w').close() #crée un fichier vide CreateDataBase = sqlite3.connect(f...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The functions below take a short segment of data, do a zero-padded FFT (to do some extra smoothing), then find the largest peak above and below ...
<ASSISTANT_TASK:> Python Code: chan='L1:LSC-POP_A_RF9_I_ERR_DQ' st=1162024217 dur=600 data=TimeSeries.fetch(chan,st,st+dur) srate=data.sample_rate.value twid=int(srate) # Length of short spectra zpadsec=8 # Length (sec) for oversampled FFT zpadwid=int(srate*zpadsec) win1=sig.hann(twid) def myfft(data,tt): idx=int(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: These are the imports from the Keras API. Note the long format which can hopefully be shortened in the future to e.g. from tf.keras.models impor...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import PIL import tensorflow as tf import numpy as np import os from tensorflow.python.keras.models import Model, Sequential from tensorflow.python.keras.layers import Dense, Flatten, Dropout from tensorflow.python.keras.applications imp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Grab the &lt;li&gt; tags Step2: Handling special dates with multiple accidents Step3: But then there are also separate entries for each &lt;li...
<ASSISTANT_TASK:> Python Code: base_url = "https://en.wikipedia.org" index_ref = "/wiki/List_of_accidents_and_incidents_involving_commercial_aircraft" index_html = urlopen(base_url + index_ref) index = BeautifulSoup(index_html, "lxml") result = index.find_all('li') result[829] result[830:834] result[0].find('a').ge...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Check and set your environment Step2: Let's reassign the $SPECPROD environment to something other than dailytest so that we don't conflict with...
<ASSISTANT_TASK:> Python Code: import os import numpy as np import matplotlib.pyplot as plt from astropy.io import fits from astropy.table import Table import desispec.io import desisim.io from desisim.obs import new_exposure from desisim.scripts import quickgen from desispec.scripts import group_spectra %pylab inline ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: # 텐서 만들기 및 조작 Step2: ## 벡터 덧셈 Step3: ### 텐서 형태 Step4: ### 브로드캐스팅 Step5: ## 행렬 곱셈 Step6: ## 텐서 형태 변경 Step7: 또한 tf.reshape를 사용하여 텐서의 차원 수(\'...
<ASSISTANT_TASK:> 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, sof...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: a. histogram Step2: Different features have different ditributions.
<ASSISTANT_TASK:> Python Code: import numpy as np import os from sklearn.manifold import TSNE from common import Data lld=Data('lld') lld.load_training_data() print 'training feature shape: ', lld.feature.shape print 'training label shape: ', lld.label.shape #lld.load_test_data() #print 'test feature shape: ',lld.featu...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <pre> Step2: Example 2 - Number of commits pushed per repository Step3: The Split-Apply-Combine Pattern Step4: <img src="http Step5: This St...
<ASSISTANT_TASK:> Python Code: import os import gzip import ujson as json directory = 'data/github_archive' filename = '2015-01-29-16.json.gz' path = os.path.join(directory, filename) with gzip.open(path) as f: events = [json.loads(line) for line in f] #print json.dumps(events[0], indent=4) new_repo_count = 0 ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Breaking it down... Step2: For loops Step3: One confusing aspect of this loop is range(1,4) why does this loop from 1 to 3? Why not 1 to 4? We...
<ASSISTANT_TASK:> Python Code: i = 1 while i <= 3: print(i,"Mississippi...") i=i+1 print("Blitz!") ## WARNING!!! INFINITE LOOP AHEAD ## IF YOU RUN THIS CODE YOU WILL NEED TO STOP OR RESTART THE KERNEL AFTER RUNNING THIS!!! i = 1 while i <= 3: print(i,"Mississippi...") print("Blitz!") for i in range(1,4): ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Definition of variables Step2: The Badness Index of each winter Step3: There you have it! Some candidates for Worst Winter Ever can be determi...
<ASSISTANT_TASK:> Python Code: import pandas as pd # Read data, sort by year & month dateparse = lambda x: pd.datetime.strptime(x, '%Y%m%d') noaa_monthly = pd.read_csv('chicago-midway-noaa.csv', index_col=2, parse_dates=True, date_parser=dateparse, na_values=-9999) noaa_monthly = noaa_monthly...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Searching the database Step2: We can get the number of returned records by looking at record["Count"] Step3: But what are our records? We can ...
<ASSISTANT_TASK:> Python Code: import os from Bio import Entrez, SeqIO Entrez.email = "" # Use your own real email Entrez.tool = "Biopython_get_GenBank_genomes.ipynb" genus = "Pectobacterium" query_text = "{0} AND bacteria[Organism]".format(genus) handle = Entrez.esearch(db='genome', term=query_text) record = Entrez....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 2...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cams', 'cams-csm1-0', 'seaice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "e...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: This was developed using Python 3.5.2 (Anaconda) and TensorFlow version Step2: Load Data Step3: The MNIST data-set has now been loaded and con...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import tensorflow as tf import numpy as np from sklearn.metrics import confusion_matrix tf.__version__ from tensorflow.examples.tutorials.mnist import input_data data = input_data.read_data_sets("data/MNIST/", one_hot=True) print("Size...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load Corpus After Preprocessing ... Step2: Basic & Advanced machine learning tools Step4: What are the features? Step5: Classification accura...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline import seaborn as sns import random #Training Corpus trn_corpus_after_preprocessing = pd.read_csv("output/trn_corpus_after_preprocessing.csv") #Testing Corpus tst_corpus_after_preprocessing = pd.rea...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We will now ask the pygame library to load a .wav file into memory and make it into a sound, ready to play. Step2: The play() method of the dru...
<ASSISTANT_TASK:> Python Code: import pygame.mixer pygame.mixer.init() drum = pygame.mixer.Sound("/opt/sonic-pi/etc/samples/drum_tom_mid_hard.wav") drum.play() def play(): print("Drums !") drum.play() play() #load GPIO library import RPi.GPIO as GPIO #Set BCM (Broadcom) mode for the pin numbering GPIO.setmo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: First we create a training set of size n_samples containing n_features each. Step2: Next we run a performance test on the created data set. The...
<ASSISTANT_TASK:> Python Code: # imports from sklearn.datasets import make_classification from sklearn.ensemble import RandomForestClassifier from timeit import default_timer as timer import matplotlib.pyplot as plt n_samples = 200000 n_features = 20 X, y = make_classification(n_samples=n_samples, n_features=n_feature...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Example 1 Step2: Passing datetime.datetime Step3: Example 2 Step4: Therefore, according to Brazilian epiweek system, it should fall on the la...
<ASSISTANT_TASK:> Python Code: from episem import episem d = '2010-10-01' episem(d) episem(d,out='W') import datetime datetime.datetime.strptime(d, '%Y-%m-%d') dt = datetime.datetime.strptime(d, '%Y-%m-%d') episem(dt) dt2 = datetime.datetime.strptime('2016-01-01', '%Y-%m-%d') dt2.isoweekday() episem(dt2) dt3 = dat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: as compounds Step2: and as mixtures of compounds Step3: These materials can be used in a particular geometry (currently only flat multi-layere...
<ASSISTANT_TASK:> Python Code: from spectrocrunch.materials import element element1 = element.Element("Ca") print(element1) from spectrocrunch.materials import compoundfromformula from spectrocrunch.materials import compoundfromname from spectrocrunch.materials import compoundfromlist from spectrocrunch.materials impo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Damped, driven nonlinear pendulum Step4: Write a function derivs for usage with scipy.integrate.odeint that computes the derivatives for the da...
<ASSISTANT_TASK:> 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 g = 9.81 # m/s^2 l = 0.5 # length of pendulum, in meters tmax = 50. # seconds t = np.linspace(0, tmax, int(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Check out the Data Step2: EDA-Exploratory Data Analysis Step3: Training a Linear Regression Model Step4: Train Test Split Step5: Creating an...
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline USAhousing = pd.read_csv('USA_Housing.csv') USAhousing.head() USAhousing.info() USAhousing.describe() USAhousing.columns sns.set_style('darkgrid') sns.pairplot(USAhousing) sns...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Mesh generation by Transfinite Interpolation applied to the sea dike problem Step2: Unfortunately, the TFI is defined on the unit square, so we...
<ASSISTANT_TASK:> Python Code: # Execute this cell to load the notebook's style sheet, then ignore it from IPython.core.display import HTML css_file = '../style/custom.css' HTML(open(css_file, "r").read()) # Import Libraries %matplotlib inline import numpy as np import matplotlib.pyplot as plt # Here, I introduce a ne...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The second method defined fits a polynomial curve to the data points and then plots it. Here we will try a 1, 2, and 3, degree polynomial. Step2...
<ASSISTANT_TASK:> Python Code: p_data = p1.retrieve_pendulum_data() plt.plot(p_data[0],p_data[1],'go') plt.show() p_data = p1.retrieve_pendulum_data() fit1 = p1.pendulum_fit(p_data[0],p_data[1],1) plt.plot(fit1[0],fit1[1],'y') fit2 = p1.pendulum_fit(p_data[0],p_data[1],2) plt.plot(fit2[0],fit2[1],'b') fit3 = p1.pendul...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Create an empty dictionary and for each variable whose absolute value of correlation coefficient with the heating space energy consumption is gr...
<ASSISTANT_TASK:> Python Code: import csv file = open('public_layout.csv','r') reader = csv.reader(file, delimiter=',') fullcsv = list(reader) dic_1=dict() print(dic_1) for i in range(801): data = np.genfromtxt('recs2009_public.csv',delimiter=',',skip_header=1,usecols=(i,908)) coef = np.corrcoef(data[:,0],data...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: <img src="https Step4: 3 - Launching IJulia Step5: And now, you should see a IJulia notebook starting next to this IPython Notebook Step6: 5 ...
<ASSISTANT_TASK:> Python Code: import os import sys import io # downloading julia (32Mo, may take 1 minute or 2) try: import urllib.request as urllib2 # Python 3 except: import urllib2 # Python 2 if 'amd64' in sys.version.lower(): julia_binary="julia-0.3.7-win64.exe" julia_url="http://s3.amazonaws.com...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
<ASSISTANT_TASK:> Python Code: from scipy.optimize import curve_fit import numpy as np s = '''1.000000000000000021e-03,2.794682735905079767e+02 4.000000000000000083e-03,2.757183469104809888e+02 1.400000000000000029e-02,2.791403179603880176e+02 2.099999999999999784e-02,1.781413355804160119e+02 3.300000000000000155e-02,-...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Notice the line that starts with %. This is a 'magic command' specific to Jupyter. It ensures that images will be plotted inline, instead of pop...
<ASSISTANT_TASK:> Python Code: import matplotlib import matplotlib.pyplot as plt import numpy as np import pandas as pd import sklearn import qutip from skimage import io from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression from ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Datentypen Step2: Aktionen Step3: Variablen, Vergleiche und Zuordnungen von Variablen Step4: if - else - (elif) Step5: Lists Step6: Diction...
<ASSISTANT_TASK:> Python Code: #Mit einem Hashtag vor einer Zeile können wir Code kommentieren, auch das ist sehr wichtig. #Immer, wirklich, immer den eigenen Code zu kommentieren. Vor allem am Anfang. print('hello world') #Der Printbefehl druckt einfach alles aus. Nicht wirklich wahnsinnig toll. #Doch er ist später...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: let's explore the dataset. Step2: in the train data we have 20 time series each of 210 data points. Notice that all the lines are compact and f...
<ASSISTANT_TASK:> Python Code: import h2o from h2o.estimators.deeplearning import H2OAutoEncoderEstimator h2o.init() %matplotlib inline import matplotlib import numpy as np import matplotlib.pyplot as plt import os.path PATH = os.path.expanduser("~/h2o-3/") train_ecg = h2o.import_file(PATH + "smalldata/anomaly/ecg_disc...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Porównanie z próbkowaniem "ręcznym" Step2: Dobrze Step3: Z jest row major więc można też napisać Step4: mgrid Step5: Zresztą sprawdzmy
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np nx = 11 ny = 5 x1,y1 = 1,2 X,Y = np.meshgrid(np.linspace(0,x1,nx),np.linspace(0,y1,ny)) X.shape f = lambda X_,Y_:np.sin(X_**2+Y_**2) Z = f(X,Y) plt.contourf(X,Y,Z) # To samo co: # plt.contourf(X.T,Y.T,Z.T) plt.imshow(Z,...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1.4 Jeux de Nim Step3: On va d'abord écrire une fonction toute simple qui affiche une configuration, en mode texte. Step4: On peut définir et ...
<ASSISTANT_TASK:> Python Code: import numpy as np import numpy.random as random import matplotlib.pyplot as plt a = [1, 3, 5] def print_nim(configuration): Affiche une configuration, donnée sous forme d'une liste d'entiers. for i, nb in enumerate(configuration): print(i, ':', '! ' * nb) print_nim(a...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Patterns Step2: translate Step3: rotate Step4: We can choose any point of rotation so let's also do this about the center. Step5: scale Step...
<ASSISTANT_TASK:> Python Code: import dphox as dp import numpy as np import holoviews as hv hv.extension('bokeh') pi = dp.text(r"$\pi$") pi.port['p'] = dp.Port(3, 1) pi.hvplot().opts(title='pi') pi1 = pi.copy.translate() # no translation pi2 = pi.copy.translate(10) # translation by 10 pi3 = pi.copy.translate(10, 1...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <a id="ref1"></a> Step2: define the class with the Tanh activation function Step3: define the class for the Relu activation function Step4: d...
<ASSISTANT_TASK:> Python Code: !conda install -y torchvision import torch import torch.nn as nn import torchvision.transforms as transforms import torchvision.datasets as dsets import torch.nn.functional as F import matplotlib.pylab as plt import numpy as np torch.manual_seed(2) class Net(nn.Module): def __init__...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Plotting the open price Step2: Plotting the volume traded Step3: Finding the timestamp of highest traded volume Step4: Creating 'Total Traded...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd from datetime import datetime import matplotlib.pyplot as plt %matplotlib inline tesla = pd.read_csv('Tesla_Stock.csv', parse_dates= True, index_col='Date') tesla.head() ford = pd.read_csv('Ford_Stock.csv', parse_dates= True, index_col='Date') ford...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: lmplot() Step2: Working with Markers Step3: Using a Grid Step4: Aspect and Size
<ASSISTANT_TASK:> Python Code: import seaborn as sns %matplotlib inline tips = sns.load_dataset('tips') tips.head() sns.lmplot(x='total_bill',y='tip',data=tips) sns.lmplot(x='total_bill',y='tip',data=tips,hue='sex') sns.lmplot(x='total_bill',y='tip',data=tips,hue='sex',palette='coolwarm') # http://matplotlib.org/api/...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We need to import some libraries Step2: Open up the input image Step3: ...and let's take a look at it Step4: Next we'll dive straight in and ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np # for array manipulation and the fft import pylab as pl # for plotting import cv2 # for image file handling cat = cv2.imread('./FIGURES/cat1.jpg',0) pl.imshow(cat,cmap='gray') pl.show() cat_squiggle = np.fft.fft2(cat) cat_squiggle_sh...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The data is too big to determine exactly what columns are usable for our analysis (137 columns with over 150,000 records. Kaggle did provide a d...
<ASSISTANT_TASK:> Python Code: # standard libraries import pandas as pd from matplotlib import pyplot as plt import seaborn as sns import numpy as np # for Bayesian analysis import pymc3 as pm # cleaning up the notebook import warnings warnings.filterwarnings('ignore') df = pd.read_csv('../../../Data/globalterrorismdb_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load house value vs. crime rate data Step2: Exploring the data Step3: Fit the regression model using crime as the feature Step4: Let's see wh...
<ASSISTANT_TASK:> Python Code: import pandas as pa import matplotlib.pyplot as plt import numpy as np from sklearn import linear_model regressionDir = '/home/weenkus/workspace/Machine Learning - University of Washington/Regression' sales = pa.read_csv(regressionDir + '/datasets/Philadelphia_Crime_Rate_noNA.csv') sales...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Replace by your GCP project and bucket Step2: Loading the dataset in GCS Step3: It has very specialized language such as Step4: and for gcs-...
<ASSISTANT_TASK:> Python Code: !pip freeze | grep tensorflow-hub==0.7.0 || pip install tensorflow-hub==0.7.0 import os import tensorflow as tf import tensorflow_hub as hub PROJECT = "your-gcp-project-here" # REPLACE WITH YOUR PROJECT NAME BUCKET = "your-gcp-bucket-here" # REPLACE WITH YOUR BUCKET NAME os.environ["PROJ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Using interact for animation with data Step3: To create an animation of a soliton propagating in time, we are going to precompute the soliton d...
<ASSISTANT_TASK:> 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 def soliton(x, t, c, a): Return phi(x, t) for a soliton wave with constants c and a. return 0.5*c*(1/(np.co...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Firstly we will calculate the features required to characterise the pointcloud. Step2: Next we can get training as a numpy array for creating o...
<ASSISTANT_TASK:> Python Code: from geospatial_learn import learning as ln incloud = "/path/to/Llandinam.ply" ln.ply_features(incloud) training = ln.get_training_ply(incld) model = 'path/to/model.h5' ln.create_model(training, model, clf='keras', cv=5) classify_ply(incloud, model, train_field="training", class_field...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Given that we will perform some numerical integrations with this function below, we expand it onto a grid appropriate for integration by Gauss-L...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import print_function # only necessary if using Python 2.x import matplotlib.pyplot as plt import numpy as np from pyshtools.shclasses import SHCoeffs, SHGrid, SHWindow lmax = 100 coeffs = SHCoeffs.from_zeros(lmax) coeffs.set_coeffs(values=[1], ls=[5], m...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Loading a dataset Step2: Generating layers Step3: The Deep Residual Network Step4: The model is a collection of resnet modules between an inp...
<ASSISTANT_TASK:> Python Code: # Start by generating the backend: from neon.backends import gen_backend be = gen_backend(backend='gpu', batch_size=128) from neon.data.aeon_shim import AeonDataLoader from neon.data.dataloader_transformers import OneHot, TypeCast, BGRMeanSubtract import num...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Similarly, the rate parameters can automatically be given exponential priors Step3: Decorator Step4: Note that this is a simple Python functio...
<ASSISTANT_TASK:> Python Code: import pymc as pm import numpy as np from pymc.examples import disaster_model switchpoint = pm.DiscreteUniform('switchpoint', lower=0, upper=110) early_mean = pm.Exponential('early_mean', beta=1., value=1) late_mean = pm.Exponential('late_mean', beta=1., value=1) @pm.stochastic def swit...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nerc', 'hadgem3-gc31-hm', 'ocean') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name",...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Image Classification Step2: Explore the Data Step5: Implement Preprocess Functions Step8: One-hot encode Step10: Randomize Data Step12: Che...
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import problem_unittests as tests import tarfile cifar10_dataset_folder_path = 'cifar-10-batches-py' # Use Floyd's cifar-10 dataset if ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Looks good! Now we import transformers and download the scripts run_benchmark.py, run_benchmark_tf.py, and plot_csv_file.py which can be found u...
<ASSISTANT_TASK:> Python Code: #@title Check available memory of GPU # Check that we are using 100% of GPU # memory footprint support libraries/code !ln -sf /opt/bin/nvidia-smi /usr/bin/nvidia-smi !pip -q install gputil !pip -q install psutil !pip -q install humanize import psutil import humanize import os import GPUti...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Step 1 Step2: Check that we can store objects of different types in a dictionary Step3: Yay - seems to work just fine! Step 2 Step4: Step 2.2...
<ASSISTANT_TASK:> Python Code: # Setup %matplotlib inline import matplotlib.pyplot as plt from sklearn.datasets import load_iris from sklearn.cross_validation import train_test_split from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import confusion_matrix from sklearn.datasets import load_iris f...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Then we can display the final result Step2: Sawtooth Signal Step3: Then, to display Step4: Interactive mode
<ASSISTANT_TASK:> Python Code: import pedsp.oscillator as oscillator import pedsp.algorithm as algorithm import matplotlib.pyplot as plt import numpy as np amplitude = 1.; sample_rate = 8000; frequency = 5; duration_secs = 2; samples = int(duration_secs * sample_rate); duty = 0.5; square = oscillator.Square(amp=amplit...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let's open a file that contains a mover and lot's of changes Step2: A Simulator creates simulation steps. So we load a single step. Step3: Eac...
<ASSISTANT_TASK:> Python Code: import openpathsampling as p st = p.storage.Storage('_toy_retis.nc', mode='r') mc = st.steps[3] print mc pmc = mc.change print pmc pm = pmc.mover print pm.treeprint() pmc in pm ow_mover = p.OneWayShootingMover([], []) # we use dummy arguments since are not going to use it list(ow_m...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1. User-Specified Input Step3: <div class=hw> Step4: 2.2 Concatenating strings Step5: 2.3 Multiple Concatenations Step6: 2.4 Comparing Strin...
<ASSISTANT_TASK:> Python Code: import numpy as np import astropy.units as u faren = input("enter a temperature (in Fahrenheit): ") print(faren) print("green eggs and\n spam") # Triple quotes are another way to specify multi-line strings y = For score and seven minutes ago, you folks all learned some basic mathy s...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Configurations Step3: Data encoding Step4: Test Step5: Load data set Step6: Define Batch Generator Step7: Check the generator Step8: Defin...
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np import random import os vocab = (" $%'()+,-./0123456789:;=?ABCDEFGHIJKLMNOPQRSTUVWXYZ" "\\^_abcdefghijklmnopqrstuvwxyz{|}\n") graph_path = r"./graphs" test_text_path = os.path.normpath(r"../Dataset/arvix_abstracts.txt") batch_size=50...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np series = pd.Series([np.array([1,2,3,4]), np.array([5,6,7,8]), np.array([9,10,11,12])], index=['file1', 'file2', 'file3']) def g(s): return pd.DataFrame.from_records(s.values,index=s.index).reset_index().rename(columns={'index': 'name'}) df = g(se...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Here's the image, admittedly its small Step2: Here's the new image Step3: To write a binary file you first need to convert binary data to uint...
<ASSISTANT_TASK:> Python Code: #For data manipulations %pylab inline from IPython.display import set_matplotlib_formats from io import BytesIO import numpy as np #to compare to scipy's builtin conversions from scipy.misc import imsave, toimage #import pillow from PIL import Image set_cmap('Greys') checkerboard = np.mod...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Take for example an ideal low-pass filter, which would give a magnitude Step2: This filter hypothetically achieves zero ripple in the frequency...
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy import signal, fftpack import matplotlib.pyplot as plt from mne.time_frequency.tfr import morlet from mne.viz import plot_filter, plot_ideal_filter import mne sfreq = 1000. f_p = 40. flim = (1., sfreq / 2.) # limits for plotting nyq = sfreq / 2. # the Nyqu...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We have provided three images containing stars, taken with 3 different CCDs, in "stars_X.npz" where X = 0, 1, 2. Step2: Just to make sure that ...
<ASSISTANT_TASK:> Python Code: import os import numpy as np import matplotlib.pyplot as plt from rhlUtils import BBox, CCD, Image, imshow %matplotlib notebook %config InlineBackend.figure_format = 'retina' #%matplotlib qt #%gui qt dataDir = # complete mag0 = 33 # Magnitude of an object with 1 detected photon data =...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Loading the problem and the loop Step2: Now we define the domain of the function to optimize. Step3: And prepare the optimization object to ru...
<ASSISTANT_TASK:> Python Code: from emukit.test_functions import branin_function from emukit.core import ParameterSpace, ContinuousParameter, DiscreteParameter from emukit.core.initial_designs import RandomDesign from GPy.models import GPRegression from emukit.model_wrappers import GPyModelWrapper from emukit.bayesian_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1. Probabilistički grafički modeli -- Bayesove mreže Step2: Q Step3: Q Step4: Q Step5: (a) Step6: Prvo, prilažemo kôd koji to radi "standar...
<ASSISTANT_TASK:> Python Code: # Učitaj osnovne biblioteke... import sklearn import codecs import mlutils import matplotlib.pyplot as plt import pgmpy as pgm %pylab inline from pgmpy.models import BayesianModel from pgmpy.factors.discrete.CPD import TabularCPD from pgmpy.inference import VariableElimination model = Ba...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-mm', 'ocean') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "emai...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let us make sure that the artifact store exists Step2: Creating the KFP CLI builder for Vertex AI Step3: Build the image and push it to your p...
<ASSISTANT_TASK:> Python Code: PROJECT_ID = !(gcloud config get-value project) PROJECT_ID = PROJECT_ID[0] REGION = "us-central1" ARTIFACT_STORE = f"gs://{PROJECT_ID}-kfp-artifact-store" !gsutil ls | grep ^{ARTIFACT_STORE}/$ || gsutil mb -l {REGION} {ARTIFACT_STORE} !cat kfp-cli_vertex/Dockerfile KFP_CLI_IMAGE_NAME =...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Now I will create an object that knows how to deal with Martian times and illuminations. Step2: I saved some predefined places and their locati...
<ASSISTANT_TASK:> Python Code: from pymars import kmaspice inca = kmaspice.MarsSpicer() inca.goto('inca') inca.time.isoformat() round(inca.l_s, 1) inca.local_soltime round(inca.illum_angles.dsolar,1) inca.advance_time_by(7*3600) round(inca.illum_angles.dsolar) inca.advance_time_by(-7*3600) times = [] angles = ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: 1a. Make an array of Fourier frequencies Step7: Now the T&K algorithm. I've transcribed the 'recipe' section of the T&K95 paper, which you will...
<ASSISTANT_TASK:> Python Code: n_bins = 8192 ## number of total frequency bins in a FT segment; same as number of time bins in the light curve dt = 1./16. # time resolution of the output light curve df = 1. / dt / n_bins def lorentzian(v, v_0, gamma): Gives a Lorentzian centered on v_0 with a FWHM of gamma ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 2. Plot chan1 as in resample2.ipynb, and add vancouver and portland points with a line between them Step2: What is the distance between Vancouv...
<ASSISTANT_TASK:> Python Code: import h5py from a301utils.a301_readfile import download from mpl_toolkits.basemap import Basemap from matplotlib import pyplot as plt import json import numpy as np rad_file=' MYD021KM.A2016217.1915.006.2016218155919.h5' geom_file='MYD03.A2016217.1915.006.2016218154759.h5' download(rad_f...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Sample dataset Step2: Exercise. What does this code do? Step3: Sparse matrix storage Step4: Exercise. What does the following code do? Step5:...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd from IPython.display import display edges = pd.read_csv ('UserEdges-1M.csv') display (edges.head ()) V_names = set (edges.Source) V_names.update (set (edges.Target)) m = len (edges) n = len (V_names) print ("==> |V| == %d, |E| == %d" % (n, m)) imp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Inside the notebook, the state will automatically display the values of the key variables Step2: Adding a label to the state for output purpose...
<ASSISTANT_TASK:> Python Code: from r3d2 import eos_defns, State eos = eos_defns.eos_gamma_law(5.0/3.0) U = State(1.0, 0.1, 0.0, 2.0, eos) U U2 = State(10.0, -0.3, 0.1, 5.0, eos, label="L") U2 q_available = 0.1 t_ignition = 10.0 Cv = 1.0 eos_reactive = eos_defns.eos_gamma_law_react(5.0/3.0, q_available, Cv, t_igniti...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Numerical Features Step2: The housing price correlates strongly with OverallQual, GrLivArea(GarageCars), GargeArea, TotalBsmtSF, 1stFlrSF, Full...
<ASSISTANT_TASK:> Python Code: # This Python 3 environment comes with many helpful analytics libraries installed # It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python # For example, here's several helpful packages to load in import numpy as np # linear algebra import pandas as pd #...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Loading and visualizing the input data Step2: Plotting the diffraction profile Step3: The profile showed above is highly smoothed and the hkl ...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt from ImageD11.columnfile import columnfile from ImageD11 import weighted_kde as wkde %matplotlib inline plt.rcParams['figure.figsize'] = (6,4) plt.rcParams['figure.dpi'] = 150 plt.rcParams['mathtext.fontset'] = 'c...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Hub with Keras Step2: ImageNet 分類器 Step3: 単一の画像で実行する Step4: バッチ次元を一つ追加し、画像をモデルに渡してください。 Step5: 結果は 1001 の要素をもつロジットベクトルで、画像がそれぞれのクラスに属する確率を表し...
<ASSISTANT_TASK:> 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 writin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step5: WARNING Step6: Outputs Step8: General markdown Step10: Headers aren't recognized by (Pandoc on Windows?) if there isn't a blank line above th...
<ASSISTANT_TASK:> Python Code: from IPython.nbconvert.utils.pandoc import pandoc from IPython.display import HTML, Javascript, display from IPython.nbconvert.filters import citation2latex, strip_files_prefix, \ markdown2html, markdown2latex def pandoc_render(markdown): Render Pa...