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: Now let's try applying a weighting in the frequency domain that doesn't change the TD variance.
<ASSISTANT_TASK:> Python Code: invasd = sqrt(2./srate)/sqrt(shaped_psd1) invasd[0] = 0. whitener = sig.hann(seglen*srate)*roll(irfft(invasd), seglen*srate/2) wtest = TimeSeries(sig.convolve(shaped_noise2, whitener, mode='same')[8*srate:-8*srate], sample_rate=srate) p1 = wtest.psd(seglen).plot() 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: Pandas Step2: <hr> Step3: <hr> Step4: Keyboard Shortcuts Step5: В IPython встроенны несколько полезных magic commands, одна из них %time поз...
<ASSISTANT_TASK:> Python Code: from IPython.display import IFrame IFrame('http://jupyter.org/', width='100%', height=350) from IPython.display import IFrame IFrame('http://i.giphy.com/12Y8uwQsnpizCw.gif', width='100%', height=350) from IPython.display import IFrame IFrame('http://pandas.pydata.org/', width='100%', hei...
<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 start by node label prediction. Download this network. It contains protein communications in Baker’s yeast. Each node (protein) has a sp...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import scipy as sp import networkx as nx %matplotlib inline g = nx.read_gml('./data/ppi.CC.gml.txt') cc = list(nx.connected_components(g)) g = nx.subgraph(g,cc[0]) g = nx.relabel.convert_node_labels_to_integers(g) labels = np.array(nx.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: As always, let's do imports and initialize a logger and a new Bundle. See Building a System for more details. Step2: Dataset Parameters Step3:...
<ASSISTANT_TASK:> Python Code: !pip install -I "phoebe>=2.1,<2.2" %matplotlib inline import phoebe from phoebe import u # units import numpy as np import matplotlib.pyplot as plt logger = phoebe.logger() b = phoebe.default_binary() b.add_dataset('lp', times=[0,1,2], wavelengths=np.linspace(549, 551, 101)) print b.fil...
<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: PT3S Step2: Install PT3S to site-packages Step3: Logging Step5: about from PT3S ... import ... and pip install -e . Step6: ggf. Tests Step7:...
<ASSISTANT_TASK:> Python Code: import doctest >>> from platform import python_version >>> print(python_version()) 3.8.8 doctest.testmod() ### ggf. Rechte erforderlich: ### entweder in PowerShell: Start-Process powershell -Verb runAs ### oder RechteMausTaste WindowsSymbol: Windows PowerShell (Administrator) ### dann ...
<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 dataset we just generated looks like this Step2: Next up, let's split the dataset into a training and test set. The training set will be us...
<ASSISTANT_TASK:> Python Code: # Creating the dataset # e.g. make_moons generates crescent-shaped data # Check out make_classification, which generates ~linearly-separable data from sklearn.datasets import make_moons X, y = make_moons( n_samples=500, # the number of observations random_state=1, noise=0.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: And some more specialized dependencies Step2: Configuration for this figure. Step3: Open a chest located on a remote globus endpoint and load ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib matplotlib.rcParams['figure.figsize'] = (10.0, 8.0) import matplotlib.pyplot as plt import numpy as np from scipy.interpolate import interp1d, InterpolatedUnivariateSpline from scipy.optimize import bisect import json from functools import partial clas...
<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: If you want to use the CoNLL-03 corpus, you need to download it and unpack it in your Flair data and model folder. This folder should be in your...
<ASSISTANT_TASK:> Python Code: from flair.data import Corpus from flair.datasets import WNUT_17 from flair.embeddings import TokenEmbeddings, WordEmbeddings, StackedEmbeddings from typing import List corpus: Corpus = WNUT_17().downsample(0.1) print(corpus) tag_type = 'ner' tag_dictionary = corpus.make_tag_dictionary...
<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: 5. Check conda installs Step2: 6. Check pip installs Step3: 7. Download data
<ASSISTANT_TASK:> Python Code: !python -V # Should be 3.5 import numpy as np import matplotlib.pyplot as plt from scipy.signal import ricker import pandas as pd import requests import numba import ipyparallel as ipp import obspy import geopandas as gpd # Not a catastrophe if missing. import folium # Not a catastro...
<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({'datetime': ['2015-12-01 00:00:00-06:00', '2015-12-02 00:01:00-06:00', '2015-12-03 00:00:00-06:00']}) df['datetime'] = pd.to_datetime(df['datetime']) df['datetime'] = df['datetime'].dt.tz_localize(None) df.sort_values(by='datetime', inplace=True) df[...
<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: Lorenz system Step3: Write a function solve_lorenz that solves the Lorenz system above for a particular initial condition $[x(0),y(0),z(0)]$. Y...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from scipy.integrate import odeint from IPython.html.widgets import interact, fixed def lorentz_derivs(yvec, t, sigma, rho, beta): x = yvec[0] y = yvec[1] z = yvec[2] dx = sigma*(y-x) dy = x*(rho-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: Basic marker Step2: Circle Marker Step3: Icon Marker Step4: RGB(A) to HEX colors
<ASSISTANT_TASK:> Python Code: import folium carte = folium.Map(location=[45.5236, -122.6750], zoom_start=12) marker = folium.Marker([45.5, -122.7], popup='Un marker') marker.add_to(carte) carte carte = folium.Map(location=[45.5236, -122.6750], zoom_start=12) circle = folium.CircleMarker( [45.5, -122.7], radi...
<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: Next we choose a model and hyperparameters. Here we'll use a k-neighbors classifier with n_neighbors=1. Step2: Then we train the model, and use...
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import load_iris iris = load_iris() X = iris.data y = iris.target from sklearn.neighbors import KNeighborsClassifier model = KNeighborsClassifier(n_neighbors=1) model.fit(X, y) y_model = model.predict(X) from sklearn.metrics import accuracy_score accuracy_score(y,...
<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: Contents Step2: 2. Different ways of learning from data Step3: In the plot we can easily see that the blue points are concentrated on the top-...
<ASSISTANT_TASK:> Python Code: from IPython.display import Image %run ../scripts/1/discretize.py data %matplotlib inline import matplotlib.pyplot as plt import numpy as np # Adding a little bit of noise so that it's easier to visualize data_with_noise = data.iloc[:, :2] + np.random.normal(loc=0, scale=0.1, size=(150,...
<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: <center><img src="https Step2: A grouping pattern, avoiding quadratic time Step3: the bad way, quadratic time Step4: there is a better approa...
<ASSISTANT_TASK:> Python Code: __AUTHORS__ = {'am': ("Andrea Marino", "andrea.marino@unifi.it",), 'mn': ("Massimo Nocentini", "massimo.nocentini@unifi.it", "https://github.com/massimo-nocentini/",)} __KEYWORDS__ = ['Python', 'Jupyter', ...
<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. Register a model
<ASSISTANT_TASK:> Python Code: # restart your notebook if prompted on Colab try: import verta except ImportError: !pip install verta import os # Ensure credentials are set up, if not, use below # os.environ['VERTA_EMAIL'] = # os.environ['VERTA_DEV_KEY'] = # os.environ['VERTA_HOST'] = from verta import Client...
<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: Keras 예제에서 잘라내기 Step2: 잘라내기 없이 MNIST에 대한 모델 훈련하기 Step3: 기준 테스트 정확성을 평가하고 나중에 사용할 수 있도록 모델을 저장합니다. Step4: 잘라내기로 사전 훈련된 모델 미세 조정하기 Step5: 기준선과...
<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: First we need to define materials that will be used in the problem Step2: With our three materials, we can now create a Materials object that c...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import math import matplotlib.pyplot as plt import numpy as np import openmc import openmc.mgxs # 1.6 enriched fuel fuel = openmc.Material(name='1.6% Fuel') fuel.set_density('g/cm3', 10.31341) fuel.add_nuclide('U235', 3.7503e-4) fuel.add_nuclide('U238', 2.2625e-2) fuel...
<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 following function runs a random model with a random independent variable y and four random covariates, using both the statsmodels and sciki...
<ASSISTANT_TASK:> Python Code: from data_cleaning_utils import import_data dat = import_data('../Data/Test/pool82014-10-02cleaned_Subset.csv') from regression import compare_OLS compare_OLS(dat) %matplotlib inline from regression import user_model user_model(data=dat) %matplotlib inline import pandas as pd from regre...
<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, read the (sample) input tables for blocking purposes. Step2: Combining Multiple Blockers
<ASSISTANT_TASK:> Python Code: # Import py_entitymatching package import py_entitymatching as em import os import pandas as pd # Get the datasets directory datasets_dir = em.get_install_path() + os.sep + 'datasets' # Get the paths of the input tables path_A = datasets_dir + os.sep + 'person_table_A.csv' path_B = datas...
<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 we set up all necessary simulation parameters Step2: Next we set up the system. As in part I, the orientation of the dipole moments is set ...
<ASSISTANT_TASK:> Python Code: import espressomd import espressomd.magnetostatics espressomd.assert_features('DIPOLES', 'LENNARD_JONES') import numpy as np lj_sigma = 1 lj_epsilon = 1 lj_cut = 2**(1. / 6.) * lj_sigma # magnetic field constant mu_0 = 1. # Particles N = 1000 # Volume fraction # phi = rho * 4. / 3. * np....
<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: Split data into training and validation sets Step2: Redefining the problem Step3: Scaling Step4: Parameters Step5: Basic RNN Step6: Executi...
<ASSISTANT_TASK:> Python Code: # Import libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt import tensorflow as tf # Import data, format dates, sort data ascending by date data = pd.read_csv( 'data/AirPassengers.csv', sep=',', header=0, names=['date','no_passengers'], u...
<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: What versions are we running? Step2: Local Functions Step3: Generate Data Step4: View means of the various combinations (poisson mean values)...
<ASSISTANT_TASK:> Python Code: ## Interactive magics %matplotlib inline %qtconsole --colors=linux import sys import warnings warnings.filterwarnings('ignore') import regex as re import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import patsy as pt from scipy import optimize # 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: Carte en moyenne temporelle sur la totalité de l'expérience Step2: Carte en moyenne temporelle de $\chi$
<ASSISTANT_TASK:> Python Code: filename = 'resultat.nc' import numpy as np import matplotlib.pyplot as plt from pylab import * import cartopy.crs as ccrs from netCDF4 import Dataset from scipy.special import logit, expit %matplotlib inline import warnings warnings.filterwarnings('ignore') data = Dataset(filename) longi...
<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 first define a function to prepare the datas in the format of keras (theano). The function also reduces the size of the imagesfrom 100X100 to...
<ASSISTANT_TASK:> Python Code: import os import numpy as np import tools as im from matplotlib import pyplot as plt from skimage.transform import resize %matplotlib inline path=os.getcwd()+'/' # finds the path of the folder in which the notebook is path_train=path+'images/train/' path_test=path+'images/test/' path_real...
<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: MIDAS ADL Step2: Figure 1 Step3: Mixing Frequencies Step4: The arguments here are as follows Step5: You can also call forecast directly. Th...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import datetime import numpy as np import pandas as pd from midas.mix import mix_freq from midas.adl import estimate, forecast, midas_adl, rmse gdp = pd.read_csv('../tests/data/gdp.csv', parse_dates=['DATE'], index_col='DATE') pay = pd.read_csv('../tests/data/pay.csv',...
<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 modified SVHN dataset can be found at Step2: Below is a skeleton of the SVHN data iterator for you to fill out, with notes to help along th...
<ASSISTANT_TASK:> Python Code: from neon.backends import gen_backend be = gen_backend(batch_size=128, backend='gpu') # set the debug level to 10 (the minimum) # to see all the output import logging main_logger = logging.getLogger('neon') main_logger.setLevel(10) import cPickle fileName = 'data/svhn_64.p' print("Loadin...
<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: Problème Step2: Idée de la solution
<ASSISTANT_TASK:> Python Code: %matplotlib inline from jyquickhelper import add_notebook_menu add_notebook_menu() from IPython.display import Image Image("http://www.xavierdupre.fr/app/code_beatrix/helpsphinx/_images/biodiversite_tri2.png") from pyquickhelper.helpgen import NbImage NbImage("data/hexa.png") <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: There are a few frequency bands that are already part of the possum class Step2: Polarization Spectra Step3: Faraday Rotation Step4: Generati...
<ASSISTANT_TASK:> Python Code: from possum import * spec = possum() spec._createASKAP12() print('Min Frequency (Hz): {:e}'.format(spec.nu_.min())) print('Max Frequency (Hz): {:e}'.format(spec.nu_.max())) spec = possum() spec._createFrequency(600, 800, 100, store=True) # ===============================================...
<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: Computing the trajectories and plotting the result Step3: Let's call the function once to view the solutions. For this set of parameters, we se...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from ipywidgets import interact, interactive from IPython.display import clear_output, display, HTML import numpy as np from scipy import integrate from matplotlib import pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib.colors import cnames from mat...
<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 we can plot the results. The Probe records the vector coming out of the answer variable, so in order to interpret that we can do the dot-pr...
<ASSISTANT_TASK:> Python Code: import nengo_spa as spa import nengo model = spa.Network() with model: # configure Nengo to just directly conpute things, rather than trying to implement the # network with neurons model.config[nengo.Ensemble].neuron_type = nengo.Direct() model.config[nengo.Connection].sy...
<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: Basics Step2: You can assign several variables at once Step3: There is no "begin-end"! You use indentation to specify blocks. Here is simple I...
<ASSISTANT_TASK:> Python Code: # you can mix text and code in one place and # run code from a Web browser a = 10 a a, b = 1, 2 a, b b, a = a, b a, b if a > b: print("A is greater than B") else: print("B is greater than A") # Integer a = 1 print(a) # Float b = 1.0 print(b) # String c = "Hello world" print(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: Exercise Step2: Recursively computing values of a polynomial using difference equations Step3: Second order polynomial
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy.signal as signal import matplotlib.pyplot as plt %matplotlib inline # Define the continuous-time linear time invariant system F a = 2 b = 1 num = [1, b] den = [1, a] F = signal.lti(num, den) # Plot a step response (t, y) = signal.step(F) plt.figure(figsize=...
<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 Theory (section 6.3.3 - 6.3.5 of the syllabus) Step2: Convenience function for setting up graphs Step3: Draw the Theis type curve Step4: ...
<ASSISTANT_TASK:> Python Code: from scipy.special import exp1 as W import numpy as np import matplotlib.pyplot as plt from scipy.special import exp1 as W def newfig(title='forgot title?', xlabel='forgot the x-label?', ylabel='forgot the y-label?', xlim=None, ylim=None, xscale='linear', yscale='linear', siz...
<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 required libraries Step2: Wait for the message Configure docker credentials before moving on to the next cell. Step3: Configure a ...
<ASSISTANT_TASK:> Python Code: import logging import os import uuid from importlib import reload from oauth2client.client import GoogleCredentials credentials = GoogleCredentials.get_application_default() import notebook_setup reload(notebook_setup) notebook_setup.notebook_setup() import k8s_util # Force a reload 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: When feature_weight = None, the output should match Random Forest. Step2: When feature_weight is uniform, it should give the same feature impor...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt from sklearn.datasets import load_breast_cancer import numpy as np from functools import reduce # Import our custom utilities from imp import reload from utils import irf_jupyter_utils from utils import irf_utils reload(irf_jupyter_utils)...
<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 two lines deal with the ability to show your graphs (generated via matplotlib) within this notebook, the remaining two lines import ma...
<ASSISTANT_TASK:> Python Code: %matplotlib inline # plots graphs within the notebook %config InlineBackend.figure_format='svg' # not sure what this does, may be default images to svg format import matplotlib.pyplot as plt #calls the plotting library hereafter referred as to plt import numpy as np L = 8*np.pi N = 200 ...
<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: Plots Step2: Looking at Node size conditional probabilities
<ASSISTANT_TASK:> Python Code: # Necessary imports import os import time from nbminer.notebook_miner import NotebookMiner from nbminer.cells.cells import Cell from nbminer.features.ast_features import ASTFeatures from nbminer.stats.summary import Summary from nbminer.stats.multiple_summary import MultipleSummary #Load...
<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: Najprej sem spletne strani FIS pobrala podatke o smučarjih in njihovih id številkah na spletišču FIS. Id-je sem potrebovala za sestavljanje url ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd import matplotlib.pyplot as plt import numpy as py #import scipy # Make the graphs a bit prettier, and bigger #pd.set_option('display.mpl_style', 'default') #plt.rcParams['figure.figsize'] = (15, 5) # This is necessary to show lots of columns in pand...
<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: Generate the data Step2: Calculate the covariance matrix and get the eigen values/vectors Step3: Plot the eigen vectors on the data Step4: No...
<ASSISTANT_TASK:> Python Code: # to display interactive plots within the notebook %matplotlib notebook # to define the size of the plotted images from pylab import rcParams rcParams['figure.figsize'] = (10, 8) import matplotlib.pyplot as plt import numpy as np from fct import generate_multivariate, normalize, plot_3d, ...
<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 code sets up Ipython Notebook environments (lines beginning with %), and loads several libraries and functions. The core scientific stack ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import math import numpy as np import matplotlib.pyplot as plt import seaborn as sbn ##from scipy import * x = .5 print x x_vector = np.array([1,2,3]) print x_vector c_list = [1,2] print "The list:",c_list print "Has length:", len(c_list) c_vector = np.array(c_list) ...
<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. Calculate the translational partition function of a CO molecule in the bottle at 298 K. What is the unit of the partition function? Step2: 3...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt hbar = 1.05457e-34 # J*s h = 6.62607e-34 # J*s kB = 1.38065e-23 # J/K m = 28.01*1.6605e-27 # kg/molecule V = 0.02 # m^3 c = 2.99792e10 # cm/s B = 1.931 # cm^-1 v = 2156.6 # cm^-1 T_trans = np.pi**2*hbar**2/2/m/V**(2/3)/kB T_rot = h*c*B/kB...
<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 min and max submission dates for filtering main_summary. Step2: Load in main_summary, filtered to the min date of the experiment, and ...
<ASSISTANT_TASK:> Python Code: S3_PATH = "s3://net-mozaws-prod-us-west-2-pipeline-analysis/taarv2/cleaned_data/" # Select essential columns. clean_data = sqlContext.read.parquet(S3_PATH).select('client_id', 'locale', 'branch', 'submission_date_s3') # Display number of rows per branch. clean_data.groupBy('branch').count...
<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: obtido no site <a href="http Step2: O módulo ElementTree (ET) Step3: Para vermos o elemento raiz da árvore, usamos Step4: O objeto root, que ...
<ASSISTANT_TASK:> Python Code: arquivo = "IDEB por Município Rede Federal Séries Finais (5ª a 8ª).xml" import xml.etree.ElementTree as ET tree = ET.parse(arquivo) root = tree.getroot() root.tag root.attrib for child in root: print(child.tag, child.attrib) valoresIDEB = root.find('valores') valoresIDEB valore...
<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: KL and non overlapping distributions Step2: Approximation of the ratio using the f-gan approach Step3: Gradients Step4: Wasserstein distance ...
<ASSISTANT_TASK:> Python Code: import jax import random import numpy as np import jax.numpy as jnp import seaborn as sns import matplotlib.pyplot as plt import scipy !pip install -qq dm-haiku !pip install -qq optax try: import haiku as hk except ModuleNotFoundError: %pip install -qq haiku import haiku as hk...
<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 numpy as np a = [np.array([1,2,3]),np.array([1,2,3]),np.array([1,2,3])] def all_equal(iterator): try: iterator = iter(iterator) first = next(iterator) return all(np.array_equal(first, rest) for rest in iterator) except StopIteration: return 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: If you already have an H2O cluster running that you'd like to connect to (for example, in a multi-node Hadoop environment), then you can specify...
<ASSISTANT_TASK:> Python Code: import h2o # Start an H2O Cluster on your local machine h2o.init() # This will not actually do anything since it's a fake IP address # h2o.init(ip="123.45.67.89", port=54321) #csv_url = "http://www.stat.berkeley.edu/~ledell/data/eeg_eyestate_splits.csv" csv_url = "https://h2o-public-tes...
<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: Bubble sort Step2: We can see the essential features of Python used Step4: Note Step6: This gets rid of the need for a temporary variable. St...
<ASSISTANT_TASK:> Python Code: def bubblesort(unsorted): Sorts an array using bubble sort algorithm Paramters --------- unsorted : list The unsorted list Returns sorted : list The sorted list (in place) last = len(unsorted) # All Python ...
<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: Survival analysis Step3: The survival function is just the complementary CDF. Step4: Here's the CDF and SF. Step5: And here's the hazard func...
<ASSISTANT_TASK:> Python Code: from os.path import basename, exists def download(url): filename = basename(url) if not exists(filename): from urllib.request import urlretrieve local, _ = urlretrieve(url, filename) print("Downloaded " + local) download("https://github.com/AllenDowney/Thin...
<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: Why NumPy? Step2: Introduction Step3: In the numpy package the terminology used for vectors, matrices and higher-dimensional data sets is arra...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import traceback import matplotlib.pyplot as plt import numpy as np %%time total = 0 for i in range(100000): total += i %%time total = np.arange(100000).sum() %%time l = list(range(0, 1000000)) ltimes5 = [x * 5 for x in l] %%time l = np.arange(1000000) ltimes5 = ...
<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: Low frequency drifts and line noise Step2: we see high amplitude undulations in low frequencies, spanning across tens of Step3: On MEG sensors...
<ASSISTANT_TASK:> Python Code: import numpy as np import mne from mne.datasets import sample from mne.preprocessing import create_ecg_epochs, create_eog_epochs # getting some data ready data_path = sample.data_path() raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif' raw = mne.io.read_raw_fif(raw_fname, preloa...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step 1 - Creating a Checkpoint Step1: Pre-Questions Step2: This table shows the top 10 water consuming counties, the population, the amount of the pop...
<ASSISTANT_TASK:> Python Code: # Import modules that contain functions we need import pandas as pd import numpy as np %matplotlib inline import matplotlib.pyplot as plt # Our data is a table and is defined as the word 'data'. # 'data' is set equal to the .csv file that is read by the pandas function. # The .csv file mu...
<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. Initialization of setup Step2: 2. Elemental Mass and Stiffness matrices Step3: 3. Flux Matrices Step4: 4. Discontinuous Galerkin Solution
<ASSISTANT_TASK:> Python Code: # Import all necessary libraries, this is a configuration step for the exercise. # Please run it before the simulation code! import numpy as np import matplotlib.pyplot as plt from gll import gll from lagrange1st import lagrange1st from flux_homo import flux # Show the plots in the Notebo...
<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: Define helper functions Step2: Project specific parameters Step3: Iterate through subjects and runs Step4: Compute 2-way correlations
<ASSISTANT_TASK:> Python Code: import pandas as pd import json from scipy import stats, signal, linalg from sklearn.decomposition import PCA import nibabel as nib import nipype from nipype import Node, SelectFiles, DataSink, IdentityInterface import matplotlib as mpl import matplotlib.pyplot as plt mpl.use("Agg") 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: Interaction Between Neurons - Feature Visualization Step2: Combining Objectives Step3: Random Directions Step4: Aligned Interpolation
<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: Continuous data is stored in objects of type Step2: <div class="alert alert-info"><h4>Note</h4><p>Accessing the `._data` attribute is done her...
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import mne import os.path as op from matplotlib import pyplot as plt # Load an example dataset, the preload flag loads the data into memory now data_path = op.join(mne.datasets.sample.data_path(), 'MEG', 'sample', 'sample_audvis_r...
<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: Describes the tests needed to validate the PutFile functionality. Step2: Check this by running Step3: The response should be Step4: Verify th...
<ASSISTANT_TASK:> Python Code: %env CLIENT bitrepository-client-1.9-RC1 !wget -Nq "https://sbforge.org/download/attachments/25395346/${CLIENT}.zip" !unzip -quo ${CLIENT}.zip %alias bitmag ${CLIENT}/bin/bitmag.sh %l #Some imports we will need later import random import string TESTFILE1='README.md' %bitmag get-file-ids...
<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='sec1.3'></a> Step2: Extract POI category and visiting frequency. Step3: <a id='sec1.4'></a> Step5: <a id='sec1.5'></a> Step7: <a id='...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import os import math import random import pandas as pd import numpy as np import matplotlib.pyplot as plt from datetime import datetime random.seed(123456789) data_dir = 'data/data-ijcai15' #fvisit = os.path.join(data_dir, 'userVisits-Osak.csv') #fcoord = os.path.join(...
<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 parameters Step2: Compute statistic Step3: View time-frequency plots
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # # License: BSD (3-clause) import numpy as np import matplotlib.pyplot as plt import mne from mne.time_frequency import tfr_morlet from mne.stats import permutation_cluster_1samp_test from mne.datasets import sample ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step4: Objects Step5: The above construct is a class, which is to say a model for creating objects. Step6: Now we have an object called "jyry", which...
<ASSISTANT_TASK:> Python Code: class Student(object): The above states that the code-block (indented area) below will define a class Student, that derives from a class called 'object'. Inheriting from 'object' is S def __init__(self, name, birthyear, interest=None): __init__ is ...
<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: Once generate data Step2: Step 1 - collect data Step3: Step 2 - Build model Step4: Step 3 training the network Step5: One epoch takes approx...
<ASSISTANT_TASK:> Python Code: num_units = 400 #state size input_len = 60 target_len = 30 batch_size = 64 with_EOS = False total_size = 57994 train_size = 46400 test_size = 11584 data_folder = '../../../../Dropbox/data' ph_data_path = '../data/price_history' npz_full = ph_data_path + '/price_history_dp_60to30_57994.np...
<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: 在这个例子中,对已排序的 _sorted 元素逐个与 i 进行比较,若 i 比已排序的所有元素都大,则只能排在已排序列表的最后。这时我们就需要一个额外的状态变量 inserted 来标记完成遍历循环还是中途被 break,在这种情况下,我们可以用 else 来取代这一状态变量: Step...
<ASSISTANT_TASK:> Python Code: from random import randrange def insertion_sort(seq): if len(seq) <= 1: return seq _sorted = seq[:1] for i in seq[1:]: inserted = False for j in range(len(_sorted)): if i < _sorted[j]: _sorted = [*_sorted[:j], i, *_sorted[j:]...
<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. The data Step2: The resulting DataFrame contains a row for each user and each column represents an artist. The values indicate whether the u...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import sklearn.metrics.pairwise data = pd.read_csv('data/lastfm-matrix-germany.csv').set_index('user') data.head() data.shape ### BEGIN SOLUTION similarity_matrix = sklearn.metrics.pairwise.cosine_similarity(np.transpose(data)) ### END SOLUTION # 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: Comparing distributions Step2: Based on the data, the distribution for Rhode is slightly farther right than the distribution for Wei, but there...
<ASSISTANT_TASK:> Python Code: # Configure Jupyter so figures appear in the notebook %matplotlib inline # Configure Jupyter to display the assigned value after an assignment %config InteractiveShell.ast_node_interactivity='last_expr_or_assign' # import classes from thinkbayes2 from thinkbayes2 import Hist, Pmf, Suite, ...
<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 show the symbols data, to see how good the recommender has to be. Step2: Let's run the trained agent, with the test set Step3: And now a...
<ASSISTANT_TASK:> Python Code: # Basic imports import os import pandas as pd import matplotlib.pyplot as plt import numpy as np import datetime as dt import scipy.optimize as spo import sys from time import time from sklearn.metrics import r2_score, median_absolute_error from multiprocessing import Pool import pickle %...
<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: What do we mean when we say local scope? Step2: What would change if you added the line global name into the function update_name?
<ASSISTANT_TASK:> Python Code: initial_var = 358645317684531432678 name = "Oi, you there" def update_name(): name = "what?" print(name) update_name() print(name) num_one = None num_two = None def power(one, two): pass from nose.tools import assert_equal, assert_not_equal assert_equal(square(12,2), 144) 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: Here's the Rosenbrock function in code. Since we're pretending it's the log-posterior, I've introduced a minus sign that doesn't normally appear...
<ASSISTANT_TASK:> Python Code: from IPython.display import Image Image(filename="DifficultDensities_banana_eg.png", width=350) def Rosenbrock_lnP(x, y, a=1.0, b=100.0): return -( (a-x)**2 + b*(y-x**2)**2 ) import numpy as np import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = (8.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: As always, let's do imports and initialize a logger and a new Bundle. See Building a System for more details. Step2: Dataset Parameters Step3:...
<ASSISTANT_TASK:> Python Code: !pip install -I "phoebe>=2.0,<2.1" %matplotlib inline import phoebe from phoebe import u # units import numpy as np import matplotlib.pyplot as plt logger = phoebe.logger() b = phoebe.default_binary() ps, constraints = phoebe.dataset.orb() print ps print ps['times'] ps_compute = phoeb...
<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: mod = 1000000007 def waysToColor(arr , n , k ) : global mod powOf2 =[0 for i in range(500 ) ] c =[[ 0 for i in range(500 ) ] for j in range(500 ) ] for i in range(n + 1 ) : c[i ][0 ] = 1 ; for j in range(1 , i + 1 ) : c[i ][j ] =(c[i - 1 ][j ] + c[i - 1 ][j - 1 ] ) % mo...
<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 matrix arithmetics like Step2: In mathematics, the dot product is an algebraic operation that takes two coordinate vectors of equal size ...
<ASSISTANT_TASK:> Python Code: import numpy as np x = np.array([1,5,2]) y = np.array([7,4,1]) x + y x * y x - y x / y x % y x = np.array([1,2,3]) y = np.array([-7,8,9]) dot = np.dot(x,y) np.dot(x,y) x = np.array( ((2,3), (3, 5)) ) y = np.array( ((1,2), (5, -1)) ) x * y x = np.matrix( ((2,3), (3, 5)) ) y = np.matrix(...
<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: Setup the axon code Step3: Single example axon, how does a0 (intial volage) drift with the number of nodes? Step4: Now let's run axon for a fe...
<ASSISTANT_TASK:> Python Code: import pylab as plt import numpy as np %matplotlib inline from __future__ import division from scipy.integrate import odeint,ode from numpy import zeros,ones,eye,tanh,dot,outer,sqrt,linspace,cos,pi,hstack,zeros_like,abs,repeat from numpy.random import uniform,normal,choice %config InlineB...
<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 and import TFX Step2: Please ignore the incompatibility error and warnings. Make sure to re-run the cell. Step3: Import the MLMD libra...
<ASSISTANT_TASK:> Python Code: !pip install --upgrade pip !pip install -q -U tfx import os import tempfile import urllib import pandas as pd import tensorflow_model_analysis as tfma from tfx.orchestration.experimental.interactive.interactive_context import InteractiveContext from tfx import v1 as tfx print('TFX vers...
<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: Upper air data can be obtained using the siphon package, but for this example we will use Step2: We will pull the data out of the example datas...
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import pandas as pd import metpy.calc as mpcalc from metpy.cbook import get_test_data from metpy.plots import add_metpy_logo, SkewT from metpy.units import units col_names = ['pressure', 'height', 'temperature', 'dewpoint', 'direction', 'speed'] df = pd.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: Make performance scorers Step2: Sequential Feature Selection with mlextend Step3: The next cell will take many hours to run, skip it Step4: R...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt from sklearn import preprocessing from sklearn.metrics import f1_score, accuracy_score, make_scorer filename = 'engineered_features.csv' training_data = pd.read_csv(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: Load Boston Housing Dataset Step2: Create Decision Tree Step3: Train Model Step4: Create Observation To Predict
<ASSISTANT_TASK:> Python Code: # Load libraries from sklearn.tree import DecisionTreeRegressor from sklearn import datasets # Load data with only two features boston = datasets.load_boston() X = boston.data[:,0:2] y = boston.target # Create decision tree classifer object regr = DecisionTreeRegressor(random_state=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: Restart the kernel Step2: Before you begin Step3: Region Step4: Timestamp Step5: Authenticate your Google Cloud account Step6: Create a Clo...
<ASSISTANT_TASK:> Python Code: import os # The Vertex AI Workbench Notebook product has specific requirements IS_WORKBENCH_NOTEBOOK = os.getenv("DL_ANACONDA_HOME") IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists( "/opt/deeplearning/metadata/env_version" ) # Vertex AI Notebook requires dependencies to be install...
<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: IPython Console Step2: IPython Qt Console Step3: IPython.parallel
<ASSISTANT_TASK:> Python Code: from IPython.display import display, Image, HTML from talktools import website, nbviewer Image('images/ipython_console.png') Image('images/ipython_qtconsole.png') Image("images/ParallelKernels.png", width="80%") <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: 10 Palavras Mais Frequentes Step2: n-Grams Step3: TF-IDF com CountVectorizer
<ASSISTANT_TASK:> Python Code: # Bibliotecas from pyspark.ml import Pipeline from pyspark.ml.feature import Tokenizer, StopWordsRemover, CountVectorizer, NGram livro = sc.textFile("Machado-de-Assis-Memorias-Postumas.txt") text = "" for line in livro.collect(): text += " " + line data = spark.createDataFrame([(0, te...
<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: Run as a Python module Step2: Training should finish in just a few seconds because it ran outside of the Jupyter's runtime, as an independent p...
<ASSISTANT_TASK:> Python Code: import os PROJECT = 'my-project-id' # REPLACE WITH YOUR PROJECT ID BUCKET = 'my-bucket-name' # REPLACE WITH YOUR BUCKET NAME REGION = 'us-central1' # REPLACE WITH YOUR BUCKET REGION e.g. us-central1 MODEL_TYPE='dnn' # 'dnn' or 'cnn' # do not change these os.environ['PROJECT'] = PROJECT ...
<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 SciPy, the definition of the negative binomial distribution differs a little from the one in our introduction. They define $Y$ = Number of fa...
<ASSISTANT_TASK:> Python Code: import arviz as az import bambi as bmb import matplotlib.pyplot as plt import numpy as np import pandas as pd from scipy.stats import nbinom az.style.use("arviz-darkgrid") import warnings warnings.simplefilter(action='ignore', category=FutureWarning) y = np.arange(0, 30) k = 3 p1 = 0.5 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: 1) Data Source and Data Usage Step2: From this data we calculated two key metrics which will be useful in determining which of these three arti...
<ASSISTANT_TASK:> Python Code: import sys # system module import pandas as pd # data package import matplotlib as mpl # graphics package import matplotlib.pyplot as plt # pyplot module import datetime as dt # date and time module 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: Even before you call your first TensorFlow function, a lot is going on behind the scenes. For example, an empty default graph object is created....
<ASSISTANT_TASK:> Python Code: import tensorflow as tf g = tf.get_default_graph() g g.get_operations() tf.constant(3.14) g.get_operations() const_operation = g.get_operations()[0] len(const_operation.inputs), len(const_operation.outputs) const_tensor = const_operation.outputs[0] const_tensor another_const_tensor ...
<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 bloque anterior se ejecuta en python y mantiene una conexión a una instancia de interprete interactivo de python, de manera que podemos usar ...
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division # Compatibilidad entre python 2 y 3 def imprime_division(a, b): print(a/b) imprime_division(4, 5) %%latex $\left(\frac{1}{\Gamma}\right)^{2}$ !ls -al %%bash touch archivoprueba.txt ls *.txt echo "Ya se verifico creación, ahora se elim...
<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: If we need only the keys 'a' and 'd', we can do this Step2: We can also specify 'subkeys' by using a dotted-syntax Step3: The dotted-syntax ca...
<ASSISTANT_TASK:> Python Code: d = { 'a': 'A', 'b': 'B', 'c': 'C', 'd': { 'x': 'D_X', 'y': 'D_Y', 'z': { 'I': 'D_Z_I', 'II': { '1': 'D_Z_II_1', '2': 'D_Z_II_2' }, 'III': 'D_Z_III' } } } 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: Step 4 Step2: Step 5 Step3: There should be 9 containers running Step4: Step 7 Step5: There should be an additional 5 containers running Ste...
<ASSISTANT_TASK:> Python Code: cd ~/nexus/esip-workshop/docker/infrastructure docker-compose up -d cassandra1 docker logs -f cassandra1 docker-compose up -d docker ps cd ~/nexus/esip-workshop/docker/analysis docker-compose up -d docker ps cd ~/nexus/esip-workshop/docker/ingest docker-compose up -d docker ps dock...
<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 we define the parameters that we use to extract all the informations from the vtk file Step2: Now we initialize the file_handler that deal...
<ASSISTANT_TASK:> Python Code: import ezyrb as ez output_name = 'Pressure' weights_name = 'Weights' namefile_prefix = '../tests/test_datasets/matlab_0' file_format = '.vtk' file_handler = ez.pod.Pod(output_name, weights_name, namefile_prefix, file_format) file_handler.start() while True: add = input('Add a new 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: Notarás por el número a la izquierda (el número 1) que esa celda es diferente. Ese número significa que es el primero output o salida del progra...
<ASSISTANT_TASK:> Python Code: import numpy as np # Alias es np import matplotlib.pyplot as plt # Alias es plt T_init = 0.0 # Tiempo inicial Tmax = 10.0 # Tiempo Total dt= 2.0 # Salto tiempos = np.arange(T_init, Tmax, dt) print tiempos T_init = 2.0 # Tiempo inicial Tmax = 8.0 # Tiempo Total dt= 1.0 # Salto...
<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', 'uhh', 'sandbox-1', 'seaice') # 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: Remise à zero(angle) Affichage et changement de l'id d'un moteur.
<ASSISTANT_TASK:> Python Code: ports = pypot.dynamixel.get_available_ports() if not ports: raise IOError('no port found!') print "Ports founds %s" % ports for port in ports: print('Connecting on port:', port) dxl_io = pypot.dynamixel.DxlIO(port) motors = dxl_io.scan() print(" %s motors founds :...
<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: Part 1 Step2: To cluster the images, we'll need to convert the images into a format we can pass into our KMeans model, which expects 1D feature...
<ASSISTANT_TASK:> Python Code: !pip install datacommons --upgrade --quiet !pip install datacommons_pandas --upgrade --quiet import datacommons import datacommons_pandas import numpy as np import pandas as pd # for visualization import matplotlib.pyplot as plt import seaborn as sns # for clustering from sklearn.cluster ...
<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 open() function opens a given filename as an object in 'read mode'. Step2: To open a file in write mode, pass the w parameter to the open()...
<ASSISTANT_TASK:> Python Code: import os os.listdir(os.path.abspath('files')) dictionaryFile = open(os.path.abspath('files/dictionary.txt')) # Open the file print(dictionaryFile.read()) # Read the file print(dictionaryFile.readline()) # Read a line in the file until newline or EOF content = dictionaryFile.read() # Sto...
<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: Introduction Step14: Training Step15: Start training. Training takes about 20 ~ 30 minutes on a n1-standard-1 GCP VM. Step16: In epoch 1, the...
<ASSISTANT_TASK:> Python Code: # Download and unzip data. !mkdir -p /content/datalab/punctuation/tmp !mkdir -p /content/datalab/punctuation/data !mkdir -p /content/datalab/punctuation/datapreped !wget -q -P /content/datalab/punctuation/tmp/ https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/corpora/euro...
<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: Validate lab package version installation Step2: Note Step3: Note Step4: The config.py module configures the default values for the environme...
<ASSISTANT_TASK:> Python Code: import yaml # Set `PATH` to include the directory containing TFX CLI and skaffold. PATH=%env PATH %env PATH=/home/jupyter/.local/bin:{PATH} !python -c "import tfx; print('TFX version: {}'.format(tfx.__version__))" !python -c "import kfp; print('KFP version: {}'.format(kfp.__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: Are there certain populations we're not getting reports from? Step2: From the data, it seems that there's not much underrepresentation by gende...
<ASSISTANT_TASK:> Python Code: import pickle import operator import numpy as np import pandas as pd import gensim.models data = pickle.load(open('/home/datauser/cpsc/data/processed/cleaned_api_data', 'rb')) data.head() pd.crosstab(data['GenderDescription'], data['age_range']) #removing minor harm incidents no_injuri...
<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: <center>Find Simulations and Load data Step2: <center>Recompose the Waveforms Step3: <center>Plot the amplitudes to verify correct scaling bet...
<ASSISTANT_TASK:> Python Code: # Setup ipython environment %load_ext autoreload %autoreload 2 %matplotlib inline # Setup plotting backend import matplotlib as mpl mpl.rcParams['lines.linewidth'] = 0.8 mpl.rcParams['font.family'] = 'serif' mpl.rcParams['font.size'] = 12 mpl.rcParams['axes.labelsize'] = 20 from matplotli...
<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: Language Translation Step3: Explore the Data Step6: Implement Preprocessing Function Step8: Preprocess all the data and save it Step10: Chec...
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper import problem_unittests as tests source_path = 'data/small_vocab_en' target_path = 'data/small_vocab_fr' source_text = helper.load_data(source_path) target_text = helper.load_data(target_path) view_sentence_range = (0, 10) DON'T MODIFY AN...
<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. When to use Python? Step2: 5. Python as a calculator Step3: 6. Variables & Types Step4: 7. Variable Assignment Step5: 8. Calculations wit...
<ASSISTANT_TASK:> Python Code: # Example, do not modify! print(5 / 8) # Put code below here print(7 + 10) # Just testing division print(5 / 8) # Addition works too print(7 + 10) # Addition and subtraction print(5 + 5) print(5 - 5) # Multiplication and division print(3 * 5) print(10 / 2) # Exponentiation print(4 ** 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: Numpy has a really handy built-in function for padding images called pad. The required inputs are the array to be padded, the size of the pad re...
<ASSISTANT_TASK:> Python Code: # The standard fare: import numpy as np import matplotlib.pyplot as plt import pandas as pd %matplotlib inline # Recall our use of this module to work with FITS files in Lab 4: from astropy.io import fits #A dummy image - just a Gaussian PSF with a standard deviation of 5 pixels import 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: Target distribution Step2: Heat bath Step3: SA algorithm Step4: Run experiments
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib matplotlib.use("nbagg") import matplotlib.pyplot as plt from IPython import display from mpl_toolkits.mplot3d import Axes3D !mkdir figures !mkdir scripts %cd /content/scripts !wget -q https://raw.githubusercontent.com/probml/pyprobml/master/scripts/pyp...
<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 section specific modules Step3: 1.9 A brief introduction to interferometry and its history Step4: This function draws a double-slit set...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline from IPython.display import HTML HTML('../style/course.css') #apply general CSS from IPython.display import display from ipywidgets import interact HTML('../style/code_toggle.html') def double_slit (p0=[0],a0=[1],bas...