Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
2,700
<ASSISTANT_TASK:> Python Code: import pycuda.autoinit import pycuda.driver as drv import numpy from pycuda.compiler import SourceModule mod = SourceModule( __global__ void multiplicar(float *dest, float *a, float *b) { const int i = threadIdx.x; dest[i] = a[i] * b[i]; } ) multiplicar = mod.get_function("multiplicar...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: ¿Por qué PyCUDA? Step2: Al correr este programa vamos a obtener un montón de ceros; algo no muy interesante. Sin embargo detrás de escenas sí p...
2,701
<ASSISTANT_TASK:> Python Code: %pylab inline matplotlib.rcParams['figure.figsize'] = 9, 6 from numpy import * import scipy.integrate # This code is not very efficient, it recalculates many quantities from many # different functions. It is easy to maintain though, and does not need to be # run very often. def r(t,p,R,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: Development of semi-analytic method Step2: Illustration of focal plane images Step3: Image moments using semi-analytic method Step4: Fitting ...
2,702
<ASSISTANT_TASK:> Python Code:: import matplotlib.pyplot as plt plt.hist(L) <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:
2,703
<ASSISTANT_TASK:> Python Code: plt.imshow(plt.imread('./res/fig11_2.png')) show_image('fig11_5.png') show_image('fig11_7.png', figsize=(8, 10)) show_image('fig11_9.png', figsize=(8, 10)) show_image('fig11_10.png', figsize=(8, 10)) show_image('fig11_13.png') show_image('ex11_17.png') #Exercise <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 11.2.2 Using Eigenvectors for Dimensionality Reduction Step2: 11.3.2 Interpretation of SVD Step3: If we set the $s$ smallest singular values t...
2,704
<ASSISTANT_TASK:> Python Code: %pylab inline rcParams["figure.figsize"] = (8, 6) rcParams["axes.grid"] = True from IPython.display import display, clear_output from mpl_toolkits.axes_grid1 import make_axes_locatable from time import sleep from __future__ import division def cart2pol(x, y): theta = arctan2(y, x) ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Self-diffusion of water Step2: The self-diffusion of water at body temperature and standard pressure, in micrometers<sup>2</sup>/millimeter, is...
2,705
<ASSISTANT_TASK:> Python Code: %matplotlib inline path = "data/galaxy/sample/" #path = "data/galaxy/" train_path = path + 'train/' valid_path = path + 'valid/' test_path = path + 'test/' results_path = path + 'results/' model_path = path + 'model/' from utils import * batch_size = 32 num_epoch = 1 import pandas as pd 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: First Model Step2: To Do
2,706
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt from ttim import * ml = ModelMaq(kaq=[1, 20, 2], z=[25, 20, 18, 10, 8, 0], c=[1000, 2000], Saq=[0.1, 1e-4, 1e-4], Sll=[0, 0], phreatictop=True, tmin=0.1, tmax=1000) w = Well(ml, xw=0, yw=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: Consider a well in the middle aquifer of a three aquifer system located at $(x,y)=(0,0)$. The well starts pumping at time $t=0$ at a discharge o...
2,707
<ASSISTANT_TASK:> Python Code: # Assign value 1 to variable x x = 1 x = 1 # Assign value 1 to variable x This is a multi-line comment. Assign value 1 to variable x. x = 1 print(1) # Print a constant x = 2014 print(x) # Print an integer variable xstr = "Hello World." # Print a string print(xstr) print(x,xstr) # 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: Comments can also be placed on the same line as the code as shown here. Step3: For multi-line comments, use triple-quoted strings. Step4: 1.4 ...
2,708
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd from sklearn.preprocessing import StandardScaler data = load_data() scaler = StandardScaler() scaler.fit(data) scaled = scaler.transform(data) inversed = scaler.inverse_transform(scaled) <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:
2,709
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', validation_size=0) img = mnist.train.images[2] plt.imshow(img.reshape((28, 28)), cmap='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: Step1: Network Architecture Step2: Training Step3: Denoising Step4: Checking out the performance
2,710
<ASSISTANT_TASK:> Python Code: import cashflows as cf cflo = cf.cashflow(const_value= 0,nper=6, spec = [(0, -1000), (1, 400), (2, 360), (3, 320), ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Criterio de la tasa interna de retorno Step2: Tasa Interna de Retorno Modificada. Step3: Análisis de sensibilidad
2,711
<ASSISTANT_TASK:> Python Code: import os import matplotlib.pyplot as plt from ascat.h_saf import AscatSsmDataRecord test_data_path = os.path.join('..', 'tests','ascat_test_data', 'hsaf') h109_path = os.path.join(test_data_path, 'h109') h110_path = os.path.join(test_data_path, 'h110') h111_path = os.path.join(test_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: A soil moisture time series is read for a specific grid point. The data attribute contains a pandas.DataFrame object. Step2: Time series plots ...
2,712
<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...
2,713
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np np.set_printoptions(precision=2) from sklearn.datasets import load_digits from sklearn.cross_validation import train_test_split from sklearn.svm import LinearSVC digits = load_digits() X, y = digits.data, digits.target ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Here, we predicted 94.4% of samples correctly. For multi-class problems, it is often interesting to know which of the classes are hard to predic...
2,714
<ASSISTANT_TASK:> Python Code: import csv data = [] revid = [] with open('page_data.csv') as csvfile: reader = csv.reader(csvfile) for row in reader: data.append([row[0],row[1],row[2]]) revid.append(row[2]) # Remove the first element ('rev_id') from revid so that the list only contains revision ...
<SYSTEM_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 the data (country and population) from the population file Step2: Getting article quality predictions Step3: Write a function to make ...
2,715
<ASSISTANT_TASK:> Python Code: from accounts import create_accounts_json num_files = 25 n = 100000 # number of accounts per file k = 500 # number of transactions create_accounts_json(num_files, n, k) from nfs import create_denormalized create_denormalize() from random_array import random_array random_array() Image...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Denormalize NFS Data Step2: Random Array Step3: Dask Step4: Dask Array Step5: Arithmetic and scalar mathematics, +, *, exp, log, ... Step6: ...
2,716
<ASSISTANT_TASK:> Python Code: %load_ext watermark %watermark -a '' -u -d -v -p numpy,pandas,matplotlib,scipy,sklearn %matplotlib inline # Added version check for recent scikit-learn 0.18 checks from distutils.version import LooseVersion as Version from sklearn import __version__ as sklearn_version from sklearn.datase...
<SYSTEM_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: Visualize data Step3: Date Preprocessing Step4: Classifier #1 Perceptron Step5: Classifier #2 Logistic Regression Step6: C...
2,717
<ASSISTANT_TASK:> Python Code: import nbformat from nbformat.v4 import new_notebook nb = new_notebook() display(nb) nbformat.validate(nb) nb.pizza = True nbformat.validate(nb) nb = new_notebook() # get rid of pizza from nbformat.v4 import new_code_cell, new_markdown_cell, new_raw_cell md = new_markdown_cell("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: cells Step2: What happens if it's invalid? Step3: Cells and their sources Step4: Three types of cells Step5: cell_type Step6: cell_type Ste...
2,718
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import tensorflow as tf import math def tf_assert_shape(tensors, requested_shape): if not type(tensors) is list: tensors = [tensors] for tensor in tensors: shape = tensor.get_shape().as_list() error_msg = 'Tensor ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Generate some data Step2: Model Step3: Add the loss Step4: Trainning Step5: Sample the model Step6: inspecting the model
2,719
<ASSISTANT_TASK:> Python Code: factors(689) max_seq_len = 682 #full_train_size = 55820 #train_size = 55800 #small_train_size = 6000 #just because of performance reasons, no statistics behind this decision #test_size = 6200 data_path = '../../../../Dropbox/data' phae_path = data_path + '/price_hist_autoencoder' csv_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: Step 1 - collect data Step2: Step 2 - Build model Step3: targets Step4: Quick test run Step5: Step 3 training the network Step6: Conclusion...
2,720
<ASSISTANT_TASK:> Python Code: import colour colour.utilities.filter_warnings(True, False) sorted(colour.LIGHTNESS_METHODS.keys()) colour.colorimetry.lightness_Glasser1958(10.08) colour.lightness(10.08, method='Glasser 1958') %matplotlib inline from colour.plotting import * colour_plotting_defaults() # Plotting 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: Note Step2: Note Step3: Wyszecki (1963) Method Step4: Note Step5: CIE 1976 Method Step6: Note Step7: Fairchild and Wyble (2010) Method Ste...
2,721
<ASSISTANT_TASK:> Python Code: # Install libraries. # The magic cells insures that those libraries can be part of a custom container # if moving the code somewhere else. %pip install -q googleads %pip install -q -U kfp matplotlib Faker --user # Automatically restart kernel after installs # import IPython # app = IPyth...
<SYSTEM_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 packages Step2: Set up your GCP project Step3: Authenticate your GCP account Step4: Create a working dataset Step5: Load example tabl...
2,722
<ASSISTANT_TASK:> Python Code: import sys sys.path.append("..") import numpy as np from pstd import PSTD, PML, Medium, PointSource from acoustics import Signal #import seaborn as sns %matplotlib inline x = 30.0 y = 20.0 z = 0.0 soundspeed = 343.2 density = 1.296 maximum_frequency_target = 200.0 medium = Medium(sounds...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Configuration Step2: Create model Step3: The model is only finite and to prevent aliasing we need a Perfectly Matched Layer. Step4: Now we cr...
2,723
<ASSISTANT_TASK:> Python Code: %pylab inline import GPyOpt from numpy.random import seed func = GPyOpt.objective_examples.experiments1d.forrester() domain =[{'name': 'var1', 'type': 'continuous', 'domain': (0,1)}] X_init = np.array([[0.0],[0.5],[1.0]]) Y_init = func.f(X_init) iter_count = 10 current_iter = 0 X_step...
<SYSTEM_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 the purposes of this notebook we are going to use one of the predefined objective functions that come with GPyOpt. However the key thing to ...
2,724
<ASSISTANT_TASK:> Python Code: import numpy as np import tensorflow as tf PROJECT_ID = 'yourProject' # Change to your project. PROJECT_NUMBER = 'yourProjectNumber' # Change to your project number BUCKET = 'yourBucketName' # Change to the bucket you created. REGION = 'yourPredictionRegion' # Change to your AI Platform ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Configure GCP environment settings Step2: Authenticate your GCP account Step3: Deploy the embedding lookup model to AI Platform Prediction Ste...
2,725
<ASSISTANT_TASK:> Python Code: import tensorflow as tf print(tf.__version__) # Load the diabetes dataset from sklearn.datasets import load_diabetes diabetes_datasets = load_diabetes() print(diabetes_datasets["DESCR"]) # Save the input and target variables print(diabetes_datasets.keys()) data = diabetes_datasets["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: Load and pre-process the data Step2: Split the data into train and test sets Step3: First model Step4: Compile and train the first unregulari...
2,726
<ASSISTANT_TASK:> Python Code: %pdb 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 = (1000, 1010) DON'T MODIFY ANYTHING IN THIS CELL ...
<SYSTEM_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...
2,727
<ASSISTANT_TASK:> Python Code: xi, l, rho = symbols('xi, l, rho') # Shape functions S = Matrix(np.zeros((4, 12))) x2 = (1 - xi) S[0, 0 ] = x2 # extension S[0, 6 ] = xi S[1, 1 ] = x2**2 * (3 - 2*x2) # y-deflection S[1, 7 ] = xi**2 * (3 - 2*xi) S[1, 5 ] = -x2**2 * (x2 - 1) * l S[1, 11] = xi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Mass matrix Step2: Integrate the density distribution with the shape functions. Step3: Special case Step4: Shape integrals Step5: First shap...
2,728
<ASSISTANT_TASK:> Python Code: b = 5 b = 6 assert b == 6 # Here's a comment! b = 5 # Here's another comment! Neither of these comments are evaluated by Python! # this is my comment b = 6 print(b) print(500) # Integer i = 1 # String s = "Hello World" # Float f = 55.55 hundred_integer = 100 hundred_string = "hundred" ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 4 Step2: 5 Step3: 6 Step4: 7 Step5: 8 Step6: 9 Step7: 11 Step8: 12 Step9: 13 Step10: 14 Step11: 15 Step12: 16
2,729
<ASSISTANT_TASK:> Python Code: %matplotlib inline %load_ext autoreload %autoreload 2 import sys sys.path.append('../../') import imp import macrodensity as md import math import numpy as np import matplotlib.pyplot as plt import os if os.path.isfile('LOCPOT'): print('LOCPOT already exists') else: os.system('bu...
<SYSTEM_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 the potential Step2: Look for pore centre points Step3: We want to try a range of sampling area sizes. Step4: From the OUTCAR the VBM is...
2,730
<ASSISTANT_TASK:> Python Code: from geopy.geocoders import GoogleV3 geolocator = GoogleV3() # geolocator = GoogleV3(api_key=<your_google_api_key>) t = pd.read_csv('https://data.cityofnewyork.us/api/views/43nn-pn8j/rows.csv?accessType=DOWNLOAD', header=0, sep=',', dtype={'PHONE':str, 'INSPECTION DATE':str}); ## Helper ...
<SYSTEM_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 Data Step2: Data preprocessing Step3: Create a dictionary of unique Addresses. We do this to avoid calling the Google geocoding api mul...
2,731
<ASSISTANT_TASK:> Python Code: def sort(L): if len(L) <= 1: return L x, y, R = L[0], L[-1], L[1:-1] p1, p2 = min(x, y), max(x, y) L1, L2, L3 = partition(p1, p2, R) if p1 == p2: return sort(L1) + [p1] + L2 + [p2] + sort(L3) else: return sort(L1) + [p1] + sort(L2) + ...
<SYSTEM_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 function partition receives three arguments
2,732
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline Xtrain = pd.read_csv('./data/multivariate_tr.csv') Xtrain.head() Xtrain.describe() Xtest = pd.read_csv('./data/multivariate_ts.csv') Xtest.head() Xtest.describe() from scipy.stats import multivariat...
<SYSTEM_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 - Check that the training data is suitable for a multivariate modeling approach (multivariate_tr.csv & multivariate_ts.csv) Step2: 2 - Check ...
2,733
<ASSISTANT_TASK:> Python Code: from symbulate import * %matplotlib inline cards = ['club', 'diamond', 'heart', 'spade'] * 4 # 4 cards of each suit len(cards) P = BoxModel(cards, size=2, replace=False, order_matters=True) P.draw() sims = P.sim(10000) sims sims = P.sim(10000) sims.tabulate() def first_is_heart(x):...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Part I. Introduction to Symbulate, and conditional versus unconditional probability Step2: Now we define a BoxModel probability space correspon...
2,734
<ASSISTANT_TASK:> Python Code: !pip install -I "phoebe>=2.2,<2.3" %matplotlib inline import phoebe from phoebe import u # units import numpy as np import matplotlib.pyplot as plt logger = phoebe.logger() b = phoebe.default_binary() b.add_dataset('lc', dataset='lc01') b.add_dataset('mesh', times=[0], columns=['intensit...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: As always, let's do imports and initialize a logger and a new bundle. See Building a System for more details. Step2: Relevant Parameters Step3...
2,735
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'uhh', 'sandbox-1', 'aerosol') # 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...
2,736
<ASSISTANT_TASK:> Python Code: from theano.sandbox import cuda %matplotlib inline import utils; reload(utils) from utils import * from __future__ import division, print_function path = get_file('nietzsche.txt', origin="https://s3.amazonaws.com/text-datasets/nietzsche.txt") text = open(path).read() print('corpus length...
<SYSTEM_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 Step2: Sometimes it's useful to have a zero value in the dataset, e.g. for padding Step3: Map from chars to indices and back again Step4...
2,737
<ASSISTANT_TASK:> Python Code: from search import * %psource Problem %psource GraphProblem romania_map = UndirectedGraph(dict( Arad=dict(Zerind=75, Sibiu=140, Timisoara=118), Bucharest=dict(Urziceni=85, Pitesti=101, Giurgiu=90, Fagaras=211), Craiova=dict(Drobeta=120, Rimnicu=146, Pitesti=138), Drobet...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Review Step2: The Problem class has six methods. Step3: Now it's time to define our problem. We will define it by passing initial, goal, graph...
2,738
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy.misc import factorial from scipy.optimize import curve_fit import scipy.constants as cst import matplotlib.pyplot as plt %matplotlib inline ao = cst.physical_constants["Bohr radius"][0] / cst.angstrom print("a0 = {} A".format(ao)) def rms(y_th, y): co...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Matplotlib is used in order to make plots Step2: Bhor radius is defined in angstrom from scipy.constants module. Step4: A root mean square fun...
2,739
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline from IPython.display import HTML HTML('../style/course.css') #apply general CSS from mpl_toolkits.mplot3d import Axes3D import plotBL HTML('../style/code_toggle.html') ant1 = np.array([-500e3,500e3,0]) # in m ant2 ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import section specific modules Step2: 4.4.1 UV coverage Step3: Let's express the corresponding physical baseline in ENU coordinates. Step4: ...
2,740
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns; sns.set() # for plot styling import numpy as np from sklearn.datasets.samples_generator import make_blobs X, y_true = make_blobs(n_samples=300, centers=4, cluster_std=0.60, random_state=0) pl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: k-Means Algorithm Step2: Caveats of expectation–maximization Step3: Here the E–M approach has converged, but has not converged to a globally o...
2,741
<ASSISTANT_TASK:> Python Code: import pandas raw_elections_2015 = pandas.read_csv("test2015.csv",delimiter='\t') raw_elections_2016 = pandas.read_csv("test2016.csv",delimiter='\t') def find_PODEMOS(words): if 'PODEMOS' in words: return 'PODEMOS' if 'EN COMU' == words: return 'PODEMOS' return...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <p>All the data are string</p> Step2: <h3>Despite all the corruption cases from the PP, only this growh their votes in 2016</h3>
2,742
<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...
2,743
<ASSISTANT_TASK:> Python Code: import numpy as np %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns import networkx as nx K_5=nx.complete_graph(5) nx.draw(K_5) def complete_deg(n): a = np.identity((n), dtype = np.int) for element in np.nditer(a, op_flags=['readwrite']): if eleme...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Complete graph Laplacian Step2: The Laplacian Matrix is a matrix that is extremely important in graph theory and numerical analysis. It is defi...
2,744
<ASSISTANT_TASK:> Python Code: import numpy as np %matplotlib inline import matplotlib.pyplot as plt fake_depth = np.linspace(100, 150, 101) fake_log = np.array([np.random.choice([0, 1]) for _ in fake_depth]) plt.figure(figsize=(15, 1)) plt.plot(fake_depth, fake_log, 'o-') from striplog import Striplog, Component comp...
<SYSTEM_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 a striplog Step2: Each Interval in the striplog looks like Step3: Plot the intervals Step5: Or we can make one with a bit more control S...
2,745
<ASSISTANT_TASK:> Python Code: # Function to generate target value for a given x. true_func = lambda X: np.cos(1.5 * np.pi * X) np.random.seed(0) # Training Set: No. of random samples used for training the model n_samples = 30 x = np.sort(np.random.rand(n_samples)) y = true_func(x) + np.random.randn(n_samples) * 0.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: Polynomial with degree 1 is a straight line - Underfitting<br> Step2: <h4>Model with degree 4 features</h4> Step3: Good Fit with degree 4 poly...
2,746
<ASSISTANT_TASK:> Python Code: # Author: Ivana Kojcic <ivana.kojcic@gmail.com> # Eric Larson <larson.eric.d@gmail.com> # Kostiantyn Maksymenko <kostiantyn.maksymenko@gmail.com> # Samuel Deslauriers-Gauthier <sam.deslauriers@gmail.com> # License: BSD (3-clause) import os.path as op import numpy a...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In order to simulate source time courses, labels of desired active regions Step3: Create simulated source activity Step4: Here, Step5: Simul...
2,747
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr> # # License: BSD-3-Clause import numpy as np import matplotlib.pyplot as plt import mne from mne.time_frequency import tfr_morlet from mne.stats import permutation_cluster_1samp_test from mne.datasets import sample print(__doc__)...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set parameters Step2: Define adjacency for statistics Step3: Compute statistic Step4: View time-frequency plots
2,748
<ASSISTANT_TASK:> Python Code: #On windows #import findspark #findspark.init(spark_home="C:/Users/me/software/spark-1.6.3-bin-hadoop2.6/") import pyspark import numpy as np # we'll be using numpy for some numeric operations sc = pyspark.SparkContext(master="local[*]", appName="tour") sc.stop() # To try the SparkContex...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: local Step2: Lambda functions Step3: Creating RDDS Step4: RDD operations Step5: Step7: Lazy evaluation Step8: Persistence Step9: If we d...
2,749
<ASSISTANT_TASK:> Python Code: plt.plot(pop_x, pop_y, 'o') plt.xlabel('Year') plt.ylabel('Population [Millions]') plt.show() graphene_used = np.concatenate( (np.ones(5), np.zeros(5)) ) temperature = np.concatenate( (T, T) ) intercept = np.ones(10) x_mat = np.column_stack( (intercept, temperature, graphene_used) ) prin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Example 1 Answer Step2: Example 3
2,750
<ASSISTANT_TASK:> Python Code: !pip install -qq optax import numpy as np import jax from jax import numpy as jnp from jax import grad, jit, vmap, random try: import optax except ModuleNotFoundError: %pip install -qq optax import optax try: import tensorflow_datasets as tfds except ModuleNotFoundError: ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step4: Plotting functions Step14: Restricted Boltzmann Machines Step15: Load MNIST Step17: Training with optax Step18: Evaluating Training Step20: ...
2,751
<ASSISTANT_TASK:> Python Code: import numpy from keras.datasets import imdb from keras.models import Sequential from keras.layers import Dense from keras.layers import LSTM from keras.layers.embeddings import Embedding from keras.preprocessing import sequence # fix random seed for reproducibility numpy.random.seed(7) #...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: You can see that this simple LSTM with little tuning achieves near state-of-the-art results on the IMDB problem. Importantly, this is a template...
2,752
<ASSISTANT_TASK:> Python Code: import numpy as np ints = np.arange(1,21) pows = 2**ints print(pows) print(pows[9], pows[19]) sum = 0 for i in range(1, 100): sum += i if sum > 200: print(i, sum) break from scipy.special import factorial def fxn(n, k): '''Computes the number of permutations ...
<SYSTEM_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^{10} \approx 10^3$$ Step2: 1.3 Answer Step3: 1.4 Answer Step4: 2. Watching Youtube with the Geometric Distribution (15 Points) Step5: 2....
2,753
<ASSISTANT_TASK:> Python Code: # Execute this cell import numpy as np import scipy.stats from astroML import stats as astroMLstats data = np.random.random(1000) # Execute this cell mean = np.mean(data) print mean # Execute this cell. Think about what it is doing. median = np.median(data) mask = data>0.75 data[mask] ...
<SYSTEM_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 arithmetic mean (or Expectation value) is Step2: While it is perhaps most common to compute the mean, the median is a more robust estimator...
2,754
<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: Functional API Step2: 前書き Step3: データの形状は、784次元のベクトルとして設定されます。各サンプルの形状のみを指定するため、バッチサイズは常に省略されます。 Step4: 返されるinputsには、モデルに供給する入力データの形状とdtypeについ...
2,755
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy.linalg as la a = np.array([[1,2,3], [4,5,6], [7,8,9]]) m = np.matrix([[1,2,3], [4,5,6]]) print('a=', a) print(19*'-') print('m=', m) print(19*'-') print('ndim(a) = ', np.ndim(a)) print('a.ndim = ', a.ndim) print(19*'-') print('np.ndim(m) = ', np.ndim(m)) 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: <span style="color Step2: <span style="color Step3: <span style="color Step4: <span style="color Step5: <span style="color Step6: <span sty...
2,756
<ASSISTANT_TASK:> Python Code: ipd.display( ipd.YouTubeVideo("ajCYQL8ouqw") ) ipd.display( ipd.YouTubeVideo("PrVu9WKs498", start=8) ) ipd.display( ipd.YouTubeVideo("Cxj8vSS2ELU", start=540) ) ipd.display( ipd.YouTubeVideo("ECvinPjmBVE", start=6) ) ipd.display( ipd.YouTubeVideo("DiW6XVFeFgo", start=60)) ipd.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: (Chords) Step2: One more Step3: Why MIR? Step4: Example Step5: Example Step6: Example Step7: Example
2,757
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import scipy.stats as st import seaborn from IPython.html.widgets import interact, interactive, fixed#functii necesare pt interactivitate from IPython.display import clear_output, display, HTML rcdef = plt.rcParams.copy...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: seaborn este o biblioteca destinata vizualizarii in statistica. Nu este inclusa in distributia Anaconda. Se bazeaza pe matplotlib si se instalea...
2,758
<ASSISTANT_TASK:> Python Code: import numpy as np from matplotlib import pyplot %matplotlib inline from matplotlib import rcParams rcParams['font.family'] = 'serif' rcParams['font.size'] = 16 a=0.3 # diffusion constant L = 1. # length of domain J = 41 ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Physical parameters Step2: Specify spatial grid in Python Step3: Specify temporal grid in Python Step4: Goal Step5: That leaves us with two ...
2,759
<ASSISTANT_TASK:> Python Code: #relatively fast networks package (pip install python-igraph) that I used for these homeworks import igraph # slow-and-steady networks package. fewer bugs, easier drawing import networkx as nx # plots! import matplotlib.pyplot as plt from matplotlib import style %matplotlib inline # othe...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Graphs! Step2: Now. What's the difference between that (^) drawing of nodes and edges and a completely random assembly of dots and lines? How c...
2,760
<ASSISTANT_TASK:> Python Code: import ipyrad as ip ## this is a comment, it is not executed, but the code below it is. import ipyrad as ip ## here we print the version print ip.__version__ ## create an Assembly object named data1. data1 = ip.Assembly("data1") ## setting/modifying parameters for this Assembly object...
<SYSTEM_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 with Jupyter notebooks Step2: The ipyrad API data structures Step3: Setting parameters Step4: Instantaneous parameter (and er...
2,761
<ASSISTANT_TASK:> Python Code: import helper source_path = 'data/letters_source.txt' target_path = 'data/letters_target.txt' source_sentences = helper.load_data(source_path) target_sentences = helper.load_data(target_path) source_sentences[:50].split('\n') target_sentences[:50].split('\n') def extract_character_voca...
<SYSTEM_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 examining the current state of the dataset. source_sentences contains the entire input sequence file as text delimited by newline...
2,762
<ASSISTANT_TASK:> Python Code: import numpy as np import sys from casadi import * import os import time # Add do_mpc to path. This is not necessary if it was installed via pip sys.path.append('../../../') # Import do_mpc package: import do_mpc import matplotlib.pyplot as plt import pandas as pd sp = do_mpc.sampling.Sa...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Toy example Step 1 Step2: We then introduce new variables to the SamplingPlanner which will later jointly define a sampling case. Think of head...
2,763
<ASSISTANT_TASK:> Python Code: !rm -rf * !rm -rf .config !rm -rf .git !git clone https://github.com/google-research/scenic.git . !python -m pip install -q . !python -m pip install -r scenic/projects/baselines/clip/requirements.txt !echo "Done." import os import jax from matplotlib import pyplot as plt import numpy as 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: Choose config Step2: Load the model and variables Step3: Prepare image Step4: Prepare text queries Step5: Get predictions Step6: Plot predi...
2,764
<ASSISTANT_TASK:> Python Code: peyton_dataset_url = 'https://github.com/facebookincubator/prophet/blob/master/examples/example_wp_peyton_manning.csv' peyton_filename = '../datasets/example_wp_peyton_manning.csv' import pandas as pd import numpy as np from fbprophet import Prophet # NB: this didn't work as of 8/22/17 #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: Fit the model by instantiating a new Prophet object. Any settings required for the forecasting procedure are passed to this object upon construc...
2,765
<ASSISTANT_TASK:> Python Code: # Configure Jupyter so figures appear in the notebook %matplotlib inline # Configure Jupyter to display the assigned value after an assignment %config InteractiveShell.ast_node_interactivity='last_expr_or_assign' # import functions from the modsim.py module from modsim import * data = pd...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Code from the previous chapter Step2: Interpolate the insulin data. Step3: The glucose minimal model Step5: Here's a version of make_system t...
2,766
<ASSISTANT_TASK:> Python Code: m = 1.00 k = 4*pi*pi wn = 2*pi T = 1.0 z = 0.02 wd = wn*sqrt(1-z*z) c = 2*z*wn*m NSTEPS = 200 # steps per second h = 1.0 / NSTEPS def load(t): return np.where(t<0, 0, np.where(t<5, sin(0.5*wn*t)**2, 0)) t = np.linspace(-1, 6, 7*NSTEPS+1) plt.plot(t, load(t)) plt.ylim((-0.05, 1.05)); ...
<SYSTEM_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 the Loading Step2: Numerical Constants Step3: Vectorize the time and the load Step4: Integration Step5: Results Step6: Comparison St...
2,767
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np scatx=np.random.rand(50) scaty=np.random.randn(50) f= plt.figure(figsize=(9,6)) plt.scatter(scatx,scaty,c=u'k',marker=u'o',alpha=1) plt.xlabel('X') plt.ylabel('Y') plt.title("Scatter Plot of A Set of Random Data") x= ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Scatter plots Step2: Histogram
2,768
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np df = pd.read_csv('../data/train.csv') df.head(10) df = df.drop(['Name', 'Ticket', 'Cabin'], axis=1) df.info() df = df.dropna() df['Sex'].unique() df['Gender'] = df['Sex'].map({'female': 0, 'male':1}).astype(int) df['Embarked'].unique() df['Port...
<SYSTEM_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 - Cleaning data Step2: We notice that the columns describe features of the Titanic passengers, such as age, sex, and class. Of particula...
2,769
<ASSISTANT_TASK:> Python Code: from k2datascience import hr_analytics from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity = "all" %matplotlib inline hr = hr_analytics.HR() print(f'Data Shape\n\n{hr.data.shape}') print('\n\nColumns\n\n{}'.format('\n'.join(hr.data.columns)...
<SYSTEM_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: Explore the data Step3: Probability, Expectation Values, and Variance Step4: Compute the 25th, 50th, and 90th percentiles fo...
2,770
<ASSISTANT_TASK:> Python Code: chain = sisl.Geometry([0]*3, sisl.Atom(1, R=1.), sc=[1, 1, 10]) chain.set_nsc([3, 3, 1]) # Transport along y-direction chain = chain.tile(20, 0) He = sisl.Hamiltonian(chain) He.construct(([0.1, 1.1], [0, -1])) Hd = He.tile(20, 1) He.write('ELEC.nc') Hd.write('DEVICE.nc') with open('RUN.fd...
<SYSTEM_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 of the $k$-point sampling for TBtrans. Step2: Run these two executables
2,771
<ASSISTANT_TASK:> Python Code:: def load_doc(filename): # open the file as read only file = open(filename, 'r') # read all text text = file.read() # close the file file.close() return text <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:
2,772
<ASSISTANT_TASK:> Python Code: #import tm1 service module from TM1py.Services import TM1Service #import tm1 utils module from TM1py.Utils import Utils #import pandas import pandas as pd #import matplotlib import matplotlib.pyplot as plt #inline plotting for matplotlib %matplotlib inline #import statsmodels package from...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Step 2 Step2: Step 3 Step3: Step 4 Step4: Rather than looping through each region and product within the data set, the following cell creates...
2,773
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import numpy as np import statsmodels.api as sm from statsmodels.formula.api import ols sm.formula.ols import statsmodels.formula.api as smf sm.OLS.from_formula dta = sm.datasets.get_rdataset("Guerry", "HistData", cache=True) df = dta.data[['Lott...
<SYSTEM_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 convention Step2: Alternatively, you can just use the formula namespace of the main statsmodels.api. Step3: Or you can use the followin...
2,774
<ASSISTANT_TASK:> Python Code: %matplotlib notebook from sympy import init_printing from sympy import S from sympy import sin, cos, tanh, exp, pi, sqrt, log from boutdata.mms import x, y, z, t from boutdata.mms import DDX import os, sys # If we add to sys.path, then it must be an absolute path common_dir = os.path.absp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Initialize Step2: Define the variables Step3: Plot Step4: Print the variables in BOUT++ format
2,775
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import glob import os from matplotlib.patches import Rectangle # define all variables for convergence script # these will pass to the bash magic below used to call plumed sum_hills dir="MetaD_converge" #where the intermediate fes will be...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Graph the final FES and plot the two squares on top of it Step2: The two functions below calculate the average free energy of a region by integ...
2,776
<ASSISTANT_TASK:> Python Code: # Librerias import pandas as pd df1 = pd.DataFrame({'A': ['A0', 'A1', 'A2', 'A3'], 'B': ['B0', 'B1', 'B2', 'B3'], 'C': ['C0', 'C1', 'C2', 'C3'], 'D': ['D0', 'D1', 'D2', 'D3']}, index=[0, 1, 2, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Concatenar Step2: Ejemplos de DataFrames Step3: Merge Step4: Ejemplo Complicado Step5: Joining
2,777
<ASSISTANT_TASK:> Python Code: # Step 1: Configure your cluster with gcloud # `gcloud container clusters get-credentials <cluster_name> --zone <cluster-zone> --project <project-id> # Step 2: Get the port where the gRPC service is running on the cluster # `kubectl get configmap metadata-grpc-configmap -o jsonpath={.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: Connect to the ML Metadata (MLMD) database Step2: Get trial summary data (used to plot Area under Learning Curve) stored as AugmentedTuner arti...
2,778
<ASSISTANT_TASK:> Python Code: # Importa la librería financiera. # Solo es necesario ejecutar la importación una sola vez. import cashflows as cf cflo = cf.cashflow(const_value=[100] * 11 + [0], start='2016-1', freq='M') cflo nrate = cf.interest_rate([24] * 12, start='2016-1', freq='M') nrate cf.savings(deposits = cf...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Ejercicio.-- Usando Microsoft Excel u otra herramienta solucione el siguiente problema Step2: *Ejemplo.--* Realice el mismo ejemplo anterior, p...
2,779
<ASSISTANT_TASK:> Python Code: import numpy as np np.random.seed(29384924) data = np.random.randint(10, size = 100) # 100 random numbers, from 0 to 9 print(data) print("Number of data points: ", data.shape[0]) # Remember our friend, ndarray.shape? print("Largest value: ", data.max()) print("Smallest value: ", data.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: Some very straightforward statistics are the number of data points, the largest value, and the smallest value. These shouldn't be immediately ig...
2,780
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt %matplotlib inline plt.style.use('fivethirtyeight') plt.rcParams['figure.figsize'] = (9,6) df = pd.read_csv("data/creditRisk.csv") df.head() import seaborn as sns sns.stripplot(data = df, x = "Income", y = "Credit His...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Plotting the Data Step2: Preparing Data Step3: Lets use a dictionary for encoding nominal variable Step4: Decision Tree Classifier Step5: Vi...
2,781
<ASSISTANT_TASK:> Python Code: person_name = "Mike" person_age = 50 person_faculty = True person = {} person['name'] = "Mike" person['age'] = 50 person['faculty'] = True print(person) 'dob' in person.keys() if 'dob' not in person.keys(): dob = input("Enter your DOB") person['dob'] = dob person person['hjklsdag...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: More Lab Questions...
2,782
<ASSISTANT_TASK:> Python Code: # Create the message variable and assign the value "Hello World" to it message="Hello World" # Use the variable in a print statement # The print statement retrieves the value assigned to the variable and displays the value print(message) message #Assign raw numbers to variables apples=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: Try changing the message in the previous code cell and re-running it. Does it behave as you expect? Step2: You can assign whatever object you l...
2,783
<ASSISTANT_TASK:> Python Code: # Constants D = 2 N = 100 K = 2 w = np.random.randn(D) w = normalize(w) theta = np.arctan2(w[0], w[1]) X = np.random.randn(N,D,K) y = np.zeros(N) for i in range(N): m = w.dot(X[i]) X[i] = X[i][:,np.argsort(-m)] y[i] = np.sign(max(m)) # Visualize data plt.plot(np.arange(-3,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: Method Step2: Exact SVM solution Step3: Naive Step4: As expected, the naive approach does really poorly. Step5: Proposed 2
2,784
<ASSISTANT_TASK:> Python Code: # This will take a few minutes r = requests.get("http://www.transtats.bts.gov/Download/On_Time_On_Time_Performance_2015_1.zip", stream=True) with open("otp-1.zip", "wb") as f: for chunk in r.iter_content(chunk_size=1024): f.write(chunk) f.flush() r.clo...
<SYSTEM_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 suppose that down the road our probram can only handle certain carriers; an update to the data adding a new carrier would violate an assum...
2,785
<ASSISTANT_TASK:> Python Code: import math import os import pandas as pd import numpy as np from datetime import datetime import tensorflow as tf from tensorflow import data print "TensorFlow : {}".format(tf.__version__) SEED = 19831060 DATA_DIR='data' # !mkdir $DATA_DIR # !gsutil cp gs://cloud-samples-data/ml-engine/...
<SYSTEM_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 the Data Step2: Dataset Metadata Step3: Building a TensorFlow Custom Estimator Step4: 2. Create model_fn Step5: 3. Create estimator...
2,786
<ASSISTANT_TASK:> Python Code: number = 3.14159265359 number = "1.7724538509055743" number = 3.14159265359 number = number ** 0.5 # Raise to the 0.5, which means square root. number = str(number) # Cast to a string. def first_negative(numbers): num = 0 index = 0 while numbers[index] > 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: Answering this is not simply taking what's in the autograder and copy-pasting it into your solution Step2: The whole point is that your code sh...
2,787
<ASSISTANT_TASK:> Python Code: #$HIDE_INPUT$ import pandas as pd autos = pd.read_csv("../input/fe-course-data/autos.csv") autos["make_encoded"] = autos.groupby("make")["price"].transform("mean") autos[["make", "price", "make_encoded"]].head(10) #$HIDE_INPUT$ import matplotlib.pyplot as plt import numpy as np import 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: Target Encoding Step2: This kind of target encoding is sometimes called a mean encoding. Applied to a binary target, it's also called bin count...
2,788
<ASSISTANT_TASK:> Python Code: import vcsn def aut(e): return vcsn.context('lal_char, b').expression(e, 'binary').standard() a1 = aut('a*+b*'); a1 a2 = aut('b*+a*'); a2 a1.is_isomorphic(a2), a1 == a2 %%automaton -s a1 $ -> 0 0 -> 1 a %%automaton -s a2 $ -> 0 0 -> 1 b a1.is_isomorphic(a1), a1.is_isomorphic(a2) a1 ...
<SYSTEM_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 automata must be accessible, but coaccessibility is not required. Step2: Equivalent automata can be non isomorphic. Step3: Weighted Automa...
2,789
<ASSISTANT_TASK:> Python Code: df = pd.DataFrame(np.fromfile("./output.bni", dtype=np.uint16).astype(np.float32) * (3300 / 2**12)) #df.describe() fig = sns.plt.figure(figsize=(16, 6)) ax = sns.plt.subplot() df[20000:20100].plot(ax=ax) df_r = df.groupby(df.index//10).mean() fig = sns.plt.figure(figsize=(16, 6)) ax = 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: Данных много, миллион сэмплов в секунду. Мы насобирали почти 70 миллионов сэмплов. Если строить их все сразу, питон ОЧЕНЬ задумается. Поэтому бу...
2,790
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy.optimize as sciopt x = np.array([[ 1247.04, 1274.9 , 1277.81, 1259.51, 1246.06, 1230.2 , 1207.37, 1192. , 1180.84, 1182.76, 1194.76, 1222.65], [ 589. , 581.29, 576.1 , 570.28, 566.45, 575.99, 601.1 , 620.6 , 637.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:
2,791
<ASSISTANT_TASK:> Python Code: import main raw_data = main.load_raw_data([]) # asume el cache gdf = main.get_grouped_dataset(raw_data, level=4) m, dfX = main.get_model_to_draw(4) import model figure() distr = model.ConditionalDistribution(gdf['131_pct'], gdf['135_pct']).fit() distr.draw_joint() xlabel('Proporción de v...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Patrones de voto Step2: Hay una relación inversa entre la gente que votó a Macri y a Scioli. Step3: Este patrón es super interesante, parecerí...
2,792
<ASSISTANT_TASK:> Python Code: # Pykep imports from pykep.trajopt import mga_1dsm, launchers from pykep.planet import jpl_lp from pykep import epoch from pykep.core import lambert_problem, propagate_lagrangian, fb_prop from pykep import DAY2SEC, DAY2YEAR, AU, RAD2DEG, ic2par from pykep.trajopt.gym import solar_orbiter_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Solar Orbiter, modelles with DSMs only on resonant arcs Step2: Solar Orbiter modeled as mga_1dsm
2,793
<ASSISTANT_TASK:> Python Code: folium.Map().add_child(ClickForMarker()) folium.Map().add_child(LatLngPopup()) folium.Map().add_child(ClickForLatLng(format_str='"[" + lat + "," + lng + "]"')) <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Click on the map to see the effects Step2: Click on the map to see the effects
2,794
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np from math import log, exp %matplotlib inline # Evaluate beta for this sensor T_0=273.15+20; N=(1/273.15-1/293.15)-(1/298.15-1/293.15); beta= log(3000/1000)/N; R_0=1000/exp(beta*((1/298.15)-(1/293.15))); ## Results print('Beta for this se...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The plot shows the nonlinear behaviour of the sensor and the two points used for estimating the curve. Step2: Note how the error starts from ze...
2,795
<ASSISTANT_TASK:> Python Code: import ipywidgets import IPython.display args = ipywidgets.Text( description='Input string:', value='cube') IPython.display.display(args) print args.value <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Construct widget with a default value and display using IPython display call. Step2: Print widget value for clarity.
2,796
<ASSISTANT_TASK:> Python Code: import os with open(os.path.join("datasets", "smsspam", "SMSSpamCollection")) as f: lines = [line.strip().split("\t") for line in f.readlines()] text = [x[1] for x in lines] y = [x[0] == "ham" for x in lines] text[:10] y[:10] type(text) type(y) from sklearn.cross_validation import tra...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Training a Classifier on Text Features Step2: We can now evaluate the classifier on the testing set. Let's first use the builtin score function...
2,797
<ASSISTANT_TASK:> Python Code: import imaginet.task model = imaginet.task.load(path="model-ipa.zip") emb = imaginet.task.embeddings(model) print(emb.shape) symb = imaginet.task.symbols(model) print " ".join(symb.values()) %pylab inline from sklearn.decomposition import PCA pca = PCA(n_components=2) xy = pca.fit_tra...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load the model Step2: Symbol embeddings Step3: The table of IPA symbols corresponding to the 49 dimensions Step4: Let's display the embeddin...
2,798
<ASSISTANT_TASK:> Python Code: import numpy as np A = np.array([[0, 0, 0, 0], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]]) mat1 = (A.T).dot(A) print mat1 a = np.array([.25, .25, .25, .25]) for i in xrange(3): a = mat1.dot(a) print a mat2 = (A).dot(A.T) print mat2 h = np.array...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Question 8. Step2: Question 9.
2,799
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division import thinkstats2 import thinkplot %matplotlib inline import scipy.stats mu = 178 sigma = 7.7 dist = scipy.stats.norm(loc=mu, scale=sigma) type(dist) dist.mean(), dist.std() dist.cdf(mu-sigma) low = dist.cdf(177.8) high = dist.cdf(185....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 연습문제 5.1 Step2: 예를 들어, <tt>scipy.stats.norm</tt>은 정규분포를 나타낸다. Step3: "고정된 확률변수(frozen random variable)"는 평균과 표준편차를 계산할 수 있다. Step4: CDF도 평가할 ...