Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
10,200
<ASSISTANT_TASK:> Python Code: import numpy as np import tensorflow as tf import tensorflow.contrib.slim as slim from tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets import matplotlib.pyplot as plt %matplotlib inline import input_data mnist = input_data.read_data_sets('fashion-mnist/data/fash...
<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: Task Step6: Visualize reconstruction quality Step7: Illustrating latent space Step8: An other way of getting insights into the latent space i...
10,201
<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: Synthetic Features and Outliers Step4: Next, we'll set up our input function, and define the function for model training Step5: Task 1 Step6: ...
10,202
<ASSISTANT_TASK:> Python Code: %pylab inline %config InlineBackend.figure_format = 'retina' from matplotlib import style style.use('https://raw.githubusercontent.com/JoseGuzman/minibrain/master/minibrain/paper.mplstyle') from scipy.stats import norm mu = 0 sigma = 1 # std rv = norm(loc = mu, scale = sigma) x = np.lins...
<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: Gaussian Distribution Step3: The variance Step4: The covariance is always measured between two dimensions. If we have datasets with more than ...
10,203
<ASSISTANT_TASK:> Python Code: !pip install --upgrade pymongo from pprint import pprint as pp import pandas as pd import matplotlib.pyplot as plt import matplotlib %matplotlib inline matplotlib.style.use('ggplot') import pymongo from pymongo import MongoClient client = MongoClient("mongo",27017) client client.list_da...
<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: Usaremos la librería pymongo para python. La cargamos a continuación. Step2: La conexión se inicia con MongoClient en el host descrito en el fi...
10,204
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd big_df = pd.read_csv("UCI_Credit_Card.csv") big_df.head() len(big_df) len(big_df.dropna()) df = big_df.drop(labels = ['ID'], axis = 1) labels = df['default.payment.next.month'] df.drop('default.payment.next.month', axis = 1, inplace = True) num_samp...
<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 load the credit card dataset and extract a small dataframe of numerical features to test on. Step2: Now let us write our transformation ...
10,205
<ASSISTANT_TASK:> Python Code: from threeML import * %matplotlib inline import warnings warnings.simplefilter('ignore') # create the simulated observation energies = np.logspace(1,4,151) low_edge = energies[:-1] high_edge = energies[1:] # get a BPL source function source_function = Broken_powerlaw(K=2,xb=300,piv=300, ...
<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 will create an observation where we have a simulated broken power law source spectrum along with an observed background spectrum. The b...
10,206
<ASSISTANT_TASK:> Python Code: #|export import tensorboard from torch.utils.tensorboard import SummaryWriter from fastai.callback.fp16 import ModelToHalf from fastai.callback.hook import hook_output #|export class TensorBoardBaseCallback(Callback): order = Recorder.order+1 "Base class for tensorboard callbacks"...
<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: TensorBoardCallback Step2: Projector Step3: TensorBoardProjectorCallback Step4: projector_word_embeddings Step5: transformers Step6: BERT S...
10,207
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np from matplotlib import pyplot as plt %matplotlib inline df = pd.read_csv('bikes_rent.csv') df.head() fig, axes = plt.subplots(nrows=3, ncols=4, figsize=(15, 10)) for idx, feature in enumerate(df.columns[:-1]): df.plot(feature, "cnt", subplots=T...
<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: Мы будем работать с датасетом "bikes_rent.csv", в котором по дням записаны календарная информация и погодные условия, характеризующие автоматизи...
10,208
<ASSISTANT_TASK:> Python Code: print("Hello INBO_course!") # python 3(!) 4*5 3**2 (3 + 4)/2, 3 + 4/2, 21//5, 21%5 # floor division, modulo 3 > 4, 3 != 4, 3 == 4 my_variable_name = 'DS_course' my_variable_name name, age = 'John', 30 print('The age of {} is {:d}'.format(name, age)) import os os.listdir() import n...
<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: Python is a calculator Step2: also logical operators Step3: Variable assignment Step4: More information on print format Step5: <div class="a...
10,209
<ASSISTANT_TASK:> Python Code: @interact(xin=(-5,5,0.1),yin=(-5,5,0.1)) def plotInt(xin,yin): xmax = 2 vmax = 5 x = linspace(-xmax, xmax, 15) # Definimos el rango en el que se mueven las variables y el paso v = linspace(-vmax, vmax, 15) X, V = meshgrid(x,v) # Creamos una grilla con eso # Defini...
<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: El Pendulo Step2: El Pendulo con perdidas Step3: El resorte Oscilaciones longitudinales.
10,210
<ASSISTANT_TASK:> Python Code: import magma as m from mantle import DFF class TFF(m.Circuit): io = m.IO(O=m.Out(m.Bit)) + m.ClockIO() ff = DFF() m.wire( ff(~ff.O), io.O ) print(TFF) class RippleCounter(m.Generator): @staticmethod def generate(width: int): class _RippleCounter(m.Circuit): ...
<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: In the last example, we defined a function that created a Step2: Let's inspect the interface to see the result of appending m.ClockIO(). Step3:...
10,211
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import hyperspy.api as hs import matplotlib.pyplot as plt import pyxem as pxm dp = hs.load('./data/06/mgo_nanoparticles.hdf5') dp dp.plot(cmap='magma_r') sigma_min = 1.7 sigma_max = 13.2 dp_rb= dp.subtract_diffraction_background('difference of gaus...
<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 demonstration data Step2: Plot data to inspect Step3: Remove the background Step4: Plot the background subtracted data Step5: Find the ...
10,212
<ASSISTANT_TASK:> Python Code: import toytree import toyplot import numpy as np # generate a random tree tre = toytree.rtree.unittree(ntips=10, seed=12345) # the .treenode attribute of the ToyTree returns its root TreeNode tre.treenode # the .idx_dict of a toytree makes TreeNodes accessible by index tre.idx_dict prin...
<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: TreeNode objects are always nested inside of ToyTree objects, and accessed from ToyTrees. When you use .treenode to access a TreeNode from a Toy...
10,213
<ASSISTANT_TASK:> Python Code: from IPython.core.display import Image, display display(Image(url='images/TipicalValuesLongChannel.png')) %matplotlib inline import math import numpy as np import scipy as sp import matplotlib.pyplot as plt import pylab as plb def matrix(m_length,m_width): "Return matrix with no homo...
<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: Variacion por cuadro de Kp del 0.0004% Step2: Matriz de Trasconductancia ideal KP_n_Ideal Step3: Matriz de Trasconductancia ideal KP_p_Ideal S...
10,214
<ASSISTANT_TASK:> Python Code: %pylab notebook %precision 2 Pn = 100e6 # [W] PF = 0.8 f_nl_A = 61.0 # [Hz] SD_A = 3 # [%] f_nl_B = 61.5 # [Hz] SD_B = 3.4 # [%] f_nl_C = 60.5 # [Hz] SD_C = 2.6 # [%] f_fl_A = f_nl_A / (SD_A / 100.0 +1) f_fl_B = f_nl_B / (SD_B / 100.0 +1) f_fl_C = f_nl_C / (SD...
<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: Description Step2: (a) Step3: and the slopes of the power-frequency curves are Step4: The total load is 230 MW, so the system frequency can b...
10,215
<ASSISTANT_TASK:> Python Code: import os import numpy as np import matplotlib.pyplot as plt import shapefile as shp from pprint import pprint from matplotlib.path import Path as Polygon def inpoly(x, y, pgcoords): Returns bool array [Ny, Nx] telling which grid points are inside polygon try: isins...
<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 a function that will tell us whether a coordinate pair is inside a shape or not. This function exists in matplotlib.path and is called P...
10,216
<ASSISTANT_TASK:> Python Code: a = range(100, 1000) b = range(100, 1000) lst = [] for x in a: for y in b: p = x * y if str(p) == str(p)[::-1]: lst.append(p) print(max(lst)) # This cell will be used for grading, leave it at the end of the notebook. <END_TASK>
<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 I created an empty list, which would hold all the palindromes created from multiplying those three digit numbers. Step2: Using two for loo...
10,217
<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: Circuits 2 Step2: Electronic structure Hamiltonians with diagonal Coulomb operators Step3: In the last line above we converted the FermionOper...
10,218
<ASSISTANT_TASK:> Python Code: from IPython.display import YouTubeVideo YouTubeVideo('sXx-PpEBR7k') from IPython.display import YouTubeVideo YouTubeVideo('_Xcmh1LQB9I') from IPython.display import YouTubeVideo YouTubeVideo('jmMcJ4XlrWM', start=195, end=234) %matplotlib inline import matplotlib.pyplot as plt from skl...
<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 first generation of AI researchers were John McCarthy Step2: Neural networks returns Step3: The success of VC theory for number of proble...
10,219
<ASSISTANT_TASK:> Python Code: FACETS_INSTALL_DIR = './' %%bash -s "$FACETS_INSTALL_DIR" if [ ! -d "${1}/facets" ]; then # Install facets - only need to do this once per Datalab instance. cd $1 git clone https://github.com/PAIR-code/facets cd facets jupyter nbextension install facets-dist/ else ...
<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: Retrieve the data Step3: Execute the query to fill a Pandas dataframe with the data of interest. Step5: Visualize the result with Facets Step7...
10,220
<ASSISTANT_TASK:> Python Code: import enoslib as en # Enable rich logging _ = en.init_logging() # claim the resources network = en.G5kNetworkConf(type="prod", roles=["my_network"], site="rennes") conf = ( en.G5kConf.from_settings(job_type="allow_classic_ssh", job_name="enoslib_observability") .add_network_conf(...
<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 simple load generator Step2: Monitoring with dstat Step3: Visualization Step4: Packet sniffing with tcpdump Step5: Visualization Step6: C...
10,221
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'uhh', 'sandbox-3', 'atmoschem') # 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: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
10,222
<ASSISTANT_TASK:> Python Code: # import modules import pandas as pd # Create dataframe raw_data = {'regiment': ['Nighthawks', 'Nighthawks', 'Nighthawks', 'Nighthawks', 'Dragoons', 'Dragoons', 'Dragoons', 'Dragoons', 'Scouts', 'Scouts', 'Scouts', 'Scouts'], 'company': ['1st', '1st', '2nd', '2nd', '1st', '1st', ...
<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 grouped variable is now a GroupBy object. It has not actually computed anything yet except for some intermediate data about the group key ...
10,223
<ASSISTANT_TASK:> Python Code: # Import of the pyomo module from pyomo.environ import * # Creation of a Concrete Model model = ConcreteModel() ## Define sets ## # Sets # i canning plants / seattle, san-diego / # j markets / new-york, chicago, topeka / ; model.i = Set(initialize=['seattle'...
<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: Set Definitions Step2: Parameters Step3: A third, powerful way to initialize a parameter is using a user-defined function. Step4: Variables S...
10,224
<ASSISTANT_TASK:> Python Code: def func(): return 1 func() s = 'Global Variable' def func(): print locals() print globals() print globals().keys() globals()['s'] func() def hello(name='Jose'): return 'Hello '+name hello() greet = hello greet greet() del hello hello() greet() def hello(name='Jose'):...
<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: Scope Review Step2: Remember that Python functions create a new scope, meaning the function has its own namespace to find variable names when t...
10,225
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plot from ipywidgets import interactive import ipywidgets as widgets import math from pulp import * %matplotlib inline H1 = 0.3073 H2 = 0.8935 H3 = 1.1064 def J_fun(mu): I = (1 - 2**(-H1*(2*mu)**H2))**H3 return I def invJ_fu...
<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: Approximation of the J-function taken from [1] with Step2: The following function solves the optimization problem that returns the best $\lambd...
10,226
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() import pyquickhelper params={"blob_storage":"", "password1":"", "hadoop_server":"", "password2":"", "username":""} pyquickhelper.ipythonhelper.open_html_form(params=params,title="server + ...
<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: Connexion au cluster Step2: Création d'un petit jeu de données Step3: On importe ce graphe Step4: On vérifie que les données ont bien été cha...
10,227
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns; sns.set() import numpy as np rng = np.random.RandomState(1) x = 10 * rng.rand(50) y = 2 * x - 5 + rng.randn(50) plt.scatter(x, y); from sklearn.linear_model import LinearRegression model = LinearRegression(fit_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: Simple Linear Regression Step2: We can use Scikit-Learn's LinearRegression estimator to fit this data and construct the best-fit line Step3: T...
10,228
<ASSISTANT_TASK:> Python Code: # Import spaCy and load the language library import spacy nlp = spacy.load('en_core_web_sm') # Create a Doc object doc = nlp(u'Tesla is looking at buying U.S. startup for $6 million') # Print each token separately for token in doc: print(token.text, token.pos_, token.dep_) nlp.pipeli...
<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 doesn't look very user-friendly, but right away we see some interesting things happen Step2: Tokenization Step3: Notice how isn't has bee...
10,229
<ASSISTANT_TASK:> Python Code: from dolfin import * from rbnics import * @PullBackFormsToReferenceDomain() @AffineShapeParametrization("data/hole_vertices_mapping.vmp") class Hole(EllipticCoerciveProblem): # Default initialization of members def __init__(self, V, **kwargs): # Call the standard initiali...
<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: 3. Affine decomposition Step2: 4. Main program Step3: 4.2. Create Finite Element space (Lagrange P1) Step4: 4.3. Allocate an object of the Ho...
10,230
<ASSISTANT_TASK:> Python Code: import seaborn as sns import matplotlib.pyplot as plt %matplotlib inline sns.set_style('whitegrid') titanic = sns.load_dataset('titanic') titanic.head() sns.jointplot(x='fare',y='age',data=titanic) sns.distplot(titanic['fare'],bins=30,kde=False,color='red') sns.boxplot(x='class',y='ag...
<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: Jointplot comparing fare and age Step2: Plot the fare column as distribution Step3: Displaying passenger and age over a boxplot Step4: A simp...
10,231
<ASSISTANT_TASK:> Python Code: db_file = '../examples/data/clones_100.100.tab' # dialect="excel" for CSV or XLS files # for computational reasons, let's limit the dataset to the first 1000 sequences X = io.load_dataframe(db_file, dialect="excel-tab")[:1000] # turn the following off if data are real # otherwise, assume...
<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. Preprocessing step Step2: 2. High-level group inference Step3: 3. Fine-grained group inference Step4: Quickstart Step5: If you want to sa...
10,232
<ASSISTANT_TASK:> Python Code: import pylab as pl import casadi as ca import casiopeia as cp x = ca.MX.sym("x", 4) u = ca.MX.sym("u", 1) eps_u = ca.MX.sym("eps_u", 1) p = ca.MX.sym("p", 3) k_M = p[0] c_M = p[1] c_m = p[2] M = 250.0 m = 50.0 p_scale = [1e3, 1e4, 1e5] f = ca.vertcat( \ x[1], \ (p_scale[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: 2.) System definition Step2: 2.) Simulation Step3: 3.) Parameter estimation for initial experiment
10,233
<ASSISTANT_TASK:> Python Code: print 'Hello World!' # this is a comment! ''' This is technically just a multiline string but ususually it's used as a multiline comment. ''' b = True # bool s = 'This is a string' # str i = 4 # int f = 4.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: In Python single line comments are started with a <b>#</b>. Step2: Python doesn't actually have built in support of multiline comments. However...
10,234
<ASSISTANT_TASK:> Python Code: #Ejemplo de Consulta import Consulta as C from IPython.display import display, Markdown display(Markdown(C.F_Mark())) %%bash Rscript "Estadistica_Descriptiva.R" %%bash python Estadistica_Inferencial.py <END_TASK>
<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: ESTADÍSTICA Y ANÁLISIS Step2: Estadística de números
10,235
<ASSISTANT_TASK:> Python Code: data = \ ''' <html> <head> <meta charset="utf-8"> <title>Homepage of Prof. Dr. Karl Stroetmann</title> <link type="text/css" rel="stylesheet" href="style.css" /> <link href="http://fonts.googleapis.com/css?family=Rochester&subset=latin,latin-ext" rel="styleshee...
<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: Imports Step2: Token Declarations Step3: Definition of the States Step4: Token Definitions Step5: The Definition of the Token SCRIPT_START S...
10,236
<ASSISTANT_TASK:> Python Code: # standard imports import numpy as np import pandas as pd import matplotlib.pyplot as plt import xarray as xr import warnings %matplotlib inline np.set_printoptions(precision=3, linewidth=80, edgeitems=1) # make numpy less verbose xr.set_options(display_width=70) warnings.simplefilter('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: Basic data arrays in numpy Step2: numpy is a powerful but "low-level" array manipulation tool. Axis only have numbers and no names (it is easy ...
10,237
<ASSISTANT_TASK:> Python Code: #This line is very important: (It turns on the inline visuals!) %pylab inline a = [2,9,32,12,14,6,9,23,4,5,13,6,7,92,21,45]; b = [7,21,4,2,92,9,9,6,13,12,45,5,6,23,14,32]; #Please calculate the dot product of the vectors 'a' and 'b'. #You may use any method you like. If get stuck. Check: ...
<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 Pearson's test Step2: Pearson's comparison of microscopy derived images Step3: Maybe remove so not to clash with Mark's.
10,238
<ASSISTANT_TASK:> Python Code: import numpy as np from pwoogs import moog,estimate,utils import matplotlib.pyplot as plt import q2 import shutil as sh %matplotlib inline # Getting star names star_names = np.loadtxt('s_twins.csv', skiprows=1, usecols=(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: Step3: The following function is used to set the input files to be used by MOOG for a specific star from the list star_names. Step4: v_m returns the m...
10,239
<ASSISTANT_TASK:> Python Code: 4 2 + 2 50 - 5*6 (50-5)*6 8/5 8//5 # Floor division discards the fractional part 8%5 # The % operator return the remainder of the division 5 ** 3 # 5 squared type(4) type(1.3) width = 30 width width = 30 height = 2 width * height s = 3 * 4 s # Try to access an undefined variable p...
<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: With Python, use ** operator to calculate powers. Step2: Use equal sign(=) to assign a value to variable like math variable. Step3: If a varia...
10,240
<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: 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. ...
10,241
<ASSISTANT_TASK:> Python Code: from IPython.display import ( display, display_html, display_png, display_svg ) %matplotlib inline import numpy as np import matplotlib.pyplot as plt from IPython.core.pylabtools import print_figure from IPython.display import Image, SVG, Math class Gaussian(object): A simple ob...
<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: Parts of this notebook need the matplotlib inline backend Step3: Special display methods Step4: Create an instance of the Gaussian distributio...
10,242
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import os SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data') from shogun import * import shogun as sg #Needed lists for the final plot classifiers_linear = []*10 classifiers_non_linear = []*10 classifiers_nam...
<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 = "section1">Data Generation and Visualization</a> Step5: Data visualization methods. Step6: <a id="section2" href="http Step7: SVM - K...
10,243
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np my_dictionary = {'a' : 45., 'b' : -19.5, 'c' : 4444} print(my_dictionary.keys()) print(my_dictionary.values()) cookbook_df = pd.DataFrame({'AAA' : [4,5,6,7], 'BBB' : [10,20,30,40],'CCC' : [100,50,-30,-50]}) cookbook_df series_dict = {'one' : pd.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: Creating data frames from various data types Step2: constructor without explicit index Step3: constructor contains dictionary with Series as v...
10,244
<ASSISTANT_TASK:> Python Code: # we assume that we have the dynet module in your path. # OUTDATED: we also assume that LD_LIBRARY_PATH includes a pointer to where libcnn_shared.so is. from dynet import * # create a parameter collection and add the parameters. m = ParameterCollection() pW = m.add_parameters((8,2)) pV = ...
<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 first block creates a parameter collection and populates it with parameters. Step2: Training Step3: To use the trainer, we need to Step4: ...
10,245
<ASSISTANT_TASK:> Python Code: nb_name = "DCAL_Water_WOFS" # Enable importing of utilities. import sys import os sys.path.append(os.environ.get('NOTEBOOK_ROOT')) import numpy as np import xarray as xr import pandas as pd import matplotlib.pyplot as plt %matplotlib inline # Load Data Cube Configuration import datacub...
<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: <span id="import">Import Dependencies and Connect to the Data Cube &#9652;</span> Step2: <span id="plat_prod">Choose Platforms and Products &#9...
10,246
<ASSISTANT_TASK:> Python Code: from IPython.display import Image Image('../data/scatter_plot.png') import numpy as np import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = (10.0, 6.0) from sklearn.datasets.samples_generator import make_blobs X, y = blobs = make_blobs(n_samples=500, center...
<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: Of course, the first thing we need is the data. Usually this data will come from your experiments or your computations, but here we are going to...
10,247
<ASSISTANT_TASK:> Python Code: import numpy as np import shutil import os import tensorflow as tf print(tf.__version__) from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("mnist/data", one_hot = True, reshape = False) print(mnist.train.images.shape) print(mnist.train.labels.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: Exploring the data Step2: Define the model. Step3: Write Input Functions Step4: Write Custom Estimator Step5: tf.estimator.train_and_evaluat...
10,248
<ASSISTANT_TASK:> Python Code: abbr = 'NLP' full_text = 'Natural Language Processing' # Enter your code here: print(f'{abbr} stands for {full_text}') %%writefile contacts.txt First_Name Last_Name, Title, Extension, Email # Write your code here: with open('contacts.txt') as c: fields = c.read() # Run fields t...
<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: Files Step2: 3. Open the file and use .read() to save the contents of the file to a string called fields. Make sure the file is closed at the ...
10,249
<ASSISTANT_TASK:> Python Code: import os import sys # Google Cloud Notebook if os.path.exists("/opt/deeplearning/metadata/env_version"): USER_FLAG = "--user" else: USER_FLAG = "" ! pip3 install -U google-cloud-aiplatform $USER_FLAG ! pip3 install -U google-cloud-storage $USER_FLAG if not os.getenv("IS_TESTING...
<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: Install the latest GA version of google-cloud-storage library as well. Step2: Restart the kernel Step3: Before you begin Step4: Region Step5:...
10,250
<ASSISTANT_TASK:> Python Code: person_height_ft = pd.Series([5.5,5.2,5.8,6.1,4.8],name='height', index = ['person_a','person_b','person_c','person_d','person_e'],dtype=np.float64) person_height_ft person_height_ft.values person_height_ft.index person_height_ft['person_c'] person_height_ft[3] person_he...
<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 Series is like a fixed-size dict in that you can get and set values by index label Step2: You can also use the index position to get and set ...
10,251
<ASSISTANT_TASK:> Python Code: # Importing_new_features # ..is easy. Features are collected # in packages or modules. Just import telnetlib # to use a telnetlib.Telnet # client # We can even import single classes # from a module, like from telnetlib import Telnet # And read the module or class docs help(telnetlib) h...
<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: Python for System Administrator Step2: Basic Arithmetic Step3: Variable assignment Step4: Formatting numbers Step5: Formatting Step6: Forma...
10,252
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np bank = pd.read_csv('bank/bank-full.csv',sep=";") bank.head() X = bank.iloc[:,:-1] y = bank['y'] y = (y == 'yes')*1 X = np.array(X) from sklearn.preprocessing import OneHotEncoder bank = pd.get_dummies(bank,drop_first=True,sparse=True) X = bank.iloc...
<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: Exercise 2.1 (30 pts) Predict y from X using kernel SVMs, random forests, and adaboost (see the sklearn.ensembles package). Tune the random for...
10,253
<ASSISTANT_TASK:> Python Code: # corpus ficticio con tres documentos de la misma longitud # y sin repeticiones de términos dentro del mismo documento # cada doc es una lista de palabras d1 = 'los angeles times'.split() d2 = 'new york times'.split() d3 = 'new york post'.split() # nuestro corpus D es una lista de docume...
<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: tf (term frequency) Step2: La aproximación anterior, tal cual está programada, arma un diccionario de diccionarios pero tiene varias desventaja...
10,254
<ASSISTANT_TASK:> Python Code: m = folium.Map([45, 0], zoom_start=4) folium.Marker([45, -30], popup="inline implicit popup").add_to(m) folium.CircleMarker( location=[45, -10], radius=25, popup=folium.Popup("inline explicit Popup") ).add_to(m) ls = folium.PolyLine( locations=[[43, 7], [43, 13], [47, 13],...
<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: Vega Popup Step3: Fancy HTML popup Step4: Note that you can put another Figure into an IFrame ; this should let you do stange things...
10,255
<ASSISTANT_TASK:> Python Code: # We could tediously build a list … # filenames = ['/data/Houston/realtime-tracer/LYLOUT_200524_210000_0600.dat.gz',] # Instead, let's read a couple hours at the same time. import sys, glob filenames = glob.glob('/data/Houston/130619/LYLOUT_130619_2[0-1]*.dat.gz') for filename in filename...
<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: Investigating the pyxlma data structure Step2: lma_data is an xarray object. If we print it, we see that it looks much like a NetCDF file, with...
10,256
<ASSISTANT_TASK:> Python Code: import os import glob import itertools import nestly %load_ext rpy2.ipython %load_ext pushnote %%R library(ggplot2) library(dplyr) library(tidyr) library(gridExtra) ## min G+C cutoff min_GC = 13.5 ## max G+C cutoff max_GC = 80 ## max G+C shift max_13C_shift_in_BD = 0.036 min_BD = min_GC/...
<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: BD min/max Step2: Nestly Step3: Nestly params Step4: Copying input files Step5: Multi-window HR-SIP Step6: Making confusion matrices Step7:...
10,257
<ASSISTANT_TASK:> Python Code: import graphlab; products = graphlab.SFrame('amazon_baby.gl/') products.head() products['word_count'] = graphlab.text_analytics.count_words(products['review']) products.head() graphlab.canvas.set_target('ipynb') products['name'].show() giraffe_reviews = products[products['name'] == 'V...
<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: Read some product review data Step2: Let's explore this data together Step3: Build the word count vector for each review Step4: Examining the...
10,258
<ASSISTANT_TASK:> Python Code: import urllib url = 'http://ichart.yahoo.com/table.csv?s=MSFT&a=0&b=1&c=2009' data = pd.read_csv(url, parse_dates=['Date']) import bokeh.plotting as bp # 주피터 노트북이 아닌 파일로 출력하는 경우 # bp.output_file("../images/msft_1.html", title="Bokeh Example (Static)") # 주피터 노트북에서 실행하여 출력하는 경우 bp.output_n...
<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: Bokeh 라이브러리 임포트 Step2: 플롯팅 Step3: 다음으로 Figure 클래스의 메서드를 호출하여 실제 플롯 객체를 추가한다. 우선 라인 플롯을 그리기 위해 line 메서드을 실행한다. Step4: 이제 show 명령어를 호출하여 실제 차트를...
10,259
<ASSISTANT_TASK:> Python Code: # change these to try this notebook out BUCKET = 'cloud-training-demos-ml' PROJECT = 'cloud-training-demos' REGION = 'us-central1' import os os.environ['BUCKET'] = BUCKET os.environ['PROJECT'] = PROJECT os.environ['REGION'] = REGION os.environ['TFVERSION'] = '1.13' %%bash if ! gsutil ls...
<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: <h2> Deploy trained model </h2> Step2: <h2> Use model to predict (online prediction) </h2> Step3: The predictions for the four instances were
10,260
<ASSISTANT_TASK:> Python Code: from numpy import linalg as LA import numpy as np import pandas as pd import matplotlib.pyplot as plt def generate_test_image(m,n): X = np.zeros((m,n)) # generate a rectangle X[25:80,25:80] = 1 # generate a triangle for i in range(25, 80, 1): X[i+80:160, 100+i-1] = 2 ...
<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 introduce PCA with an image processing example. A grayscale digital image can be represented by a matrix, whose $(i,j)^{th}$ entry corre...
10,261
<ASSISTANT_TASK:> Python Code: input = tf.placeholder(tf.float32, (None, 32, 32, 3)) filter_weights = tf.Variable(tf.truncated_normal((8, 8, 3, 20))) # (height, width, input_depth, output_depth) filter_bias = tf.Variable(tf.zeros(20)) strides = [1, 2, 2, 1] # (batch, height, width, depth) padding = 'VALID' conv = tf.nn...
<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: calculate the number of parameters of a convo layer Step2: The output layer shape is Step3: There are 756,560 total parameters. That's a HUGE ...
10,262
<ASSISTANT_TASK:> Python Code: import requests r = requests.get('https://www.baidu.com/') print(type(r)) print(r.status_code) print(type(r.text)) print(r.headers) print(r.text) print(r.cookies) r = requests.post('http://httpbin.org/post') print('----POST----\n', r.text) r = requests.put('http://httpbin.org/put')...
<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: 请求响应的类型是 requests.models.Response Step2: 状态码是200 Step3: 响应体的类型是字符串str Step4: 可以得到响应的 HTTP HEADER Step5: 响应体内容 Step6: Cookies的类型是RequestsCoo...
10,263
<ASSISTANT_TASK:> Python Code: !pip install -q tensorflow-recommenders !pip install -q --upgrade tensorflow-datasets # You can use any Python source file as a module by executing an import statement in some other Python source file. # The import statement combines two operations; it searches for the named module, then...
<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: Note Step2: This notebook uses TF2.x. Step3: Lab Task 1 Step4: As before, we'll split the data by putting 80% of the ratings in the train set...
10,264
<ASSISTANT_TASK:> Python Code: import numpy as np # for quick visualization in notebook import matplotlib.pyplot as plt %matplotlib inline N = 100 # number of points per class D = 2 # dimensionality K = 3 # number of classes X = np.zeros((N*K,D)) # data matrix (each row = single example) y = np.zeros(N*K, dtype='uint8'...
<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: Training a softmax linear classifier Step2: Softmax loss using cross-entropy Step3: We now have an array probs of size [300 x 3], where each r...
10,265
<ASSISTANT_TASK:> Python Code: # 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 import mne print(__doc__) data_path = mne.datasets.opm.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: Load data, resample. We will store the raw objects in dicts with entries Step2: Do some minimal artifact rejection just for VectorView data Ste...
10,266
<ASSISTANT_TASK:> Python Code: def total_value(P, m, r, n): Total value of portfolio given parameters Based on following formula: A = \frac{P}{(r / m)} \left[ \left(1 + \frac{r}{m} \right)^{m \cdot n} - 1 \right ] :Input: - *P* (float) - Payment amount per compoundin...
<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: Root Finding and Optimization Step3: Fixed Point Iteration Step4: Guess at $r_0$ and check to see what direction we need to go... Step5: Exam...
10,267
<ASSISTANT_TASK:> Python Code: # Oversampling factor: we would like to see spectral windows # and periodograms in more detail than just at the Fourier frequencies oversampling = 10 truefreq = 0.2284271247 # Time sampling (a): ts = np.linspace(start = 1, stop = 90, num = 90) df1 = pd.DataFrame({'time': ts, ...
<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: Visualize first the three spectral windows. What are the differences between them? After inspecting it on the whole test frequency range, enlarg...
10,268
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pandas as pd import matplotlib.pyplot as plt plt.style.use('ggplot') data = pd.read_table('spectrum_crab_hess_2006.txt', comment='#', sep='\s*', engine='python') data def flux_ecpl(energy, flux1, gamma, energy_cut): re...
<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 Step2: The model Step3: Plot data and model Step4: The likelihood Step5: ML fit with Minuit Step6: Analysis with emcee
10,269
<ASSISTANT_TASK:> Python Code: import tensorflow as tf cluster = tf.train.ClusterSpec({"local": ["localhost:2222", "localhost:2223"]}) server0 = tf.train.Server(cluster, job_name="local", task_index=0) print(server0) server1 = tf.train.Server(cluster, job_name="local", task_index=1) print(server1) import tensorflow ...
<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: Start Server "Task 0" (localhost Step2: Start Server "Task 1" (localhost Step3: Define Compute-Heavy TensorFlow Graph Step4: Define Shape Ste...
10,270
<ASSISTANT_TASK:> Python Code: import time import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import numpy as np from sklearn import preprocessing from sklearn.ensemble import RandomForestClassifier from sklearn.cross_validation import StratifiedShuffleSplit from sklearn.cross_validation import 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: <h2> Import the dataframe and remove any features that are all zero </h2> Step2: <h2> Get mappings between sample names, file names, and sample...
10,271
<ASSISTANT_TASK:> Python Code: import hashlib import os import pickle from urllib.request import urlretrieve import numpy as np from PIL import Image from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelBinarizer from sklearn.utils import resample from tqdm import tqdm from zipfil...
<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: The notMNIST dataset is too large for many computers to handle. It contains 500,000 images for just training. You'll be using a subset of this...
10,272
<ASSISTANT_TASK:> Python Code: from owslib.csw import CatalogueServiceWeb endpoint = 'http://www.ngdc.noaa.gov/geoportal/csw' csw = CatalogueServiceWeb(endpoint, timeout=30) import pandas as pd ioos_ras = ['AOOS', # Alaska 'CaRA', # Caribbean 'CeNCOOS', # Central and Northern Califo...
<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 use the same list of all the Regional Associations as before, Step2: The function below is similar to the one we used before. Step3: C...
10,273
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import seaborn as sns x = np.linspace(0,4*np.pi,10) x f = np.sin(x) f plt.plot(x, f, marker='o') plt.xlabel('x') plt.ylabel('f(x)'); from scipy.interpolate import interp1d x = np.linspace(0,4*np.pi,10) # only use 10...
<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: Overview Step2: This creates a new array of points that are the values of $\sin(x_i)$ at each point $x_i$ Step3: This plot shows that the poin...
10,274
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np def well2d(x, y, nx, ny, L=1.0): z = (2 / L) * np.sin((nx * np.pi * x) / L) * np.sin((ny * np.pi * y) / L) return z psi = well2d(np.linspace(0,1,10), np.linspace(0,1,10), 1, 1) assert len(psi)==10 assert psi.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: Contour plots of 2d wavefunctions Step2: The contour, contourf, pcolor and pcolormesh functions of Matplotlib can be used for effective visuali...
10,275
<ASSISTANT_TASK:> Python Code: # Copyright 2019 The TensorFlow Hub Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
<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: Train embeddings on TPU using Autoencoder Step2: Get data Step3: Function to visualize our images and pick the first image from the test set S...
10,276
<ASSISTANT_TASK:> Python Code: tr = np.array(model.monitor.channels['valid_y_y_1_nll'].time_record) / 3600. fig = plt.figure(figsize=(12,8)) ax1 = fig.add_subplot(111) ax1.plot(model.monitor.channels['valid_y_y_1_nll'].val_record) ax1.plot(model.monitor.channels['train_y_y_1_nll'].val_record) ax1.plot(model_no_mom.moni...
<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: Plot ratio of update norms to parameter norms across epochs for different layers
10,277
<ASSISTANT_TASK:> Python Code: def soma( x, y): s = x + y return s r = soma(50, 20) print (r) def soma( x, y, squared=False): if squared: s = (x + y)**2 else: s = (x + y) return s print ('soma(2, 3):', soma(2, 3)) print ('soma(2, 3, False):', soma(2, 3, False)) print ('soma(2, 3, ...
<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: Para se realizar a chamada da função soma, basta utilizá-la pelo seu nome passando os parâmetros como argumentos da função. Veja o exemplo a seg...
10,278
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt %matplotlib inline df = pd.read_csv('tensile_test_data.csv', ) df.head() df = pd.read_csv('tensile_test_data.csv', header=None) df.head() df.plot(x=2, y=1) df = pd.read_excel('weather_data.xlsx') df.head() df = 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: This gives us some strange column names. '237.7605198' is one of the values in the data set, not the column name. We need to specify header=None...
10,279
<ASSISTANT_TASK:> Python Code: #!pip install -I "phoebe>=2.4,<2.5" %matplotlib inline import phoebe from phoebe import u # units import numpy as np logger = phoebe.logger() b = phoebe.default_binary() b.add_dataset('lc', compute_phases=phoebe.linspace(0,1,101)) b.run_compute(irrad_method='none') times = b.get_value('...
<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 first line is only necessary for ipython noteboooks - it allows the plots to be shown on this page instead of in interactive mode. Dependi...
10,280
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import seaborn as sns import numpy as np import pandas as pd # Required coverage level for analysis. This is in units of number of apatamer # particles (beads). This is used to minimize potential contamination. # For example, a tolerated bead fracti...
<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: Parameters used in Manuscript Step2: Load in data Step3: Load CSVs Step7: Helper functions Step8: Data Analysis Step9: Generate Figure Data...
10,281
<ASSISTANT_TASK:> Python Code: mps_to_mmph = 1000 * 3600 import numpy as np n_steps = 10 # can get from cfg file precip_rates = np.linspace(5, 20, num=n_steps, endpoint=False) precip_rates np.savetxt('./input/precip_rates.txt', precip_rates, fmt='%6.2f') cat input/precip_rates.txt from topoflow.components.met_base...
<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: Programmatically create a file holding the precipitation rate time series. This will mimic what I'll need to do in WMT, where I'll have access t...
10,282
<ASSISTANT_TASK:> Python Code: # print all urls import yaml import io val = yaml.safe_load(io.open("example_config.yaml", "rt")) print([entry["url"] for entry in val["handlers"]]) # print all urls import axon val = axon.load("example_config1.axon") print([entry["url"] for entry in val["handlers"]]) # print all urls v...
<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: In AXON it will be formatted as Step2: With AXON it can be also presented in the following form
10,283
<ASSISTANT_TASK:> Python Code: class Point: Represents a point in a 2D Euclidean plane. def __init__(self, x, y): self.x = x self.y = y @property def tuplify(self): return self.x, self.y def __lt__(self, other): return self.tuplify < other.tupl...
<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: Triangulation with line sweep Step5: Test the orientation method on a simple test case. Step6: Now we can start with our main method. Step7: ...
10,284
<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: 使用 tf.data 加载 pandas dataframes Step2: 下载包含心脏数据集的 csv 文件。 Step3: 使用 pandas 读取 csv 文件。 Step4: 将 thal 列(数据帧(dataframe)中的 object )转换为离散数值。 Step5...
10,285
<ASSISTANT_TASK:> Python Code: print('Auch beim Maschinellen Lernen immer wichtig:' + '\n' +'Aufgabe und Daten umfassend kennenlernen') %matplotlib inline import numpy as np x = np.array([[1, 2, 3], [4, 5, 6]]) print("x:\n{}".format(x)) from scipy import sparse # create a 2d NumPy array with a diagonal of ones, and ...
<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: <h2> Deshalb die Daten sich anzeigen lassen (print() etc.)</h2> Step2: <h2> Warum setzen wir die Bibliothek Scikit-learn ein ?</h2> Step3: <h3...
10,286
<ASSISTANT_TASK:> Python Code: # If you haven't already, make sure you install the `dfcx-scrapi` library !pip install dfcx-scrapi from dfcx_scrapi.core.project import Project creds_path = '<YOUR_CREDS_PATH>' project_id = '<YOUR_GCP_PROJECT_ID>' gcs_bucket = '<YOUR_GCS_BUCKET>' p = Project(creds_path, project_id=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: Step1: Imports Step2: User Inputs Step3: Extract All Agents from GCP Project Step5: Backup All Agents to GCS Bucket
10,287
<ASSISTANT_TASK:> Python Code: import os import numpy as np import pandas as pd import matplotlib.pyplot as plt from statsmodels.tsa.api import ExponentialSmoothing, SimpleExpSmoothing, Holt %matplotlib inline data = [446.6565, 454.4733, 455.663 , 423.6322, 456.2713, 440.5881, 425.3325, 485.1494, 506.0482, 526....
<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: Simple Exponential Smoothing Step2: Here we run three variants of simple exponential smoothing Step3: Holt's Method Step4: Seasonally adjuste...
10,288
<ASSISTANT_TASK:> Python Code: from quantopian.pipeline import Pipeline def make_pipeline(): return Pipeline() pipe = make_pipeline() from quantopian.research import run_pipeline result = run_pipeline(pipe, '2017-01-01', '2017-01-01') result.head(10) result.info() from quantopian.pipeline.data.builtin import USEqu...
<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 Step2: Factors Step3: Combining Factors Step4: Filters and Screens Step5: Screens Step6: Reverse a screen Step7: Combine Filters Step...
10,289
<ASSISTANT_TASK:> Python Code: data = [ {'age': 33, 'sex': 'F', 'BP': 'high', 'cholesterol': 'high', 'Na': 0.66, 'K': 0.06, 'drug': 'A'}, {'age': 77, 'sex': 'F', 'BP': 'high', 'cholesterol': 'normal', 'Na': 0.19, 'K': 0.03, 'drug': 'D'}, {'age': 88, 'sex': 'M', 'BP': 'normal', 'cholesterol': 'normal', '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: Understanding the task by understanding the data Step2: Then remove the 'drug' entry from all the dictionaries Step3: Sweet! Now let's look at...
10,290
<ASSISTANT_TASK:> Python Code: import os import sys import pandas as pd import seaborn as sns import matplotlib import matplotlib.pyplot as plt import utils %matplotlib inline %load_ext autoreload %autoreload 2 CSV_PATH = '../../data/unique_counts_semi.csv' # load data initial_df = utils.load_queries(CSV_PATH) # filte...
<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: Do some cleanup Step2: Query Frequency Analysis Step3: The frequency of queries drops off pretty quickly, suggesting a long tail of low freque...
10,291
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd from stemgraphic import stem_graphic df = pd.read_csv('../iris.csv') df.describe() stem_graphic(df['sepal_length']); <END_TASK>
<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 a data frame Step2: Select a column, or pass the whole dataframe if you want stem_graphic to select the first numerical column.
10,292
<ASSISTANT_TASK:> Python Code: from PyUGC import * from PyUGC.Stream import UGC from PyUGC.Base import OGDC from PyUGC import Engine from PyUGC import FileParser from PyUGC import DataExchange import datasource #help(UGC) #help(OGDC) #help(datasource) import os basepath = os.path.join(os.getcwd(),"../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: 2、使用Python的help(...)查看库的元数据信息获得帮助。 Step2: 3、设置测试数据目录。 Step3: 4、导入数据的测试函数。 Step4: 5、运行这个测试。 Step5: (三)查看生成的数据源文件UDB。 Step6: <font color="red...
10,293
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'retina' import numpy as np import pandas as pd import matplotlib.pyplot as plt data_path = 'Bike-Sharing-Dataset/hour.csv' rides = pd.read_csv(data_path) rides.head() rides[:24*10].plot(x='dteday', y='cnt') dummy_fields = ['seas...
<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 and prepare the data Step2: Checking out the data Step3: Dummy variables Step4: Scaling target variables Step5: Splitting the data into...
10,294
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper data_dir = './data/simpsons/moes_tavern_lines.txt' text = helper.load_data(data_dir) # Ignore notice, since we don't use it for analysing the data text = text[81:] view_sentence_range = (0, 10) DON'T MODIFY ANYTHING IN THIS CELL 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: TV Script Generation Step3: Explore the Data Step7: Implement Preprocessing Functions Step10: Tokenize Punctuation Step12: Preprocess all th...
10,295
<ASSISTANT_TASK:> Python Code: control=input() import getpass password=getpass.getpass() # Delete Jobs import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) # suppress warnings # Figure out samples from the header of ...
<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: Insert your admin password Step2: Deleting script
10,296
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt from astropy.io import fits from astropy.wcs import WCS from astropy.visualization import (MinMaxInterval, LogStretch, ImageNormalize) %matplotlib inline hdu = fits.open('./data/w5.fits')[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: 2. RGB-3-color images Step2: 3. RGB colors of Herschel-SPIRE images Step3:
10,297
<ASSISTANT_TASK:> Python Code: !head -n 2 ../data/yelp/yelp_training_set_review.json reviews = gl.SFrame.read_csv('../data/yelp/yelp_training_set_review.json', header = False) reviews reviews[0] reviews=reviews.unpack('X1','') reviews reviews = reviews.unpack('votes', '') reviews reviews.show() gl.canvas.set_target(...
<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: Unpack to extract structure Step2: Votes are still crammed in a dictionary. Let's unpack it. Step3: Quick data visualization Step4: 3. Proble...
10,298
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt from simmit import smartplus as sim import os E = 70000.0 nu = 0.3 L = sim.L_iso(E,nu,"Enu") print np.array_str(L, precision=4, suppress_small=True) d = sim.check_symetries(L) print(d['umat_type']) print(d['props']) x ...
<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: L_iso Step2: M_iso Step3: L_cubic Step4: M_cubic Step5: L_isotrans Step6: bp Step7: Ir2() Step8: Ir05()
10,299
<ASSISTANT_TASK:> Python Code: import pandas as pd df=pd.DataFrame(data=[[1,2],[3,4],[1,2],[1,4],[1,2]],columns=['col1','col2']) def g(df): df['index_original'] = df.groupby(['col1', 'col2']).col1.transform('idxmax') for i in range(len(df)): i = len(df) - 1 - i origin = df.loc[i, 'index_original...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: