Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
13,300
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cmcc', 'cmcc-cm2-hr4', 'atmos') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "e...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
13,301
<ASSISTANT_TASK:> Python Code: from workflow.engine import GenericWorkflowEngine my_engine = GenericWorkflowEngine() from functools import wraps def print_data(obj, eng): Print the data found in the token. print(obj.data) def add_data(number_to_add): Add number_to_add to obj.data. @wraps(add_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: Instantiate a workflow engine Step4: Create tasks Step5: Create a workflow definition Step6: Define tokens Step7: Run the engine Step8: Res...
13,302
<ASSISTANT_TASK:> Python Code: import xray_vision import xray_vision.mpl_plotting as mpl_plot import skbeam.core.speckle as xsvs import skbeam.core.roi as roi import skbeam.core.correlation as corr import skbeam.core.utils as utils import numpy as np import os, sys import matplotlib as mpl import matplotlib.pyplot as 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: Easily switch between interactive and static matplotlib plots¶ Step2: This data provided by Dr. Andrei Fluerasu Step3: Create the Rings Mask¶ ...
13,303
<ASSISTANT_TASK:> Python Code: from Bio.Blast import NCBIWWW help(NCBIWWW.qblast) from Bio.Blast import NCBIWWW result_handle = NCBIWWW.qblast("blastn", "nt", "8332116") from Bio.Blast import NCBIWWW fasta_string = open("data/m_cold.fasta").read() result_handle = NCBIWWW.qblast("blastn", "nt", fasta_string) from Bio...
<SYSTEM_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 that the default settings on the NCBI BLAST website are not quite Step2: Alternatively, if we have our query sequence already in a FASTA S...
13,304
<ASSISTANT_TASK:> Python Code: # Import SPI rack and D5a module from spirack import SPI_rack, D5a_module COM_speed = 1e6 # Baud rate, doesn't matter much timeout = 1 # In seconds spi_rack = SPI_rack('COM4', COM_speed, timeout) spi_rack.unlock() # Unlock the controller to be able to send data D5a = D5a_module(spi_rack...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Open the SPI rack connection and unlock the controller. This is necessary after bootup of the controller module. If not unlocked, no communicati...
13,305
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import load_breast_cancer cancer = load_breast_cancer() X = cancer.data y = cancer.target from sklearn.tree import DecisionTreeClassifier def decision_stump(features, labels): clf = DecisionTreeClassifier(max_depth=1, random_state=123) clf.fit(features, labe...
<SYSTEM_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 the Decision Stump Step2: Get an Accuracy Result Step3: Demonstrate for a single iteration Step4: Extract Incorrect Classifications Ste...
13,306
<ASSISTANT_TASK:> Python Code: def smoothListGaussian(list,degree=5): list =[list[0]]*(degree-1) + list + [list[-1]]*degree window=degree*2-1 weight=np.array([1.0]*window) weightGauss=[] for i in range(window): i=i-degree+1 frac=i/float(window) gauss=1/(np.exp((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: This function is syntactically correct and it works. Let's test it with a data set. The same one used in the scipy cookbook (http Step3: Despit...
13,307
<ASSISTANT_TASK:> Python Code:: df['total'] = df['col_1'] + df['col_2'] df = df.pipe(lambda x: x.div(x['total'], axis='index')).applymap('{:.0%}'.format) <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:
13,308
<ASSISTANT_TASK:> Python Code: # A bit of setup # import numpy as np # import matplotlib.pyplot as plt # from cs231n.classifiers.neural_net import TwoLayerNet # %matplotlib inline # plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots # plt.rcParams['image.interpolation'] = 'nearest' # plt.rcParams[...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Implementing a Neural Network Step2: We will use the class TwoLayerNet in the file cs231n/classifiers/neural_net.py to represent instances of o...
13,309
<ASSISTANT_TASK:> Python Code: import pandas as pd from pandas_datareader import data, wb import datetime # We will look at stock prices over the past year, starting at January 1, 2016 start = datetime.datetime(2016,1,1) end = datetime.date.today() # Let's get Apple stock data; Apple's ticker symbol is AAPL # First...
<SYSTEM_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 Basics Step2: Add More Stocks Step3: Plot Price of all three stocks Step4: Apply Rolling Window Step5: Profit Step6: S&P 500 Step7: ...
13,310
<ASSISTANT_TASK:> Python Code: # This is probably due to a unit conversion in a multiplicative prefactor # This multiplicative prefactor is based on nanometers r_min = 0.14 r_max = 1.0 print (1/r_min - 1/r_max) # This multiplicative prefactor is based on angstroms r_min = 1.4 r_max = 10.0 print (1/r_min - 1/r_max) 4*n...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Switching from nanometers to angstroms makes the multiplicative prefactor smaller, which is opposite of the desired effect! Step2: Igrid[atomI]...
13,311
<ASSISTANT_TASK:> Python Code: # This exercise is mostly for us to understand what kind of data we have and then # run some simple stats on the fields/values in the data. Pandas will be great for that import pandas as pd pd.__version__ # Set default figure sizes pylab.rcParams['figure.figsize'] = (16.0, 5.0) # Lets tak...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Lets do standard histogram and event volume over time plots Step2: <img align="right" src="files/images/spice_weasel.jpg" width="300px" style="...
13,312
<ASSISTANT_TASK:> Python Code: import rebound import numpy as np sim = rebound.Simulation() OMEGA = 0.00013143527 # [1/s] sim.integrator_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 =...
<SYSTEM_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...
13,313
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import scipy.stats as stats import matplotlib.pyplot as plt import math import cvxpy def get_markowitz_weights(mu, Sigma, gamma=1, max_position=1.0, max_leverage=1.0, short=False): w = cvxpy.Variable(len(Sigma)) g = cvxpy.Parameter(sign='pos...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Helper Functions Step2: Exercise 1 Step3: b. $1 Bets Step4: Exercise 2 Step5: b. Equally Weighted Portfolio Step6: c. Market Weighted Portf...
13,314
<ASSISTANT_TASK:> Python Code: # 检查你的Python版本 from sys import version_info if version_info.major != 2 and version_info.minor != 7: raise Exception('请使用Python 2.7来完成此项目') # 引入这个项目需要的库 import numpy as np import pandas as pd import visuals as vs from IPython.display import display # 使得我们可以对DataFrame使用display()函数 # 设置以...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 分析数据 Step2: 练习 Step3: 问题 1 Step4: 问题 2 Step5: 问题 3 Step6: 观察 Step7: 练习 Step8: 问题 4 Step9: 问题 5 Step10: 练习:降维 Step11: 观察 Step12: 可视化一个...
13,315
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import KFold from sklearn.linear_model import Ridge from sklearn.model_selection import cross_val_score from sklearn.preprocessing import PolynomialFeatures # A seed just to ensure that the ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: To think about, first part Step2: What does centering (subtracting the mean values) mean mathematically? Step3: The intercept is the value of ...
13,316
<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: 컨볼루셔널 변이형 오토인코더 Step2: MNIST 데이터세트 로드하기 Step3: tf.data를 사용하여 데이터 배치 및 셔플 처리하기 Step5: tf.keras.Sequential을 사용하여 인코더 및 디코더 네트워크 정의하기 Step7: 손실...
13,317
<ASSISTANT_TASK:> Python Code: %load_ext sql %sql mysql://studentuser:studentpw@mysqlserver/dognitiondb %sql USE dognitiondb %config SqlMagic.displaylimit=25 %%sql SELECT user_guid FROM users WHERE free_start_user=1 LIMIT 0,5; %%sql DESCRIBE dogs %%sql SELECT dog_guid FROM dogs WHERE dna_tested=1; %%sql DESCRIBE use...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Recall the general syntax structure we learned from the "Introduction to Query Syntax" video at the beginning of the week Step2: Question 1 Ste...
13,318
<ASSISTANT_TASK:> Python Code: import re import glob import numpy import iris import iris.coord_categorisation from iris.experimental.equalise_cubes import equalise_attributes import warnings warnings.filterwarnings('ignore') lat_constraint = iris.Constraint(latitude=lambda cell: cell <= -30) def read_hfds_data(file_l...
<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: Step 1 Step5: Step 2 Step7: Step 3 Step9: Step 4 Step10: Step 5 Step14: Step 6 Step15: Final result
13,319
<ASSISTANT_TASK:> Python Code: # Učitaj osnovne biblioteke... import numpy as np import sklearn import mlutils import matplotlib.pyplot as plt %pylab inline from sklearn.linear_model import LinearRegression, RidgeClassifier from sklearn.metrics import accuracy_score seven_X = np.array([[2,1], [2,3], [1,2], [3,2], [5,...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Zadatci Step2: (a) Step3: Kako bi se uvjerili da se u isprobanoj implementaciji ne radi o ničemu doli o običnoj linearnoj regresiji, napišite ...
13,320
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np # tuberculosis (TB) dataset path_tb = '/Users/ericfourrier/Documents/ProjetR/tidy-data/data/tb.csv' df_tb = pd.read_csv(path_tb) df_tb.head(20) # clean column names df_tb = df_tb.rename(columns={'iso2':'country'}) # rename iso2 in country df_tb = 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: Original TB dataset. Corresponding to each ‘m’ column for males, there is also an ‘f’ column Step2: Create sex and age columns from variable 'c...
13,321
<ASSISTANT_TASK:> Python Code: import requests # to make GET request from bs4 import BeautifulSoup # to parse the HTML response import time # to pause between calls import csv # to write data to csv import pandas # to see CSV # make a GET request response = requests.get('http://www.ilga.gov/senate/default.asp') #...
<SYSTEM_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. Using BeautifulSoup Step2: 1.2 soup it Step3: 1.3 Find Elements Step4: NB Step5: That's a lot! Many elements on a page will have the same...
13,322
<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: Language Translation Step3: Explore the Data Step6: Implement Preprocessing Function Step8: Preprocess all the data and save it Step10: Chec...
13,323
<ASSISTANT_TASK:> Python Code: import ctcsound c = ctcsound.Csound() ret = c.compileCsd("test1.csd") if ret == ctcsound.CSOUND_SUCCESS: c.start() c.perform() c.reset() # Defining our Csound ORC code within a multiline String orc = sr=44100 ksmps=32 nchnls=2 0dbfs=1 instr 1 aout vco2 0.5, 440 outs aout, aou...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Example 1 - Simple Compilation with Csound Step3: Example 2 - Compilation with Csound without CSD Step5: Example 3 - Using Our Own Performance...
13,324
<ASSISTANT_TASK:> Python Code: import openpnm as op pn = op.network.Cubic([4, 4,]) geo = op.geometry.SpheresAndCylinders(network=pn, pores=pn.Ps, throats=pn.Ts) air = op.phases.Air(network=pn) phys = op.physics.Basic(network=pn, phase=air, geometry=geo) alg = op.algorithms.ReactiveTransport(network=pn, phase=air) pri...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Normal Usage Step2: We can see that many default settings are already present by printing the settings attribute Step3: We can override these ...
13,325
<ASSISTANT_TASK:> Python Code: import requests import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.cluster import AgglomerativeClustering from sklearn.metrics import ( adjusted_rand_score, adjusted_mutual_info_score, homogeneity_score, completeness_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: 数据获取 Step2: 数据预处理 Step3: 数据集拆分 Step4: 训练模型 Step5: 模型评估
13,326
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt func = np.poly1d(np.array([1, 2, 3, 4]).astype(float)) func2 = func.deriv(m=2) x = np.linspace(-10, 10, 30) y = func(x) y2 = func2(x) plt.plot(x, y) plt.plot(x, y2, 'r>') plt.xlabel('x') plt.ylabel('y(x)') plt.show() ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1. 简单绘图 Step2: 其中,linspace函数常见x轴的数值,在-10和10之间产生30个均匀分布的值。 Step3: plot函数可以接受任意个数的参数,我们可以使用可选的格式字符串参数指定线条的颜色和风格,默认为'b-'即蓝色视线。你可以指定其他风格。 Step4: ...
13,327
<ASSISTANT_TASK:> Python Code: # Perform standard imports: import spacy nlp = spacy.load('en_core_web_sm') doc1 = nlp(u"I am a runner running in a race because I love to run since I ran today") for token in doc1: print(token.text, '\t', token.pos_, '\t', token.lemma, '\t', token.lemma_) def show_lemmas(text): ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <font color=green>In the above sentence, running, run and ran all point to the same lemma run (...11841) to avoid duplication.</font> Step2: He...
13,328
<ASSISTANT_TASK:> Python Code: import pandas as pd floodingReports = pd.Series([5, 6, 2, 9, 12]) floodingReports floodingReports = pd.Series([5, 6, 2, 9, 12], index=['Cochise County', 'Pima County', 'Santa Cruz County', 'Maricopa County', 'Yuma County']) floodingReports floodingReports['Cochise County'] floodingRep...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Series 101 Step2: Note that the first column of numbers (0 to 4) are the index. Step3: View the number of floodingReports in Cochise County St...
13,329
<ASSISTANT_TASK:> Python Code: from dolfin import * from rbnics import * @DEIM() class Gaussian(EllipticCoerciveProblem): # Default initialization of members def __init__(self, V, **kwargs): # Call the standard initialization EllipticCoerciveProblem.__init__(self, V, **kwargs) # ... and...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 3. Affine decomposition Step2: 4. Main program Step3: 4.2. Create Finite Element space (Lagrange P1) Step4: 4.3. Allocate an object of the Ga...
13,330
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import make_blobs import matplotlib.pyplot as plt # Make the features (X) and output (y) with 200 samples, X, y = make_blobs(n_samples = 200, # two feature variables, n_features = 2, # three clusters, ...
<SYSTEM_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 Data Step2: View Data
13,331
<ASSISTANT_TASK:> Python Code: # To support both python 2 and python 3 from __future__ import division, print_function, unicode_literals # Common imports import numpy as np import os try: # %tensorflow_version only exists in Colab. %tensorflow_version 1.x except Exception: pass # to make this notebook's out...
<SYSTEM_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 running a graph Step2: Managing graphs Step3: Linear Regression Step4: Compare with pure NumPy Step5: Compare with Scikit-Learn...
13,332
<ASSISTANT_TASK:> Python Code: def find_df(v, p, u, tau): return -digamma(v/2.) + log(v/2.) + (tau * (log(u) - u)).sum()/tau.sum() + 1 + (digamma((v+p)/2.)-log((v+p)/2.)) u_test = np.array([[1,1], [2,2], [3,3]]) tau_test = np.array([[4,4], [5,5], [6,6]]) find_df(1, 2, u_test, tau_test) def get_random(X): size...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Expectation Maximization with Mixtures Step2: Plotting the sample with actual parameters Step3: Estimating parameters
13,333
<ASSISTANT_TASK:> Python Code: def Centered_Triangular_num(n ) : return(3 * n * n + 3 * n + 2 ) // 2  if __name__== ' __main __' : n = 3 print(Centered_Triangular_num(n ) ) n = 12 print(Centered_Triangular_num(n ) )  <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:
13,334
<ASSISTANT_TASK:> Python Code: from precovery_utils import ssoisPrecovery ssois_query = ssoisPrecovery() query_url = ssois_query.format_search_by_arc_url('kbmod_mpc.dat') print(query_url) results_df = ssois_query.query_ssois(query_url) results_df.head() from IPython.display import HTML image_data_link = results_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: Create Query URL from MPC formatted file Step2: Query service via URL Step3: Create direct data download link Step4: Compare KBMOD data to av...
13,335
<ASSISTANT_TASK:> Python Code: import toytree # a tree plotting library import toyplot # a general plotting library import numpy as np # numerical library print(toytree.__version__) print(toyplot.__version__) print(np.__version__) # load a toytree from a newick string at a URL tre = toytree.tree("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: Load and draw your first tree Step2: Parsing Newick/Nexus data Step4: To parse either format you can tell toytree the format of the newick str...
13,336
<ASSISTANT_TASK:> Python Code: %reload_ext autoreload %autoreload 2 %matplotlib inline from fastai.imports import * from fastai.transforms import * from fastai.conv_learner import * from fastai.model import * from fastai.dataset import * from fastai.sgdr import * PATH = "data/planet/" !ls {PATH} from fastai.plots 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: 2 Multi-Label versus Single-Label Classification Step2: In single-label classification each sample belongs to one class. In the previous exampl...
13,337
<ASSISTANT_TASK:> Python Code: def raiz(x_l, x_u): x_r = (x_l + x_u)/2 return x_r def intervalo_de_raiz(f, x_l, x_u): x_r = raiz(x_l, x_u) if f(x_l)*f(x_r) < 0: x_u = x_r if f(x_l)*f(x_r) > 0: x_l = x_r return x_l, x_u def biseccion(f, x_inferior, x_superior): print("{0:2s}\...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Implementación no vectorizada Step2: Ejemplo 2 Step3: Ejemplo 3 Step4: Ejemplo 4
13,338
<ASSISTANT_TASK:> Python Code: import numpy as np import math from numba import vectorize, cuda from matplotlib import pyplot as plt %matplotlib inline !find / -iname 'libdevice' !find / -iname 'libnvvm.so' import os os.environ['NUMBAPRO_LIBDEVICE'] = "/usr/local/cuda-10.0/nvvm/libdevice" os.environ['NUMBAPRO_NVVM'] ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Problem 0 - Accessing the GPU Step2: Paste the location of the libraries into the following code box (if it's different, otherwise you can just...
13,339
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import sklearn features = load_data() from sklearn.preprocessing import MultiLabelBinarizer new_features = MultiLabelBinarizer().fit_transform(features) <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:
13,340
<ASSISTANT_TASK:> Python Code: import threading from _thread import start_new_thread, allocate_lock import logging import time import numpy as np def worker1(): print(threading.currentThread().getName(), '--begin') time.sleep(3) print(threading.currentThread().getName(), '--end') def worker2(): pr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Example 1 Step2: Example 2 Step3: Example 3 Step4: Example 4 Step5: Example 5 Step6: Example 6 Step7: Example 7
13,341
<ASSISTANT_TASK:> Python Code: import deepchem as dc from deepchem.models.tensorgraph.tensor_graph import TensorGraph tg = TensorGraph(use_queue=False) from deepchem.models.tensorgraph.layers import Feature left_features = Feature(shape=(None, 75)) right_features = Feature(shape=(None, 75)) from deepchem.models.tenso...
<SYSTEM_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're going to construct an architecture that has two identical feature inputs. Let's call these feature inputs left_features and right_features...
13,342
<ASSISTANT_TASK:> Python Code: import os import pandas as pd def get_rail_id(row): Extract specific rail_ids from complex data structure that assigns rail_ids (Sample IDs) to snaptron_ids (exon-exon junctions). Designed to be used as a pd.DataFrame().apply() function. Arguments: row - a row in ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Processing TP53 Exon-Exon Junction Data Step2: First, load several files required for processing Step3: Next, select the samples with the spec...
13,343
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd import matplotlib.pyplot as plt import numpy as np import os print('Esperamos trabalhar no diretório') print(os.getcwd()) #Se usar o arquivo descompactado #pd.read_csv('DOM2015.csv',sep=',') base09 = pd.read_csv('DOM2009.csv',sep=',') base13 = pd.rea...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Na célula a cima foram escolhidas as variáveis que serão utilizadas. Em sequência, temos Step2: No código a cima foi feita a categorização das ...
13,344
<ASSISTANT_TASK:> Python Code: #the usual beginning import pandas as pd import numpy as np from pandas import Series, DataFrame from datetime import datetime, timedelta from pandas import concat #define any string with 'C' as NaN def readD(val): if 'C' in val: return np.nan return val df = pd.read_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: Step2: Import File into Python Step3: Set Date and Time of ROP Exam and Eye Drops Step4: Baseline Averages Step5: Average q 5 Min for 1 hour after 1...
13,345
<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: Natural Language Processing Step2: Next we'll download and unzip the data. Step3: There are three files that we'll use in our model Step4: In...
13,346
<ASSISTANT_TASK:> Python Code: # Load pickled data import pickle # TODO: Fill this in based on where you saved the training and testing data training_file = 'train.p' validation_file= 'valid.p' testing_file = 'test.p' with open(training_file, mode='rb') as f: train = pickle.load(f) with open(validation_file, mode='...
<SYSTEM_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 Info of the Dataset Step2: Visualize Data Step3: Preprocess Data Step4: Setup TensorFlow Step5: SOLUTION Step6: Features and Labels S...
13,347
<ASSISTANT_TASK:> Python Code: from pulp import * import numpy as np import matplotlib.pyplot as plt %matplotlib inline import seaborn as sn #a handful of sites sites = ['org','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P'] print(len(sites)-1) #make some positions (so we can plot this) positions = dic...
<SYSTEM_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. First lets make some fake data Step2: 2. The model Step3: Solve it! Step4: And the result Step5: The optimal tours
13,348
<ASSISTANT_TASK:> Python Code: l1 = sorted(['b', 'c', 'a']) # a list l2 = sorted(('b', 'c', 'a')) # a tuple l3 = sorted('bca') # a string print(l1, l1 == l2 == l3) print(type(l1) == type(l2) == type(l3) == list) l = [1, 2, 3] s = sorted(l) print('This should be False:', id(l) == id(s)) l = [2, 3, 1] s = sorted(l) ...
<SYSTEM_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() always returns a new object. Step2: It is also possible to sort lists in place with the sort() method of lists. It accepts the key and...
13,349
<ASSISTANT_TASK:> Python Code: pokemon = data[data.Generation == 1] Image(url="http://i.giphy.com/yidUzHnBk32Um9aMMw.gif") pokemon # Afficher les données de Pikachu : pokemon[pokemon.Name == 'Pikachu'] # Creer une variable de attribut de Pikachu Pikachu = pokemon[pokemon.Name == 'Pikachu'] Pikachu Image(url="http://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: Voila comment sélectionner des données sur un DataFrame existant Step2: Regardons les stats de Pikachu maintenant. Pour afficher les données, ...
13,350
<ASSISTANT_TASK:> Python Code: import jax import jax.numpy as jnp global_list = [] def log2(x): global_list.append(x) ln_x = jnp.log(x) ln_2 = jnp.log(2.0) return ln_x / ln_2 print(jax.make_jaxpr(log2)(3.0)) def log2_with_print(x): print("printed x:", x) ln_x = jnp.log(x) ln_2 = jnp.log(2.0) return ln_...
<SYSTEM_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 Understanding Jaxprs section of the documentation provides more information on the meaning of the above output. Step2: See how the printed ...
13,351
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd from sklearn.metrics import mean_absolute_error from sklearn.model_selection import GridSearchCV, KFold, cross_val_predict from sklearn.neighbors import KNeighborsRegressor from sklearn.pipeline import make_pipeline from sklearn.preprocessing 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: Next, let's load the data. This week, we're going to load the Auto MPG data set, which is available online at the UC Irvine Machine Learning Rep...
13,352
<ASSISTANT_TASK:> Python Code: def get_closest_vowel(word): if len(word) < 3: return "" vowels = {"a", "e", "i", "o", "u", "A", "E", 'O', 'U', 'I'} for i in range(len(word)-2, 0, -1): if word[i] in vowels: if (word[i+1] not in vowels) and (word[i-1] not in vowels): ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
13,353
<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: Restart the kernel Step2: Before you begin Step3: Region Step4: Timestamp Step5: Authenticate your Google Cloud account Step6: Create a Clo...
13,354
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ec-earth-consortium', 'sandbox-2', 'aerosol') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contribu...
<SYSTEM_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...
13,355
<ASSISTANT_TASK:> Python Code: # Imports for plotting import matplotlib.pyplot as plt %matplotlib inline import seaborn as sns import numpy as np sns.set_style('darkgrid') mb_solve_json = { "atom": { "decays": [ { "channels": [[0, 1]], "rate": 1.0 } ], "fields": [ { ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Velocity Classes for Modelling Doppler Broadening in Thermal Systems Step2: We can check the set of velocity classes we've defined Step3: The ...
13,356
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mpi-m', 'sandbox-2', 'atmos') # 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: 1...
13,357
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'pcmdi', 'sandbox-2', 'land') # 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: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
13,358
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns import numpy as np import sympy as sym import quantecon as qe import solowpy import pypwt pwt = pypwt.load_pwt_data() fig, ax = plt.subplots(1, 1, figsize=(8,6)) for ctry in pwt.major_axis: tmp_data = pwt.major_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 0. Motivation Step2: From the above figure it is clear that the prediction of constant factor shares is strongly at odds with the empirical dat...
13,359
<ASSISTANT_TASK:> Python Code: from __future__ import print_function from keras.models import Model from keras.layers import Dense, Activation, Embedding from keras.layers import LSTM, Input from keras.layers.merge import concatenate from keras.optimizers import RMSprop, Adam from keras.utils.data_utils import get_file...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Setting params for model setup and build. Step2: Loading and reading Alice.txt corpus, saving characters (unique alphabet and punctuation chara...
13,360
<ASSISTANT_TASK:> Python Code: from rmtk.vulnerability.derivation_fragility.R_mu_T_dispersion.SPO2IDA import SPO2IDA_procedure from rmtk.vulnerability.common import utils %matplotlib inline capacity_curves_file = "../../../../../../rmtk_data/capacity_curves_Vb-dfloor.csv" input_spectrum = "../../../../../../rmtk_dat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load capacity curves Step2: Idealise pushover curves Step3: Load damage state thresholds Step4: Calculate fragility functions Step5: Plot fr...
13,361
<ASSISTANT_TASK:> Python Code: import numpy as np # Simulate a dataset containing one feature (and one target) # The feature values are contained in X # The target values are contained in y def make_data(N=100, err=0.8, rseed=1): # randomly sample the data rng = np.random.RandomState(rseed) X = rng.rand(N, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Generate a dataset and fit it with a high bias and a high variance model Step2: Prediction Performance as Training Dataset Size Increases
13,362
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper data_dir = './data/simpsons/moes_tavern_lines.txt' text = helper.load_data(data_dir) # Ignore notice, since we don't use it for analysing the data text = text[81:] view_sentence_range = (0, 10) DON'T MODIFY ANYTHING IN THIS CELL import num...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: TV Script Generation Step3: Explore the Data Step6: Implement Preprocessing Functions Step9: Tokenize Punctuation Step11: Preprocess all the...
13,363
<ASSISTANT_TASK:> Python Code: % matplotlib inline import numpy as np from scipy import signal import numpy.polynomial.polynomial as poly from netCDF4 import Dataset import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap from eofs.standard import Eof infile = 'data/hgt500.mon.mean.nc' ncin = Dataset(...
<SYSTEM_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. Load ght500 data Step2: 3. Detrend Step3: 4. Carry out EOF analysis Step4: 4.3 Retrieve the leading EOFs Step5: 5. Visualize leading EOFs...
13,364
<ASSISTANT_TASK:> Python Code: %matplotlib inline from ecell4.prelude import * with reaction_rules(): A + B == C | (0.01, 0.3) run_simulation(10.0, {'C': 60}, volume=1.0) from ecell4_base.core import * from ecell4_base import * w = ode.World(Real3(1, 1, 1)) w = ode.World(Real3(1, 1, 1)) w.add_molecules(Species('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: Here we give you a breakdown for run_simulation. Step2: Real3 is a coordinate vector. Step3: Use add_molecules to add molecules, remove_molecu...
13,365
<ASSISTANT_TASK:> Python Code: def unique_digits(x): odd_digit_elements = [] for i in x: if all (int(c) % 2 == 1 for c in str(i)): odd_digit_elements.append(i) return sorted(odd_digit_elements) <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:
13,366
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import pandas as pd import numpy as np df = pd.read_csv('./data/weight-height.csv') df.head() df.plot(kind = 'scatter', figsize = (7, 7), x = 'Height', y = 'Weight', title = 'Weight and Height in adults') 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: Cost Function Step2: Manual exploration of different values of W and b Step3: Linear Regression with Keras Step4: Evaluating Model Performanc...
13,367
<ASSISTANT_TASK:> Python Code: os.chdir('../results') molecule_string = [] casrn = [] test_type = [] dose = [] dose_amount = [] dose_units = [] route = [] organism = [] source = [] rootdir = '.' fnames = [] for dirpath, subdirlist, filelist in os.walk(rootdir): # Remove the _cas directory, as the files there do no...
<SYSTEM_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 expression traverses the current directory tree and accumulates the file names in fnames Step2: Read each file in the list as a p...
13,368
<ASSISTANT_TASK:> Python Code: import pkg_resources if pkg_resources.get_distribution('CGRtools').version.split('.')[:2] != ['4', '0']: print('WARNING. Tutorial was tested on 4.0 version of CGRtools') else: print('Welcome!') # load data for tutorial from pickle import load from traceback import format_exc with ...
<SYSTEM_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.1. Molecules Step2: Molecules has explicify_hydrogens and implicify_hydrogens methods to handle hydrogens. Step3: 3.2. Reactions standardiza...
13,369
<ASSISTANT_TASK:> Python Code: from msmbuilder.dataset import dataset import mdtraj as md import numpy as np from glob import glob from mdtraj.utils import timing import itertools from msmbuilder.featurizer import AtomPairsFeaturizer from msmbuilder.decomposition import tICA from msmbuilder.cluster import MiniBatchKMea...
<SYSTEM_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 featurize the trajectories into the pairwise distance between all the atoms in the EF hand and the catalytic Ca<sup>2+</sup>. Since we only l...
13,370
<ASSISTANT_TASK:> Python Code: data_in = '272091-815432' def criteria(word): meets = True if '11' in word or \ '22' in word or \ '33' in word or \ '44' in word or \ '55' in word or \ '66' in word or \ '77' in word or \ '88' in word or \ '99' in word: last_num = None ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: --- Part Two ---
13,371
<ASSISTANT_TASK:> Python Code: import urllib2 import csv import pandas as pd import numpy as np from scipy import stats import matplotlib.pyplot as plt %matplotlib inline url_X_train = 'http://statweb.stanford.edu/~tibs/ElemStatLearn/datasets/14cancer.xtrain' url_y_train = 'http://statweb.stanford.edu/~tibs/ElemStatLea...
<SYSTEM_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 Exploration Step2: To see a preview of the data, we can use the head and tail functions Step3: Let's see how the classes are distributed....
13,372
<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: Environments Step2: The code below defines a dummy RL environment for use in the examples below. Step3: Creating a Server and Client Step4: F...
13,373
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline cd hyperspectral import neon_aop_hyperspectral as neon_hs refl, metadata = neon_hs.aop_h5refl2array('../../../data/NEON_D16_MCRA_DP3_566300_4901000_reflectance.h5') b56 = refl[:,:,55] neon_hs.plot...
<SYSTEM_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 the hyperspectral functions into the variable neon_hs (for neon hyperspectral) Step2: Optionally, you can view the data stored in the me...
13,374
<ASSISTANT_TASK:> Python Code: import sys sys.path.append('..') import socnet as sn sn.graph_width = 320 sn.graph_height = 180 g = sn.load_graph('2-largura.gml', has_pos=True) sn.show_graph(g) from math import inf, isinf from queue import Queue s = 1 q = Queue() for n in g.nodes(): g.node[n]['d'] = inf g.node[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: A seguir, vamos configurar as propriedades visuais Step2: Por fim, vamos carregar e visualizar um grafo Step3: Caminhos de comprimento mínimo ...
13,375
<ASSISTANT_TASK:> Python Code: # sphinx_gallery_thumbnail_number = 2 # Authors: Eric Larson <larson.eric.d@gmail.com> # Sheraz Khan <sheraz@khansheraz.com> # Denis Engemann <denis.engemann@gmail.com> # # License: BSD (3-clause) import os.path as op import numpy as np import matplotlib.pyplot as plt im...
<SYSTEM_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 do some things in the name of speed, such as crop (which will Step2: Now we band-pass filter our data and create epochs. Step3: Comput...
13,376
<ASSISTANT_TASK:> Python Code: # Run some setup code for this notebook. import random import numpy as np from cs231n.data_utils import load_CIFAR10 import matplotlib.pyplot as plt from __future__ import print_function # This is a bit of magic to make matplotlib figures appear inline in the notebook # rather than in a n...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We would now like to classify the test data with the kNN classifier. Recall that we can break down this process into two steps Step2: Inline Qu...
13,377
<ASSISTANT_TASK:> Python Code: [x*x for x in range(3)] (x*x for x in range(3)) g = (x*x for x in range(3)) next(g) next(g) next(g) next(g) for i in g: print(i, end=", ") g = (x*x for x in range(3)) for i in g: print(i, end=", ") list(x*x for x in range(3)) def eager_updown(n): xs = [] for i in rang...
<SYSTEM_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 generator expression is lazy. Step2: You can use generators as iterators. Step3: A generator is single use. Step4: The list constructor for...
13,378
<ASSISTANT_TASK:> Python Code: from lsst.cwfs.instrument import Instrument from lsst.cwfs.algorithm import Algorithm from lsst.cwfs.image import Image, readFile import lsst.cwfs.plots as plots ff = np.loadtxt('../tests/testImages/FAM/ccdCenter189.txt') f25 = np.zeros((25,4)) ii = 0 for i in range(ff.shape[0]): if ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We use 25 fields for this test Step2: distribution of the test fields
13,379
<ASSISTANT_TASK:> Python Code: import slater print(slater.__doc__) print(slater.AOType.all_shells) print(slater.AOType.s) p_type = slater.AOType.from_string("p") print(p_type) f_type = slater.AOType.from_int(3) print(f_type, " l = ", f_type.l) AO_2s = slater.AO(n=2, aoType=slater.AOType.s, occ=1) print(AO_2s) print...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Atomic orbitals Step2: The atomic orbital class Step3: An occupency can be set to the shell. Step4: You can define the AO from a usual string...
13,380
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np import math import timeit import matplotlib.pyplot as plt %matplotlib inline from cs231n.data_utils import load_CIFAR10 def get_CIFAR10_data(num_training=49000, num_validation=1000, num_test=10000): Load the CIFAR-10 dataset from disk 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: What's this TensorFlow business? Step2: Example Model Step3: TensorFlow supports many other layer types, loss functions, and optimizers - you ...
13,381
<ASSISTANT_TASK:> Python Code: import random import numpy as np import matplotlib.pyplot as plt import quantities as pq import neo import elephant.unitary_event_analysis as ue # Fix random seed to guarantee fixed output random.seed(1224) # Download data !curl https://web.gin.g-node.org/INM-6/elephant-data/raw/master/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: Next, we download a data file containing spike train data from multiple trials of two neurons. Step3: Write a plotting function Step4: Load da...
13,382
<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: Visualizing objective functions by interpolating in randomly drawn directions Step3: Background Step7: This function has a saddle point at $(0...
13,383
<ASSISTANT_TASK:> Python Code: send(IP(dst="1.2.3.4")/TCP(dport=502, options=[("MSS", 0)])) ans = sr([IP(dst="8.8.8.8", ttl=(1, 8), options=IPOption_RR())/ICMP(seq=RandShort()), IP(dst="8.8.8.8", ttl=(1, 8), options=IPOption_Traceroute())/ICMP(seq=RandShort()), IP(dst="8.8.8.8", ttl=(1, 8))/ICMP(seq=RandShort())], ver...
<SYSTEM_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_ Adanced firewalking using IP options is sometimes useful to perform network enumeration. Here is more complicate one-liner Step2: Now that, ...
13,384
<ASSISTANT_TASK:> Python Code: data = pd.read_csv("./formatted_data.csv",header=0, index_col=False) data.head() drop_cols = ['Sensor_'+x+'1' for x in map(chr,range(65,81))] drop_cols.append('Batch_No') data = data.drop(drop_cols, axis=1) data.head() data.describe() from sklearn import preprocessing target = data['La...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: For each sensor the second column is the normalized form of the first column, so to avoid duplicates we drop the first column (A1,B1...P1) for e...
13,385
<ASSISTANT_TASK:> Python Code: import espressomd import espressomd.electrostatics import espressomd.observables import espressomd.accumulators import espressomd.math espressomd.assert_features(['WCA', 'ELECTROSTATICS']) import numpy as np import scipy.optimize %matplotlib inline import matplotlib.pyplot as plt np.rando...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: System setup Step2: We will build the charged rod from individual particles that are fixed in space. With this, we can use the particle-based e...
13,386
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns plt.rcParams['figure.figsize']=(20,5) #No usamos ninguan columna como índice para los datos Puertos=pd.read_csv('/Datos/Informacion_Estadistica_Mensual_de_las_Marinas_FOP_180216...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Se revisan las cantidades de filas y columanas, se visulizan los primeros y los últimos registros. Step2: Lo primero que trato de explorar es l...
13,387
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pylab as plt import seaborn as sns np.set_printoptions(precision=4, suppress=True) sns.set_context('notebook') %matplotlib inline theta = [[1., 2], [.5, 2.5], [.25, 2.75]] def f(x, a, b): if x < a or x > b: return 0 else: retur...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Draw uniform density Step2: Simulate data and draw histogram Step3: Simulate data and estimate model parameter by MLE
13,388
<ASSISTANT_TASK:> Python Code: # Define our function (Python) def duff_osc_ss(x, params): omega = params['omega'] t = params['cur_time'] xd = np.array([[x[1]], [-x[0] - 0.1 * x[0]**3 - 0.1 * x[1] + 1 * sin(omega * t)]]) return xd # Arguments are name of derivative function, number 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: Mousai can easily recreate the near-continuous response Step2: Let's sweep through driving frequencies to find a frequency response function St...
13,389
<ASSISTANT_TASK:> Python Code: import numpy as np def rolling_apply(fun, a, w): r = np.empty(a.shape) r.fill(np.nan) for i in range(w - 1, a.shape[0]): r[i] = fun(a[(i-w+1):i+1]) return r def rolling_window(a, window): shape = a.shape[:-1] + (a.shape[-1] - window + 1, window) strides = ...
<SYSTEM_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 loop in Python are however very slow compared to a loop in C code. Fortunately there is a trick to make NumPy perform this looping internally ...
13,390
<ASSISTANT_TASK:> Python Code: import joblib features=joblib.load('clean_LCfeatures.p') labels=joblib.load('clean_LClabels.p') clabels=joblib.load('clean_LCclassifierlabel.p') import numpy as np import pandas as pd from time import time from IPython.display import display # Allows the use of display() for DataFrames # ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Some weird scaling going on, just to check my sanity, check the max values of a few of the features. these may need to be log scaled just to dea...
13,391
<ASSISTANT_TASK:> Python Code: def lstrip(iterable, strip_value): Return iterable with strip_value removed from the beginnning stripped = [] iterator = iter(iterable) for item in iterator: if not item == strip_value: stripped.append(item) break for item ...
<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 the iterator protocol Step5: Bonus1 Step6: Experiments Step11: Bonus2 Step14: Using dropwhile helper function in itertools module Ste...
13,392
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 import numpy as np import pandas as pd import patsy as ps from statsmodels.sandbox.regression.gmm import IV2SLS import os, sys from dowhy import CausalModel n_points = 1000 education_abilty = 1 education_voucher = 2 income_abilty = 2 income_education = ...
<SYSTEM_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 dataset Step2: Using DoWhy to estimate the causal effect of education on future income Step3: We have an estimate, indicating that...
13,393
<ASSISTANT_TASK:> Python Code: import varout.layers import varout.objectives import varout.experiments import lasagne.layers import lasagne.nonlinearities import lasagne.init import theano import theano.tensor as T import numpy as np import holonets import holoviews as hv %load_ext holoviews.ipython dataset = varout.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: Another quirk of the experiment is that they decided to merge the MNIST validation set into the training set; so we have to validation set Step2...
13,394
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.read_csv("datascience.csv", encoding='gb18030') #注意它的编码是中文GB18030,不是Pandas默认设置的编码,所以此处需要显式指定编码类型,以免出现乱码错误。 # 之后看看数据框的头几行,以确认读取是否正确。 df.head() #我们看看数据框的长度,以确认数据是否读取完整。 df.shape import jieba def chinese_word_cut(mytext): return " ".join(jieba.cut(mytext)) 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: (1024, 3) Step2: 我们需要人为设定主题的数量。这个要求让很多人大跌眼镜——我怎么知道这一堆文章里面多少主题?! Step3: 到这里,LDA已经成功帮我们完成了主题抽取。但是我知道你不是很满意,因为结果不够直观。
13,395
<ASSISTANT_TASK:> Python Code: from IPython.core.display import display, HTML;from string import Template; HTML('<script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>') css_text2 = ''' #main { float: left; width: 750px;}#sidebar { float: right; width: 100px;}#sequence { width: 600px; height: 70px;}#lege...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Graphic Interpretation
13,396
<ASSISTANT_TASK:> Python Code: !pip install -r requirements_notebook.txt !kubectl create namespace cifar10 %%writefile broker.yaml apiVersion: eventing.knative.dev/v1 kind: broker metadata: name: default namespace: cifar10 !kubectl create -f broker.yaml %%writefile event-display.yaml apiVersion: apps/v1 kind: Deploy...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Setup Resources Step2: Create the Kfserving image classification model for Cifar10. We add in a logger for requests. Step3: Create the pretrai...
13,397
<ASSISTANT_TASK:> Python Code: # Load libraries from sklearn.svm import SVC from sklearn import datasets from sklearn.preprocessing import StandardScaler import numpy as np #Load data with only two classes iris = datasets.load_iris() X = iris.data[:100,:] y = iris.target[:100] # Standarize features scaler = StandardS...
<SYSTEM_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 Iris Flower Dataset Step2: Standardize Features Step3: Train Support Vector Classifier Step4: View Support Vectors Step5: View Indices ...
13,398
<ASSISTANT_TASK:> Python Code: from openhunt.mordorutils import * spark = get_spark() mordor_file = "https://raw.githubusercontent.com/OTRF/mordor/master/datasets/small/windows/defense_evasion/host/empire_wdigest_downgrade.tar.gz" registerMordorSQLTable(spark, mordor_file, "mordorTable") df = spark.sql( ''' SELECT `@...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Download & Process Mordor Dataset Step2: Analytic I
13,399
<ASSISTANT_TASK:> Python Code: tables = Gaia.load_tables() querystart = r"SELECT " rr_params = ["source_id", "pf", "pf_error", "int_average_g", "int_average_g_error", "int_average_bp", "int_average_bp_error", "int_average_rp", "int_average_rp_error", "metallicity", "metallicity_error", ...
<SYSTEM_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 construst our query. We use the prebuilt rr_lyrae table in Gaia DR2, and get all of the parameters of interest. We will retrieve st...