Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
12,500
<ASSISTANT_TASK:> Python Code: !pip install dicttoxml import json from dicttoxml import dicttoxml PETS = {} PET_STATUS_INDEX = {} TAG_INDEX = {} ORDERS = {} ORDER_STATUS_INDEX = {} JSON = 'application/json' XML = 'application/xml' content_type = JSON class MissingField(Exception): def __init__(self, type_name, fie...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: POST /pet Step2: PUT /pet Step3: GET /pet/findByStatus Step4: GET /pet/findByTags Step5: GET /pet/ Step6: POST /pet/ Step7: DELETE /pet/ S...
12,501
<ASSISTANT_TASK:> Python Code: # Imports import os import sys import pandas as pd import seaborn as sb # Custom Imports sys.path.insert(0, '../../') import stats_toolbox as st from stats_toolbox.utils.data_loaders import load_fem_preg_2002 # Graphics setup %pylab inline --no-import-all sb.set_context('notebook', font_...
<SYSTEM_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 Step2: Constructing Histograms Step3: Getting frequencies for values Step4: or equivilantly Step5: Visualising Step6: By default ...
12,502
<ASSISTANT_TASK:> Python Code: %pylab notebook VS = 230.0 # Secondary voltage (V) amps = arange(0, 65.2, 6.52) # Current values (A) Req = 0.0445 # Equivalent R (ohms) Xeq = 0.0645 # Equivalent X (ohms) I = amps * array ([[0.8 - 0.6j], # Lagging [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: Define all the parameters Step2: Calculate the current values for the three power factors. Step3: Calculate VP/a Step4: Calculate voltage reg...
12,503
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 '''step 1''' # Load all necessary modules here, for clearness import torch import numpy as np import torch.nn as nn import torch.nn.functional as F import torch.optim as optim # from torchvision.datasets import MNIST import torchvision from torchvision ...
<SYSTEM_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.1 Commonly required module Step2: 1.2 Random seed setting for reproducibility Step3: 2. Data split and Cross Validatioin Step5: 2.2 Calcula...
12,504
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import pandas as pd %matplotlib inline !wget --no-check-certificate https://openaq-data.s3.amazonaws.com/2018-04-06.csv -P /Users/nipun/Downloads/ import pandas as pd df = pd.read_csv("/Users/nipun/Downloads/2018-04-06.csv") df = df[(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: Downloading data from OpenAQ for 2018-04-06 Step2: Downloading World GeoJson file Step3: Creating india.json correspdonding to Indian data
12,505
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import sqlite3 import pandas as pd import seaborn as sns sns.set_style("white") conn = sqlite3.connect('../data/output/database.sqlite') c = conn.cursor() def execute(sql): ''' Executes a SQL command on the 'c' cursor and returns ...
<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: Current visualization ideas Step6: Odd outliers throughout needs to be explored and cleaned more
12,506
<ASSISTANT_TASK:> Python Code: import pandas as pd pd.__version__ import matplotlib.pyplot as plt import matplotlib matplotlib.__version__ pump_df = pd.read_csv('https://raw.githubusercontent.com/yy/dviz-course/master/data/pumps.csv') pump_df.head() # TODO: write your code here # Your code here len(pump_df) 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: You can check the version of the library. Because pandas is fast-evolving library, you want to make sure that you have the up-to-date version of...
12,507
<ASSISTANT_TASK:> Python Code: ##importing python module import os import pandas import numpy import gseapy import mygene import ipywidgets import qgrid import urllib2 qgrid.nbinstall(overwrite=True) qgrid.set_defaults(remote_js=True, precision=4) from IPython.display import IFrame import matplotlib.image as mpimg 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: Read in differential expression results as a Pandas data frame to get differentially expressed gene list Step2: Translate Ensembl IDs to Gene S...
12,508
<ASSISTANT_TASK:> Python Code: from datetime import datetime datetime(year=2015, month=7, day=4) from dateutil import parser date = parser.parse("4th of July, 2015") date date.strftime('%A') import numpy as np date = np.array('2015-07-04', dtype=np.datetime64) date date + np.arange(12) np.datetime64('2015-07-04') ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Or, using the dateutil module, you can parse dates from a variety of string formats Step2: Once you have a datetime object, you can do things l...
12,509
<ASSISTANT_TASK:> Python Code: import epoxpy from epoxpy.lib import A a = A() a.visualize(show_ports=True) from epoxpy.lib import C10 c10 = C10() c10.visualize(show_ports=True) from epoxpy.lib import Epoxy_A_10_B_20_C10_2_Blend import mbuild as mb import random random.seed(1024) blend = Epoxy_A_10_B_20_C10_2_Blend() ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Particle C10 Step2: Epoxy blend (10 A's, 20 B's and 2 C10's)
12,510
<ASSISTANT_TASK:> Python Code: import rebound import numpy as np sim = rebound.Simulation() OMEGA = 0.00013143527 # [1/s] sim.ri_sei.OMEGA = OMEGA surface_density = 400. # kg/m^2 particle_density = 400. # kg/m^3 sim.G = 6.67428e-11 # N m^2 / kg^2 sim.dt = 1e-3*2.*np.pi/OMEGA sim.softening = 0.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: Next up, setting up several constants. We will be simulating a shearing sheet, a box with shear-periodic boundary conditions. This is a local ap...
12,511
<ASSISTANT_TASK:> Python Code: from datetime import datetime,timedelta, time import pandas as pd import numpy as np import matplotlib.pyplot as plt from data_helper_functions import * from IPython.display import display pd.options.display.max_columns = 999 %matplotlib inline desired_channel = 'BAND_01' desired_date = d...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Build up sensor to pvoutput model Step2: ...finally ready to model! Step3: Linear model Step4: When only keeping the photometer data, random ...
12,512
<ASSISTANT_TASK:> Python Code: def do_something(arg1, arg2): A short sentence describing what this function does. More description Parameters ---------- arg1 : type1 Description of the parameter ``arg1`` arg2 : type2 Description of the parameter ``arg2`` ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Documenting Code Step2: 1b Step3: 1c Step6: 1d Step7: 1e Step8: Problem 2 Step9: 2b Step10: 2c Step11: You should see various files have...
12,513
<ASSISTANT_TASK:> Python Code: import iris import numpy as np import holoviews as hv import holocube as hc from cartopy import crs from cartopy import feature as cf hv.notebook_extension() %%output size=400 feats = [cf.LAND, cf.OCEAN, cf.RIVERS, cf.LAKES, cf.BORDERS, cf.COASTLINE] features = hv.Overlay([hc.GeoFeature(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Plotting with projections Step2: Below is the full list of cartopy projections that can be displayed using matplotlib. Step3: We can test the ...
12,514
<ASSISTANT_TASK:> Python Code: import warnings warnings.filterwarnings('ignore') import pandexo.engine.justdoit as jdi import numpy as np import os exo_dict = jdi.load_exo_dict('HD 189733 b') exo_dict['observation']['sat_level'] = 80 #saturation level in percent of full well exo_dict['observation']['sat_unit'] =...
<SYSTEM_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 Exo Dict for Specific Planet Step2: Edit exoplanet observation inputs Step3: Edit exoplanet inputs using one of three options Step4: 2)...
12,515
<ASSISTANT_TASK:> Python Code: import torch @torch.jit.script def activation_cell(cx): return torch.tanh(cx) # note takes non-parameter jit.script functions activation_cell from context at definition time! (Probably will want to do this in a factory style function even if it's not 100% Pythonic) @torch.jit.script ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Functional Interfacefor a Cell
12,516
<ASSISTANT_TASK:> Python Code: #import our modules from __future__ import print_function import fwdpy as fp import numpy as np import datetime import time #set up our sim rng = fp.GSLrng(101) nregions = [fp.Region(0,1,1),fp.Region(2,3,1)] sregions = [fp.ExpS(1,2,1,-0.1),fp.ExpS(1,2,0.1,0.001)] rregions = [fp.Region(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: Calculating sliding windows Step2: Using pylibseq
12,517
<ASSISTANT_TASK:> Python Code: # Import modules you might use import numpy as np # Some data, in a list my_data = [12, 5, 17, 8, 9, 11, 21] # Function for calulating the mean of some data def mean(data): # Initialize sum to zero sum_x = 0.0 # Loop over data for x in data: # Add to sum su...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Notice that, rather than using parentheses or brackets to enclose units of code (such as loops or conditional statements), python simply uses in...
12,518
<ASSISTANT_TASK:> Python Code: !rm mnist_data.mat && wget https://github.com/KordingLab/lab_teaching_2015/raw/master/session_2/mnist_data.mat import numpy as np from scipy.io import loadmat mnist = loadmat('mnist_data.mat') X = mnist['X'] y = mnist['y'] print("Size of X and y: ", X.shape, y.shape) def sigmoid(z): g...
<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: Back propagation algorithm Step4: Work flow for computing final $\Theta_1, \Theta_2$ Step5: Analyzing weights
12,519
<ASSISTANT_TASK:> Python Code: def multiplek(y_test, topk): multik = [] for i, score in enumerate(y_test): if y_test[i] in topk[i]: multik.append(y_test[i]) else: multik.append(topk[i][0]) return multik pred = grid.predict(X_test.ravel()) # predicts a category p_pro...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Predicting top 3 categories Step2: The function below brings all the steps above so it can be applied to the X_test set. Step3: The function b...
12,520
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division import numpy import scipy.stats import matplotlib.pyplot as pyplot from ipywidgets import interact, interactive, fixed import ipywidgets as widgets # seed the random number generator so we all get the same results numpy.random.seed(18) # som...
<SYSTEM_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 One Step2: Here's what that distribution looks like Step3: make_sample draws a random sample from this distribution. The result is a Num...
12,521
<ASSISTANT_TASK:> Python Code: %%bash git --help %%bash git clone https://github.com/cosmoscalibur/herramientas_computacionales.git herramientas %%bash cd herramientas ls -oha %%bash cd herramientas git remote -v %%bash cd herramientas git init %%bash cd herramientas git remote add pruebas https://github.com/cosmo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Configuración Step2: De esta forma crearemos una copia del repositorio git herramientas_computacionales en el directorio ./herramientas. Si no ...
12,522
<ASSISTANT_TASK:> Python Code:: import cv2 %matplotlib notebook %matplotlib inline from matplotlib import pyplot as plt img = cv2.imread("hsv_ball.jpg",cv2.IMREAD_GRAYSCALE) _,mask = cv2.threshold(img, 220,255,cv2.THRESH_BINARY_INV) titles = ['images',"mask"] images = [img,mask] for i in range(2): plt.subplot(1,2,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:
12,523
<ASSISTANT_TASK:> Python Code: import math import time import diffrax import equinox as eqx # https://github.com/patrick-kidger/equinox import jax import jax.nn as jnn import jax.numpy as jnp import jax.random as jrandom import jax.scipy as jsp import matplotlib import matplotlib.pyplot as plt import optax # https://...
<SYSTEM_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 let's define the vector field for the CDE. Step2: Now wrap up the whole CDE solve into a model. Step3: Toy dataset of spirals. Step4: T...
12,524
<ASSISTANT_TASK:> Python Code: import sys import pandas as pd # check out Modin https://towardsdatascience.com/get-faster-pandas-with-modin-even-on-your-laptops-b527a2eeda74 import numpy as np import json import matplotlib.pyplot as plt import seaborn as sns from pathlib import Path import datetime # Add path to APS 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: Check if there are missing values. Step2: Fill missing values where necessary. Step3: Feature engineering Step4: Add historical values, e.g. ...
12,525
<ASSISTANT_TASK:> Python Code: import logging import numpy as np import pandas as pd import matplotlib.pyplot as plt root = logging.getLogger() root.addHandler(logging.StreamHandler()) %matplotlib inline # download from Google Drive: https://drive.google.com/open?id=0B9cazFzBtPuCOFNiUHYwcVFVODQ # Representative exampl...
<SYSTEM_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. Choose a representative species for a case study Step2: 2. Rasterize the species, to get a matrix of pixels Step3: 2.1 Plot to get an idea ...
12,526
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception !python -m pip install iree-compiler iree-runtime iree-tools-tf -f https://github.com/google/iree/rel...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Image edge detection module Step2: High Level Compilation With IREE Step3: Low-Level Compilation
12,527
<ASSISTANT_TASK:> Python Code: import featuretools as ft es = ft.demo.load_mock_customer(return_entityset=True) feature_defs = ft.dfs(entityset=es, target_dataframe_name="customers", agg_primitives=["mean", "sum", "mode", "n_most_common"], trans_primitiv...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: By default, describe_feature uses the existing column and DataFrame names and the default primitive description templates to generate feature de...
12,528
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib as mpl import plotnine as p9 import matplotlib.pyplot as plt import itertools import warnings warnings.simplefilter("ignore") from sklearn import neighbors, preprocessing, impute, metrics, model_selection, linear_model, svm, feature...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: Classification 1 Step4: Evaluating a classifier Step5: Confusion matrix and metrics
12,529
<ASSISTANT_TASK:> Python Code: import numpy as np import os from operator import itemgetter from collections import Counter import scipy.stats as stat from gensim.models import Word2Vec from nltk import corpus import FastGaussianLDA2 wvmodel = Word2Vec.load_word2vec_format( "/Users/michael/Documents/Gaussian_LDA-m...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Loading the word_vector model with GenSim Step2: Sets of vocab to filter on Step3: Document cleaning
12,530
<ASSISTANT_TASK:> Python Code: class Pessoa(object): def __init__(self, nome, idade): self.nome = nome self.idade = idade joao = Pessoa() joao = Pessoa('João', 20) print(joao, '\n') print(joao.nome) print(joao.idade) joao.nome = 'João Pedro' print(joao.nome) maria = Pessoa('Maria', 20) print(maria) ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Encapsulamento Step2: Desta forma não conseguimos recuperar e nem alterar o valor dessa variável privada. Para isso precisamos construir dois m...
12,531
<ASSISTANT_TASK:> Python Code: # I import useful libraries (with functions) so I can visualize my data # I use Pandas because this dataset has word/string column titles and I like the readability features of commands and finish visual products that Pandas offers import pandas as pd import matplotlib.pyplot as plt impor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Uploaded data into Python¶ Step2: Next Step3: These data points can be plotted on top of a calculated pitch line Step4: I now have an input (...
12,532
<ASSISTANT_TASK:> Python Code: # NBVAL_IGNORE_OUTPUT import numpy as np import matplotlib.pyplot as plot import math as mt import matplotlib.ticker as mticker from mpl_toolkits.axes_grid1 import make_axes_locatable from matplotlib import cm # NBVAL_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: From Devito's library of examples, we import some specific functions, such as Step2: Previously we used the expression configuration ['log-leve...
12,533
<ASSISTANT_TASK:> Python Code: import word2vec word2vec.word2phrase('./text8', './text8-phrases', verbose=True) word2vec.word2vec('./text8-phrases', './text8.bin', size=100, verbose=True) word2vec.word2clusters('./text8', './text8-clusters.txt', 100, verbose=True) import word2vec model = word2vec.load('./text8.bin...
<SYSTEM_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 word2phrase to group up similar words "Los Angeles" to "Los_Angeles" Step2: This will create a text8-phrases that we can use as a better in...
12,534
<ASSISTANT_TASK:> Python Code: names = ['foo','bar','rf'] dates = pd.date_range(start='2015-01-01',end='2018-12-31', freq=pd.tseries.offsets.BDay()) n = len(dates) rdf = pd.DataFrame( np.zeros((n, len(names))), index = dates, columns = names ) np.random.seed(1) rdf['foo'] = np.random.normal(loc = 0.1/252,sc...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Build and run Target Strategy Step2: Now use the PTE rebalance algo to trigger a rebalance whenever predicted tracking error is greater than 1%...
12,535
<ASSISTANT_TASK:> Python Code: x=5 print(x) import numpy as np def sin_signal(t, omega=0.1, t0=0.): A sinusoidal signal signal = np.sin(omega * (t-t0)) return signal # let's try t = np.linspace(0., 100., 10) # The output of the last entry in a cell gets printed sin_signal(t) # Sometimes, the output is too...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Hi this is normal text Step3: We can define functions and call them later Step4: The output can be suppressed adding a ";" at the end of the c...
12,536
<ASSISTANT_TASK:> Python Code: import graphlab as gl import re import matplotlib.pyplot as plt gl.canvas.set_target('ipynb') %matplotlib inline amazon = gl.SFrame.read_csv('Amazon.csv', verbose=False) google = gl.SFrame.read_csv('GoogleProducts.csv', verbose=False) truth = gl.SFrame.read_csv('Amzon_GoogleProducts_perfe...
<SYSTEM_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="eval"></a> Evaluation functions Step2: <a id="model"></a> Record Linker model Step3: <a id="feature"></a> Feature Engineering Step4: <...
12,537
<ASSISTANT_TASK:> Python Code: from pymldb import Connection mldb = Connection("http://localhost/") print mldb.put('/v1/procedures/import_rcp', { "type": "import.text", "params": { "headers": ["user_id", "recipe_id"], "dataFileUrl": "file://mldb/mldb_test_data/favorites.csv.gz", "output...
<SYSTEM_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 sequence of procedures below is based on the one explained in the Mapping Reddit demo notebook. Step2: We then train an SVD decomposition a...
12,538
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'sandbox-3', 'aerosol') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "em...
<SYSTEM_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...
12,539
<ASSISTANT_TASK:> Python Code: from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", reshape=False) X_train, y_train = mnist.train.images, mnist.train.labels X_validation, y_validation = mnist.validation.images, mnist.validation.labels X_test, y_test ...
<SYSTEM_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 MNIST data that TensorFlow pre-loads comes as 28x28x1 images. Step2: Visualize Data Step3: Preprocess Data Step4: Setup TensorFlow Step5:...
12,540
<ASSISTANT_TASK:> Python Code: import logging logging.basicConfig(level = logging.INFO) import smurff import numpy as np import scipy.sparse as sp def gen_matrix(shape, num_latent, density = 1.0 ): Generate a matrix by multipling two factors. Sparsify if asked. X = np.random.normal(size=(shape[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: Out-of-matrix prediction using synthetic data Step2: Train the model Step3: Make a PredictSession Step4: Out-of-matrix prediction using side-...
12,541
<ASSISTANT_TASK:> Python Code: !ls -lh ../data/reads !gunzip -c ../data/reads/mutant1_OIST-2015-03-28.fq.gz | head -8 !fastqc ../data/reads/mutant1_OIST-2015-03-28.fq.gz from IPython.display import IFrame IFrame('../data/reads/mutant1_OIST-2015-03-28_fastqc.html', width=1000, height=1000) import gzip from Bio import...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We see that there are five files four of these are mutants, and and one reference original sample. Step2: Each read in the fastq file format ha...
12,542
<ASSISTANT_TASK:> Python Code: %pylab inline %matplotlib inline import os SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data') from scipy.io import loadmat from shogun import features, MulticlassLabels, Math # load the dataset dataset = loadmat(os.path.join(SHOGUN_DATA_DIR, 'multiclass/usps.mat')) Xall = 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: Creating the autoencoder Step2: Pre-training Step3: Fine-tuning Step4: Evaluation Step5: The figure shows the corrupted examples and their r...
12,543
<ASSISTANT_TASK:> Python Code: import pandas as pd df_red = pd.read_csv("data/winequality-red.csv",sep=";") df_white = pd.read_csv("data/winequality-white.csv",sep=";") # Add the type column df_red['type'] = 1 df_white['type'] = 0 df = pd.concat([df_red,df_white], axis=0) df.describe() import matplotlib.pyplot as plt ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Las variables de entrada utilizadas se basan en pruebas fisioquímicas de los vinos y corresponden a Step2: Se puede notar la existencia de una ...
12,544
<ASSISTANT_TASK:> Python Code: import numpy as np a = np.zeros(9).reshape(3,3) # 3 x 3 matrix filled with zeros print(a) print(a.dtype) a1 = np.zeros((3, 3)) # same matrix, note the tuple parameter b = np.random.rand(6) # random numbers between 0-1 print(b) a1 = np.full((3, 4), 8) print(a1) i = np.eye(4)...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Creating and filling arrays Step2: Vector filled with random number. Step3: Matrix filled with constant. Step4: Identity matrix. Step5: Crea...
12,545
<ASSISTANT_TASK:> Python Code: import os from pathlib import Path testfolder = str(Path().resolve().parent.parent / 'bifacial_radiance' / 'TEMP' / 'Tutorial_11') if not os.path.exists(testfolder): os.makedirs(testfolder) print ("Your simulation will be stored in %s" % testfolder) from bifacial_radiance import...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: If desired, you can view the Oct file at this point Step2: And adjust the view parameters, you should see this image. Step3: View the geometry...
12,546
<ASSISTANT_TASK:> Python Code: import sympy from sympy import * from sympy.abc import x, n, z, t, k init_printing() # for nice printing, a-la' TeX %run "sums.py" # duplicated code, put it into "sums.py" def expand_sum_in_eq(eq_term): lhs, rhs = eq_term.lhs, eq_term.rhs return Eq(lhs, expand_Sum(rhs)) f = 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: Since coefficient in the triangle on the rhs are a part of Pascal triangle, namely A104712, the following is a generalization Step2: again, fib...
12,547
<ASSISTANT_TASK:> Python Code: x = [1,2,3] lambda x: max(x) a = range(-5,5) ## with builtins b = map(abs,a) c = [abs(x) for x in a] print b==c,b ## with your own function b = [x**2 for x in a] print b==c,b import types ## filter a = ['', 'fee', '', '', '', 'fi', '', '', '', '', 'foo', '', '', '', '', '', 'fum'] b = 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: Simple list comprehensions Step2: Filtering list comprehensions Step3: Nested list comprehensions Step4: Having fun with Zip
12,548
<ASSISTANT_TASK:> Python Code: def greetings(f): print(f) def wrapper(*args, **kwargs): print("dekorator foo mówi: ", "Hello world!") return f(*args, **kwargs) return wrapper @greetings def foo(a, b): print(a, b) print("Foo function") def bar(): pass foo(4...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <h1><center>?</center></h1> Step3: moduł functools Step4: singledispatch Step5: lru_cache (least recently used) Step6: partial
12,549
<ASSISTANT_TASK:> Python Code: print('Hello, world') # This is a code cell my_variable = 5 print(my_variable) import hail as hl from bokeh.io import output_notebook, show hl.init() output_notebook() hl.utils.get_1kg('data/') ! ls -1 data/ hl.import_vcf('data/1kg.vcf.bgz').write('data/1kg.mt', overwrite=True) mt...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Modes Step2: This is a markdown cell, so even if something looks like code (as below), it won't get executed! Step3: Common gotcha Step4: Now...
12,550
<ASSISTANT_TASK:> Python Code: # python standard library from fractions import Fraction spam = 'offer is secret, click secret link, secret sports link'.split(',') print(len(spam)) ham = 'play sports today, went play sports, secret sports event, sports is today, sports costs money'.split(',') print(len(ham)) class Mail...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step12: The terms have to be changed to be either all plural or all singular. In this case I changed 'sport' to 'sports' where needed. Step16: SpamDet...
12,551
<ASSISTANT_TASK:> Python Code: import numpy as np a = np.array([1, 2, 3, 4]) print 'Вектор:\n', a b = np.array([1, 2, 3, 4, 5], dtype=float) print 'Вещественный вектор:\n', b c = np.array([True, False, True], dtype=bool) print 'Булевский вектор:\n', c print 'Тип булевского вектора:\n', c.dtype d = np.arange(start=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: 1. Создание векторов Step2: Тип значений вектора можно узнать с помощью numpy.ndarray.dtype Step3: Другим способом задания вектора является фу...
12,552
<ASSISTANT_TASK:> Python Code: # @title Install dependencies # @markdown Only execute if not already installed and running a cloud runtime !pip install -q timesketch_api_client # @title Import libraries # @markdown This cell will import all the libraries needed for the running of this colab. import altair as alt # For ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Fill in your event data Step2: Attributes / Tags (optional)
12,553
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier data = pd.read_csv('../input/fifa-2018-match-statistics/FIFA 2018 Statistics.csv') y = (data['Man of the Match'] == "Yes") # Convert from string...
<SYSTEM_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 is how to calculate and show importances with the eli5 library
12,554
<ASSISTANT_TASK:> Python Code: # In order to run this code, you need an already trianed model (see the accompanying notebook) import graphlab as gl model = gl.load_model('pattern_mining_model.gl') model def predict(x): # Construct an SFrame sf = gl.SFrame(x) # Add your own business logic here ...
<SYSTEM_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 can expose the trained model as a REST endpoint. This will allow other applications to consume the predictions from the model. Step2: 2. C...
12,555
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'ukesm1-0-mmh', 'aerosol') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
12,556
<ASSISTANT_TASK:> Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst # Ensure the right version of Tensorflow is installed. !pip freeze | grep tensorflow==2.5 from google.cloud import bigquery import tensorflow as tf import numpy as np import shutil print(tf.__version__) CSV_COLUMNS = ['fa...
<SYSTEM_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> Input </h2> Step2: <h2> Create features out of input data </h2> Step3: <h2> Serving input function </h2> Step4: <h2> tf.estimator.train_...
12,557
<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: Automatic differentiation and gradient tape Step2: Derivatives of a function Step3: Higher-order gradients Step4: Gradient tapes Step5: At t...
12,558
<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 * pc = ParameterCollection() NUM_LAYERS=2 INPUT_DIM=50 HIDDEN_DIM=10 builder = LSTMBuilder(NUM_LAYERS, INPUT_DIM, HID...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: An LSTM/RNN overview Step2: Note that when we create the builder, it adds the internal RNN parameters to the ParameterCollection. Step3: If ou...
12,559
<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: Eager execution Step2: 2. A NumPy-like library for numerical computation and machine learning Step3: Tensors behave similarly to NumPy arrays,...
12,560
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np masses = np.arange(0.1, 0.96, 0.05) # list of masses from scipy.interpolate import interp1d ages = np.arange(5.0e6, 3.1e7, 1.0e6) # ages requested # open output file objects output_files = [open('files/dmestar_{: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: Magnetic Mass Tracks Step2: Magnetic Isochrones Step3: Dartmouth & MARCS; Solar abundance Step4: Interpolate isochrones onto a finer mass gri...
12,561
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-mh', 'seaice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "ema...
<SYSTEM_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...
12,562
<ASSISTANT_TASK:> Python Code: import ovation.lab.constants as constants import ovation.lab.results as results import ovation.download as dowload from ovation.lab.session import connect s = connect(input("Email: "), api=constants.LAB_STAGING_HOST) # use constants.LAB_PRODUCTION_HOST for production batch = input("Batc...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: API Key Step2: Find fastq results for samples in batch Step3: results.get_sample_results pulls all WorkflowSampleResults for the given batch a...
12,563
<ASSISTANT_TASK:> Python Code: %%R library(dplyr) playoffs <- data_frame( holiday = 'playoff', ds = as.Date(c('2008-01-13', '2009-01-03', '2010-01-16', '2010-01-24', '2010-02-07', '2011-01-08', '2013-01-12', '2014-01-12', '2014-01-19', '2014-02-02', '2015-01-11', '...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Above we have included the superbowl days as both playoff games and superbowl games. This means that the superbowl effect will be an additional ...
12,564
<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: Quantum Chess REST API Step2: It is possible to play the game in interactive mode, by applying moves to the board. Split the knight on b1 to a3...
12,565
<ASSISTANT_TASK:> Python Code: import matplotlib.pylab as plt X = [10, 20, 30, 40, 50, 60, 70] y = [40, 45, 50, 65, 70, 70, 80] plt.figure(figsize=(4, 2)) plt.scatter(X, y) plt.xlabel("training time"); plt.ylabel("productivity") plt.show() plt.figure(figsize=(6, 3)) plt.scatter(X, y) plt.xlabel("training time") plt.yl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: scatter plot 을 보면 훈련시간이 늘어남에 따라 생산성도 높아지고 있음을 쉽게 볼 수 있다. 따라서 훈련시간과 생산성 사이에 밀접한 관계가 있음을 알 수 있다. Step2: 가장 좋은 표본회귀식은 전체적으로 추정오차, 즉 잔차를 가장 작게 해 줄 ...
12,566
<ASSISTANT_TASK:> Python Code: ph_sel_name = "Dex" data_id = "12d" # ph_sel_name = "all-ph" # data_id = "7d" from fretbursts import * init_notebook() from IPython.display import display data_dir = './data/singlespot/' import os data_dir = os.path.abspath(data_dir) + '/' assert os.path.exists(data_dir), "Path '%s' doe...
<SYSTEM_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 software and filenames definitions Step2: Data folder Step3: List of data files Step4: Data load Step5: Laser alternation selection Ste...
12,567
<ASSISTANT_TASK:> Python Code: def environmentScoreNoRounding(speciesData, nodeConfig, biomassData): numTimesteps = len(biomassData[nodeConfig[0]['nodeId']]) scores = np.empty(numTimesteps) for timestep in range(numTimesteps): # Calculate the Ecosystem Score for this timestep biomass = 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: Step2: Using cube root instead of log Step3: Shannon index, based on number of individuals Step4: Shannon index, based on biomass Step5: Biomass-bas...
12,568
<ASSISTANT_TASK:> Python Code: import numpy as np from sklearn.linear_model import LogisticRegression from sklearn import datasets from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler # Load the iris dataset iris = datasets.load_iris() # Create X from the features X = 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: Create The Data Step2: View The Data Step3: Split The Data Into Training And Test Sets Step4: Standardize Features Step5: Run Logistic Regre...
12,569
<ASSISTANT_TASK:> Python Code: def ci_pendulo_doble(x, y): # tome en cuenta que las longitudes de los eslabones son 2 y 2 l1, l2 = 2, 2 from numpy import arccos, arctan2, sqrt # YOUR CODE HERE raise NotImplementedError() return q1, q2 from numpy.testing import assert_allclose assert_allclose(ci_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Obtenga las posiciones en el espacio articular, $q_1$ y $q_2$, necesarias para que el punto final del pendulo doble llegue a las coordenadas $p_...
12,570
<ASSISTANT_TASK:> Python Code: #!pip install -I "phoebe>=2.4,<2.5" import phoebe from phoebe import u # units logger = phoebe.logger() b = phoebe.default_binary(contact_binary=True) b.add_dataset('lc', times=phoebe.linspace(0,0.5,101)) b.run_compute(irrad_method='none', model='no_spot') b.add_feature('spot', compone...
<SYSTEM_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. Step2: Model without Spots Step3: Adding Spots Step4: Comparing Light C...
12,571
<ASSISTANT_TASK:> Python Code: import pandas as pd import lifelines import matplotlib.pylab as plt %matplotlib inline data = lifelines.datasets.load_dd() data.head() data.tail() from lifelines import KaplanMeierFitter kmf = KaplanMeierFitter() # kaplan-meier # KaplanMeierFitter.fit(event_times, event_observed=None, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: political leaders
12,572
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'csir-csiro', 'sandbox-2', 'atmoschem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("na...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
12,573
<ASSISTANT_TASK:> Python Code: # some random heights of the family height = [1.75, 1.65, 1.71, 1.89, 1.79] # some random weights of the family weight = [65.4, 59.2, 63.6, 88.4, 68.7] # Now if we go to calculate BMI weight / height ** 2 import numpy as np # selective import # Convet the followoing list to numpy arrays ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Solution Step2: Note Step4: Numpy Step6: Numpy Subsetting Step8: Exercise Step10: 2. Baseball player's height Step12: 3. Baseball playe...
12,574
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import statsmodels.api as sm import numpy as np import pandas as pd data = sm.datasets.sunspots.load() from datetime import datetime dates = sm.tsa.datetools.dates_from_range('1700', length=len(data.endog)) endog = pd.Series(data.endog, index=dates...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Getting started Step2: Right now an annual date series must be datetimes at the end of the year. Step3: Using Pandas Step4: Instantiate the m...
12,575
<ASSISTANT_TASK:> Python Code: if boolean-expression: statements-when-true else: statemrnts-when-false x = 15 y = 20 z = 2 x > y z*x <= y y >= x-z z*10 == x raining = False snowing = True age = 45 age < 18 and raining age >= 18 and not snowing not snowing or not raining age == 45 and not snowing if boolean-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: Python’s Relational Operators Step2: A. 4 Step3: A. 4 Step4: elif versus a series of if statements Step5: Check Yourself Step6: A. One Step...
12,576
<ASSISTANT_TASK:> Python Code: [10, 20, 30, 40] ['dog', 'fish', 'bird'] ['bob', 3.14, 42, ['sam', 55]] cheeses = ['Chedder', 'Pepper Jack', 'Queso Fresca'] grades = [99, 84, 91] empty = [] cheeses = ['Chedder', 'Pepper Jack', 'Queso Fresca'] cheeses[0] = 'Gouda' print( cheeses ) for cheese in cheeses: print( ch...
<SYSTEM_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 elements of a list don't have to be the same data type in Python (in other languages they do) Step2: As you can see, lists can be nested St...
12,577
<ASSISTANT_TASK:> Python Code: !pip install git+git://github.com/lindermanlab/ssm-jax-refactor.git import ssm import jax.random as jr import jax.numpy as np import matplotlib.pyplot as plt from tensorflow_probability.substrates import jax as tfp from ssm.hmm import BernoulliHMM from ssm.plots import gradient_cmap fro...
<SYSTEM_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 and Plotting Functions Step2: Bernoulli HMM Step3: From the true model, we can sample synthetic data Step4: Let's view the synthetic ...
12,578
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib as mpl import matplotlib.pyplot as plt import pandas as pd import numpy as np from datetime import datetime import trulia.stats import geocoder import json from datetime import timedelta from collections import defaultdict import time import requests 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: Below is a time series of the weather in Chapel Hill, NC every morning over a few years. You can clearly see an annual cyclic pattern, which sh...
12,579
<ASSISTANT_TASK:> Python Code: %tensorflow_version 1.x !curl -Lo deepchem_installer.py https://raw.githubusercontent.com/deepchem/deepchem/master/scripts/colab_install.py import deepchem_installer %time deepchem_installer.install(version='2.3.0') import deepchem as dc tasks, datasets, transformers = dc.molnet.load_muv...
<SYSTEM_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 start by loading the data. We will use the MUV dataset. It includes 74,501 molecules in the training set, and 9313 molecules in the vali...
12,580
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelBinarizer, StandardScaler from keras.models import Sequential from keras.layers import Dense, Activation, Dropout stats = ...
<SYSTEM_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 preparation Step2: The file Seasons_Stats.csv contains the statics of all players since 1950. First, we drop a couple of blank columns, an...
12,581
<ASSISTANT_TASK:> Python Code: import requests import json import pandas as pd SERVER = 'http://data.neonscience.org/api/v0/' SITECODE = 'WOOD' PRODUCTCODE = 'DP1.00041.001' #Get availability site_request = requests.get(SERVER+'sites/'+SITECODE) site_json = site_request.json() for product in site_json['data']['dataPro...
<SYSTEM_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 get soil temperature data from NEON's Woodworth site. Soil temperature data is measured and recorded automatically by soil temeprature pro...
12,582
<ASSISTANT_TASK:> Python Code: REGION = 'us-central1' PROJECT_ID = !(gcloud config get-value core/project) PROJECT_ID = PROJECT_ID[0] BUCKET = 'gs://' + PROJECT_ID !bq --location=US mk census %%bigquery CREATE OR REPLACE TABLE census.data AS SELECT age, workclass, education_num, occupation, hours_per_week,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: First, create a BigQuery dataset. We will then query a public BigQuery dataset to populate a table in this dataset. This is census data. We will...
12,583
<ASSISTANT_TASK:> Python Code: from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt %matplotlib inline import numpy as np import urllib2 def check_condition(row): if row[-1] == 0: return False return True url = ('https://raw.githubusercontent.com/Upward-Spiral-Science' '/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: What is the total number of synapses in our data set? Step2: What is the maximum number of synapses at a given point in our data set? Step3: W...
12,584
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline ad_data = pd.read_csv('advertising.csv') ad_data.head() ad_data.info() ad_data.describe() sns.distplot(ad_data['Age'],kde=False,bins=30,color='blue') sns.jointplot(data=ad_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Get the Data Step2: Check the head of ad_data Step3: Use info and describe() on ad_data Step4: Exploratory Data Analysis Step5: Create a joi...
12,585
<ASSISTANT_TASK:> Python Code: # Load the needed packages import os import matplotlib.pyplot as plt import numpy as np from netCDF4 import Dataset import awot from awot.graph import FlightLevel, RadarVerticalPlot, MicrophysicalVerticalPlot %matplotlib inline file1 = "WCR.OWLES13.20131215.225944_234806.up-down.nc" #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: <b>Supply input data and plotting characteristics. In this case we'll use a file from the OWLeS project and corrected field of velocity data usi...
12,586
<ASSISTANT_TASK:> Python Code: from __future__ import division, print_function %matplotlib inline path = "data/dogscats/" #path = "data/dogscats/sample/" import os, json from glob import glob import numpy as np np.set_printoptions(precision=4, linewidth=100) from matplotlib import pyplot as plt # check that ~/.keras...
<SYSTEM_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 path to data Step2: A few basic libraries that we'll need for the initial exercises Step3: We have created a file most imaginatively ca...
12,587
<ASSISTANT_TASK:> Python Code: import vcsn c = vcsn.context('lat<lan_char(abc), lan_char(bce)>, nmin') l = c.levenshtein() l a1 = vcsn.context('lan_char(abc), b').expression("bac+cab").derived_term().strip().partial_identity() a1 a2 = vcsn.context('lan_char(bce), b').expression("bec+bebe").automaton().cominimize().str...
<SYSTEM_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 Levenshtein automaton only has one state, but has $N*M + N + M$ transitions, for alphabets of size $N$ and $M$. Step2: The automaton can be...
12,588
<ASSISTANT_TASK:> Python Code: fruits = ['Apple', 'Mango', 'Grapes', 'Jackfruit', 'Apple', 'Banana', 'Grapes', [1, "Orange"]] # processing the entire list for fruit in fruits: print(fruit, end=", ") # print("*"*30) fruits.insert(0, "kiwi") print( fruits) # help(fruits.insert) # Including ft1 = list(fru...
<SYSTEM_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: Removing Step3: Appending Step4: Ordering Step5: Inverting Step6: The function enumerate() returns a tuple of two elements in e...
12,589
<ASSISTANT_TASK:> Python Code: import numpy as np np.linspace(0,10,11) # your code here #start by defining the length of the array arrayLength = 10 #let's set the array to currently be an array of 0s myArray = np.zeros(arrayLength) #make a numpy array of 10 zeros # Let's define the first element of the array myArray[...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: You can do a lot with the numpy module. Below is an example to jog your memory Step2: Do you remember loops? Let's use a while loop to make an ...
12,590
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import pandas as pd def fun_log(z): return 1/(1+np.exp(-z)) z = np.linspace(-5, 5) plt.figure(figsize = (8,6)) plt.plot(z, fun_log(z), lw = 2) plt.xlabel('$z$') plt.ylabel('$\sigma(z)$') plt.grid() plt.show() def reg_log(B,Xa): 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: Notamos que Step2: 3. Funcional de costo Step3: Diseñar un clasificador binario con regresión logística. Step4: Los parámetros del clasificad...
12,591
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pymc3 as pm import numpy as np import matplotlib.pyplot as plt import seaborn as sns import pandas as pd import theano.tensor as T x = np.random.randn(100) with pm.Model() as model: mu = pm.Normal('mu', mu=0, sd=1) sd = pm.Normal('sd', mu=0, sd=1) obs...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Hm, looks like something has gone wrong, but what? Let's look at the values getting proposed using the Print operator Step2: Looks like sd is a...
12,592
<ASSISTANT_TASK:> Python Code: import re three_repeating_characters = re.compile(r'(.)\1{2}') with open('../inputs/day14.txt', 'r') as f: salt = f.readline().strip() # TEST DATA # salt = 'abc' print(salt) import hashlib hash_index= {} def get_hash_string(key): if key in hash_index: return hash_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Hash index Step2: Part Two
12,593
<ASSISTANT_TASK:> Python Code: spam = ["eggs", 7.12345] # This is a list, a comma-separated sequence of values between square brackets print spam print type(spam) eggs = [spam, 1.2345, "fooo"] # No problem with multi-line declaration print eggs spam = [] # And this is an empty list print sp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: You can mix all kind of types inside a list Step2: What about tuples? Step3: What about both together? Step4: Let's go back to lists Step5: ...
12,594
<ASSISTANT_TASK:> Python Code: %%bash export PROJECT=$(gcloud config list project --format "value(core.project)") echo "Your current GCP Project Name is: "$PROJECT import os, json, math, shutil import datetime import numpy as np import logging # SET TF ERROR LOG VERBOSITY logging.getLogger("tensorflow").setLevel(loggin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Create a new Google Cloud Storage Bucket for ML model exports Step2: Setup parameters for notebook scheduling Step3: Locating the CSV files St...
12,595
<ASSISTANT_TASK:> Python Code: import pandas as pd capitais = pd.read_csv('capitais.csv', sep=',') capitais.head() # Imprime os 5 primeiros elementos do dataframe capitais = pd.read_csv('capitais.csv', sep=',', index_col='municipio') capitais.head() len(capitais.index) capitais.index capitais.columns capitais["popul...
<SYSTEM_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 que o índice que foi gerado é o padrão e não o default. Para defirmos a coluna municipio como sendo o índice, precisamos passar o parâmetro...
12,596
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'gfdl-esm2m', 'land') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
12,597
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'inm', 'inm-cm5-h', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "em...
<SYSTEM_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...
12,598
<ASSISTANT_TASK:> Python Code: import pickle import sys sys.path.append("../tools/") from feature_format import featureFormat, targetFeatureSplit data_dict = pickle.load(open("../final_project/final_project_dataset.pkl", "r") ) ### first element is our labels, any added elements are predictor ### features. Keep this th...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Create a decision tree classifier (just use the default parameters), train it on all the data. Print out the accuracy. Step2: Now you’ll add i...
12,599
<ASSISTANT_TASK:> Python Code: # -*- coding: UTF-8 -*- import pandas as pd import numpy as np import re from bs4 import BeautifulSoup def review_to_wordlist(review): ''' 把IMDB的评论转成词序列 参考:http://blog.csdn.net/longxinchen_ml/article/details/50629613 ''' # 去掉HTML标签,拿到内容 review_text = BeautifulSoup...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 载入数据集 Step2: 预处理数据 Step3: 特征处理 Step4: 朴素贝叶斯训练 Step5: 提交最终的结果到kaggle,AUC为:0.85728,排名300左右,50%的水平 Step6: 提交最终的结果到kaggle,AUC为:0.88956,排名260左...