Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
7,800
<ASSISTANT_TASK:> Python Code: from conf import LisaLogging LisaLogging.setup() %pylab inline import json import os # Support to access the remote target import devlib from env import TestEnv # Import support for Android devices from android import Screen, Workload, System, ViewerWorkload from target_script import Targ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Test environment setup Step2: Workload definition Step3: Workload execution Step4: Traces visualisation
7,801
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from sklearn.pipeline import Pipeline from sklearn.svm import SVR from sklearn import cross_validation np.random.seed(0) n_samples = 200 kernels = ['linear', 'poly', 'rbf'] true_fun = lambda X: X ** 3 X = np.sort(5 * (np.random.rand(n_sam...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Learning Curves Step2: They all come from the same underlying process. But if you were asked to make a prediction, you would be more likely to ...
7,802
<ASSISTANT_TASK:> Python Code: %matplotlib inline %reload_ext autoreload %autoreload 2 from fastai.conv_learner import * PATH = "data/cifar10/" os.makedirs(PATH, exist_ok=True) classes = ('plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck') stats = (np.array([ 0.4914 , 0.48216, 0.44653]), 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: Viewing Data Step2: Learner Initialization Tests Step3: Step4: Could num_classes be used for loss-choice logic? Step5: Darknet53 Tests Step...
7,803
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from numpy.polynomial import Chebyshev as T from numpy.polynomial.hermite import hermval %matplotlib inline def p_cheb(x, n): RETURNS T_n(x) value of not normalized Chebyshev polynomials $\int \frac1{\sqrt{1-x^2}}T_m(x)T_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: Multivariate function approximation Step5: Now, let's approximate the function with polynomials taking different maximal power $n$ and the corr...
7,804
<ASSISTANT_TASK:> Python Code: # As usual, a bit of setup import time, os, json import numpy as np import matplotlib.pyplot as plt from cs231n.gradient_check import eval_numerical_gradient, eval_numerical_gradient_array from cs231n.rnn_layers import * from cs231n.captioning_solver import CaptioningSolver from cs231n.cl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Image Captioning with LSTMs Step2: Load MS-COCO data Step3: LSTM Step4: LSTM Step5: LSTM Step6: LSTM Step7: LSTM captioning model Step8: ...
7,805
<ASSISTANT_TASK:> Python Code: from dolfin import * from rbnics import * @PullBackFormsToReferenceDomain() @ShapeParametrization( ("x[0]", "x[1]"), # subdomain 1 ("mu[0] * (x[0] - 1) + 1", "x[1]"), # subdomain 2 ) class EllipticOptimalControl(EllipticOptimalControlProblem): # Default initialization of me...
<SYSTEM_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 El...
7,806
<ASSISTANT_TASK:> Python Code: import pandas as pd import matplotlib matplotlib.style.use('ggplot') %matplotlib inline training_data = { 'x': [0, 1, 2, 3], 'y': [4, 7, 7, 8] } train_df = pd.DataFrame.from_dict(training_data) train_df train_df.plot(kind='scatter', x='x', y='y') <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: Let's plot the data to see what it looks like
7,807
<ASSISTANT_TASK:> Python Code: %pylab inline import sys sys.path.append("../lib/") import seaborn as sns import pandas as pd from operator import itemgetter from dataContainer import DataContainer, dataClassMapper container = DataContainer() # load the data data = container.collapse() # rem...
<SYSTEM_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 DataContainer class is a container that integrates the available datasets. It allows easy loading and combining (and hopefully more cool stu...
7,808
<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: Train an LSTM weather forecasting model for the Coral Edge TPU Step2: Prepare the climate dataset Step3: Visualize the data Step4: This heat ...
7,809
<ASSISTANT_TASK:> Python Code: # Show matplotlib plots inline (nicely formatted in the notebook) %matplotlib inline # Import libraries necessary for this project import numpy as np import pandas as pd import renders as rs import seaborn as sns from matplotlib import pylab as plt from IPython.display import 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: Data Exploration Step2: Implementation Step3: Question 1 Step4: Answer Step5: Question 2 Step6: Question 3 Step7: Answer Step8: Observati...
7,810
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import numpy as np from PIL import Image # for bmp import from glob import glob from scipy.misc import imresize import matplotlib.pyplot as plt import math import time %matplotlib inline def showImage(imageToPlot): plt.figure(figsize=(2, 4)) 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: Loading and studying the 342x719 image of fantom Step2: Let's assume vertical line points are spaced by 1cm each. This corresponds to a depth o...
7,811
<ASSISTANT_TASK:> Python Code: %matplotlib inline import os, sys import numpy as np import matplotlib import matplotlib.pyplot as plt import pandas as pd import requests import StringIO # set matplotlib style matplotlib.style.use('ggplot') sitename = 'alligatorriver' roiname = 'DB_0001' infile = "{}_{}_roistats.csv".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: While the data can be read directly from a URL we'll start by doing the simple thing of reading the CSV file directly from our local disk. Step2...
7,812
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 import numpy as np policy = np.array([[0.3, 0.2, 0.5], [0.5, 0.4, 0.1], [0.8, 0.1, 0.1]]) print("This is represents the policy with 3 states and 3 actions p(row=a|col=s):\n", np.matrix(policy)) # 'raw_rewards' variable contains rewards obtained after tr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Policy Evaluation by Dynamic Programming Step2: Policy Evaluation by Linear Programming Step3: The result stays the same. Step4: As can be s...
7,813
<ASSISTANT_TASK:> Python Code: from pyspark.sql import SQLContext # adding the PySpark module to SparkContext sc.addPyFile("https://raw.githubusercontent.com/seahboonsiew/pyspark-csv/master/pyspark_csv.py") import pyspark_csv as pycsv # you may need to modify this line if the filename or path is different. sqlContext =...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Enter the following command in the next cell to look at the first record and click Run Step2: Enter the following command in the next cell to g...
7,814
<ASSISTANT_TASK:> Python Code: # Authors: Martin Luessi <mluessi@nmr.mgh.harvard.edu> # Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # Nicolas P. Rougier (graph code borrowed from his matplotlib gallery) # # License: BSD (3-clause) import numpy as np import matplotlib.pyplot as plt imp...
<SYSTEM_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 our data Step2: Compute inverse solutions and their connectivity Step3: Make a connectivity plot Step4: Make two connectivity plots in t...
7,815
<ASSISTANT_TASK:> Python Code: OUTFN = "AK_NCDC_FirstOrderStations.json" SAVEDATA = False stationdata = [] for station in all_stations: path = os.path.join(endpoint_stations, "GHCND:{}".format(station)) fullbase = requests.compat.urljoin(baseurl, path) r = requests.get( fullbase, headers=cu...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Optional
7,816
<ASSISTANT_TASK:> Python Code: import flopy # load the model model_ws = os.path.join("Freyberg","extra_crispy") ml = flopy.modflow.Modflow.load("freyberg.nam",model_ws=model_ws) # Because this model is old -- it predates flopy's modelgrid implementation. # And because modelgrid has been implemented without backward 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: The plot shows the Freyberg (1988) model domain. The colorflood is the hydraulic conductivity ($\frac{m}{d}$). Red and green cells coorespond ...
7,817
<ASSISTANT_TASK:> Python Code: #!pip install -I "phoebe>=2.4,<2.5" %matplotlib inline import phoebe from phoebe import u # units import numpy as np logger = phoebe.logger() b = phoebe.default_binary() b.add_dataset('lc', compute_phases=phoebe.linspace(0,1,101)) b.run_compute(irrad_method='none') times = b.get_value('...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: This first line is only necessary for ipython noteboooks - it allows the plots to be shown on this page instead of in interactive mode. Dependi...
7,818
<ASSISTANT_TASK:> Python Code: #Initializations from IPython.core.display import HTML HTML(open("../styles/custom.css", "r").read()) %matplotlib inline import numpy as np import matplotlib.pyplot as plt import math pi = math.pi from pint import UnitRegistry ur = UnitRegistry() # ideal gas parameters for air gamma = 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: Coefficient of Discharge Step2: Choked Flow Step3: Critical Pressure Ratio Step4: Procedure to Calculate the Airbag Vent Mass Flowrate
7,819
<ASSISTANT_TASK:> Python Code: import PIL import PIL.Image import scipy import scipy.misc ref = PIL.Image.open("sky.jpg") ref = numpy.array(ref) ref = scipy.misc.imresize(ref, 0.25, interp="bicubic") target = PIL.Image.open("bird.jpg") target = numpy.array(target) 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: compute strict interior and border regions Step2: compute seamless clone (red)
7,820
<ASSISTANT_TASK:> Python Code: %matplotlib inline from math import pi, sin, cos import numpy as np import openmc fuel = openmc.Material(name='fuel') fuel.add_element('U', 1.0) fuel.add_element('O', 2.0) fuel.set_density('g/cm3', 10.0) clad = openmc.Material(name='zircaloy') clad.add_element('Zr', 1.0) clad.set_density...
<SYSTEM_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 begin by creating the materials that will be used in our model. Step2: With our materials created, we'll now define key dimensions in our...
7,821
<ASSISTANT_TASK:> Python Code: import sympy sympy.init_printing() Theta = sympy.Matrix(sympy.symbols( 'theta_0:3_0:4')).reshape(3,4) def Y(n): return sympy.Matrix(sympy.symbols( 'G_x:z_0:{:d}'.format(n+1))).T.reshape(3, n+1) def C(n): return sympy.ones(n+1, 1) def T(n): return sympy.Matrix(sympy...
<SYSTEM_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 let's us derive a recurisve form.
7,822
<ASSISTANT_TASK:> Python Code: import pandas as pd %matplotlib inline # load the raw data df = pd.read_csv('../Data/shaneiphone_exp2.csv') # plot gravity signal df[['motionGravityX', 'motionGravityY', 'motionGravityZ']].plot() # plot gyroscope signal [indices 7000 to 10000 include a series of sharp turns in the Censi...
<SYSTEM_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 XYZ axes from SensorLog are in the frame of the iPhone. On the way to Censio, my phone was placed flat on the driver seat. On the return t...
7,823
<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...
7,824
<ASSISTANT_TASK:> Python Code: # import the required libraries import numpy as np import time import random import cPickle import codecs import collections import os import math import json import tensorflow as tf from six.moves import xrange # libraries required for visualisation: from IPython.display import SVG, disp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: define the path of the model you want to load, and also the path of the dataset Step4: We define two convenience functions to encode a stroke i...
7,825
<ASSISTANT_TASK:> Python Code: #%matplotlib inline import matplotlib.pyplot as plt plt.scatter((1,2,2.5), (2,1,2)); plt.xlim((0,3)); plt.ylim((0,3)); import numpy as np A = np.array(((1,1),(2,1),(2.5,1))); b = np.array((2,1,2)) # Create A and b x = np.dot(np.dot(np.linalg.inv(np.dot(A.T, A)), A.T), b) # Project b onto...
<SYSTEM_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 way to express this problem is to say, I would like to find the equation of a line that satisfies all of the above points. Take the foll...
7,826
<ASSISTANT_TASK:> Python Code: import numpy as np import networkx as nx from matplotlib import pyplot as plt %matplotlib inline from scipy.io import loadmat import warnings warnings.filterwarnings( 'ignore' ) def mcl_iter( A, p = 2, alpha = 2, theta = 1e-8, rel_eps = 1e-4, niter = 10000 ) : ## Convert A into a transit...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Problems Step2: The agorithm is desinged to transform the graph connectivity in such a way as to disconnect different communities and concentra...
7,827
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np from fbprophet import Prophet DATA_HOME_DIR = '/data/airline' df = pd.read_csv(DATA_HOME_DIR+'/international-airline-passengers.csv', sep=';', names=['ds', 'y'], header=0, parse_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: The input to Prophet is always a dataframe with two columns Step2: It looks like we have a exponential growth trend in the data, so in order to...
7,828
<ASSISTANT_TASK:> Python Code: import moldesign as mdt import moldesign.units as u mdt.configure() molecule = mdt.read('data/butane.xyz') molecule viewer = molecule.draw() viewer # we tell Jupyter to draw the viewer by putting it on the last line of the cell print(viewer.selected_atoms) molecule.set_energy_model...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Optional Step2: 2. Read in a molecular structure Step3: Jupyter notebooks will automatically print out the value of the last statement in any ...
7,829
<ASSISTANT_TASK:> Python Code: platform = 'lendingclub' use_cuda = True dtype = torch.cuda.FloatTensor save_path = "model_dump/nn_1_0_0/" store = pd.HDFStore( dc.home_path+'/justin_tinkering/data_science/lendingclub/{0}_store.h5'. format(platform), append=True) loan_info = store['train_filtered_columns'] 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: Until I figure out a good imputation method (e.g. bayes PCA), just drop columns with null still Step2: instantiate network Step3: get the weig...
7,830
<ASSISTANT_TASK:> Python Code: def resp_elas(m,c,k, cC,cS,w, F, x0,v0): wn2 = k/m ; wn = sqrt(wn2) ; beta = w/wn z = c/(2*m*wn) wd = wn*sqrt(1-z*z) # xi(t) = R sin(w t) + S cos(w t) + D det = (1.-beta**2)**2+(2*beta*z)**2 R = ((1-beta**2)*cS + (2*beta*z)*cC)/det/k S = ((1-beta**2)*cC - (2*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: Plastic response Step2: An utility function Step3: The system parameters Step4: Derived quantities Step5: Load definition Step6: The actual...
7,831
<ASSISTANT_TASK:> Python Code: import frame_methods import engine_methods as em import itertools import pandas as pd import matplotlib.pyplot as plt from scipy.stats import norm import numpy as np from ipywidgets import interact, interactive, fixed, interact_manual import ipywidgets as widgets ### Setup frame environm...
<SYSTEM_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 must first setup a sample environment with a frame and components. Step2: Scoring Step3: Weight Distribution- Y Step4: Collisions Step5: ...
7,832
<ASSISTANT_TASK:> Python Code: from __future__ import (absolute_import, division, print_function, unicode_literals) from astropy.time import Time import astropy.units as u from astropy.coordinates import EarthLocation import pytz import datetime from astroplan import Observer # Set up an observe...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Convert that astropy.time.Time back to a localized datetime, arriving back at the original datetime (only this one is localized) Step2: Let's s...
7,833
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import matplotlib %matplotlib inline from sklearn.model_selection import KFold from sklearn.ensemble import RandomForestClassifier as RFC from sklearn.ensemble import AdaBoostClassifier as AdaBoost from sklearn.multicl...
<SYSTEM_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 begin by loading and examining our raw dataset, containing data obtained through the TMDB API and saved previously as a CSV file. Step2: ...
7,834
<ASSISTANT_TASK:> Python Code: %matplotlib inline import sys, os sys.path.insert(0, os.path.expanduser('~/work/git/github/taku-y/pymc3')) import theano theano.config.floatX = 'float64' import matplotlib.pyplot as plt import numpy as np import pymc3 as pm import pandas as pd data = pd.read_csv('../data/radon.csv') coun...
<SYSTEM_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 hierarchical model trace -its found values- from 500 iterations onwards (right side plot) and its accumulated marginal values (left...
7,835
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'gfdl-esm4', 'atmoschem') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("nam...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
7,836
<ASSISTANT_TASK:> Python Code: boys = int(input('How many boys are in the class: ')) girls = int(input('How many girls are in the class:')) pupils = boys + girls print('There are', pupils,'in the class altogether') bigger_number = 12 smaller_number = 10 difference = bigger_number - smaller_number print('The difference...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Subtraction Step2: Multiplication Step3: Division Step4: Extra Useful Bit Step5: Working with Strings - aka Text Step6: Change line 3 of th...
7,837
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'messy-consortium', 'sandbox-1', 'seaice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 2...
7,838
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt %matplotlib inline import numpy as np import urllib2 from __future__ import division plt.style.use('ggplot') np.random.seed(1) url = ('https://raw.githubusercontent.com/Upward-Spiral-Science' '/data/master/syn-density/output.csv') data = urllib2.urlo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Using image data Step2: Grabbing images from website Step3: Now just need to figure out z-axis. The z values in the image data go from 2917-41...
7,839
<ASSISTANT_TASK:> Python Code: import sys sys.path.append('..') import pandexo.engine.justdoit as jdi exo_dict = jdi.load_exo_dict() #WASP-43 exo_dict['star']['jmag'] = 9.995 # J magnitude of the system exo_dict['star']['hmag'] = 9.397 # H magnitude of the system #WASP-43b exo_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Edit Inputs Step2: Edit stellar and planet inputs Step3: Step 2) Load in instrument dictionary Step4: Edit HST/WFC3 detector and observation ...
7,840
<ASSISTANT_TASK:> Python Code: def bcdToHexaDecimal(s ) : len1 = len(s ) check = 0 num = 0 sum = 0 mul = 1 ans =[] i = len1 - 1 while(i >= 0 ) : sum +=(ord(s[i ] ) - ord('0' ) ) * mul mul *= 2 check += 1 if(check == 4 or i == 0 ) : if(sum <= 9 ) : ans . append(chr(sum + ord('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:
7,841
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'sandbox-2', 'atmos') # 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...
7,842
<ASSISTANT_TASK:> Python Code: from keras.layers import Bidirectional, Concatenate, Permute, Dot, Input, LSTM, Multiply from keras.layers import RepeatVector, Dense, Activation, Lambda from keras.optimizers import Adam from keras.utils import to_categorical from keras.models import load_model, Model import keras.backen...
<SYSTEM_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 - Translating human readable dates into machine readable dates Step2: You've loaded Step3: You now have Step4: 2 - Neural machine translati...
7,843
<ASSISTANT_TASK:> Python Code: # standard import if you're using "formula notation" import statsmodels.formula.api as smf lm = smf.ols(formula='Sales ~ TV', data=data).fit() lm.params # lets make a prediction if TV advertising would spend $50,000 # Statsmodels formula interface expects a datarames X_new = pd.DataFrame...
<SYSTEM_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 Least Squares Line Step2: null hypothesis Step3: The most common way to evaluate the overall fit of a linear model is by the R-sq...
7,844
<ASSISTANT_TASK:> Python Code: %pylab inline dat_file = '../examples/1-rosenbrock/dakota.dat' data = numpy.loadtxt(dat_file, skiprows=1, unpack=True, usecols=[0,2,3,4]) data plot(data[1,], data[2,], 'ro') xlim((-2, 2)) ylim((-2, 2)) xlabel('$x_1$') ylabel('$x_2$') title('Planview of parameter study locations') 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: Read the Dakota tabular data file. Step2: Plot the path taken in the vector parameter study. Step3: Plot the values of the Rosenbrock function...
7,845
<ASSISTANT_TASK:> Python Code: # Copyright 2020 DeepMind Technologies Limited # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: Installation Step4: Supported tasks and wrappers Step5: These are the wrappers that can be applied to the tasks Step6: Discrete Relative Acti...
7,846
<ASSISTANT_TASK:> Python Code: import pandas as pd from sklearn.ensemble import RandomForestRegressor from sklearn.model_selection import cross_val_score df = pd.read_csv("../input/fe-course-data/concrete.csv") df.head() X = df.copy() y = X.pop("CompressiveStrength") # Train and score baseline model baseline = RandomF...
<SYSTEM_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 here the various ingredients going into each variety of concrete. We'll see in a moment how adding some additional synthetic feature...
7,847
<ASSISTANT_TASK:> Python Code: # create some noise a = np.random.randn(50, 600, 100) a.shape # create some noise with higher variance and add bias. b = 2. * np.random.randn(*a.shape) + 1. b.shape # manufacture some loss function # there are n_epochs * n_batchs * batch_size # recorded values of the loss loss = 10 / np....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: MultiIndex Dataframe Step2: Visualization Step3: CSV Read/Write Step4: HDF5 Read/Write Step5: Furthermore, the file sizes are significantly ...
7,848
<ASSISTANT_TASK:> Python Code: ## Q2 Solution. def hash(x): return math.fmod(3 * x + 2, 11) for i in xrange(1,12): print hash(i) ## Q3 Solution. prob = 1.0 / 10 a = (1 - prob)**4 print a b = (1 - ( 1 - (1 - prob)**2) )**2 print b c = (1 - (1.0 /10 * 1.0 / 9)) print c ## Q5 Solution. vec1 = np.array([2, 1, 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: Q3. Step2: Q4. Step3: Q6. Step4: Q7. Step5: Q8. Step6: Q10. Step7: Q11. Step8: Q13.
7,849
<ASSISTANT_TASK:> Python Code: c1 = lambda x: x + 1 c2 = lambda x: -x + 2 x1 = np.linspace(0.01, 2, 10) x2 = np.linspace(-2, -0.01, 10) plt.plot(x1, c1(x1), label=r"$y = x + 1$") plt.plot(x2, c2(x2), label=r"$y = -x + 2$") plt.plot(0, 2, 'wo', markersize=7) plt.plot(0, 1, 'wo', markersize=7) ax = plt.axes() ax.set_ylim...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Even though the value of $y$ for when $x = 0$ is undefined we can say something about the limits of this function. Step2: Note that dividing b...
7,850
<ASSISTANT_TASK:> Python Code: __author__ = 'Shahariar Rabby' import email import imaplib import ctypes import getpass import threading from playsound import playsound def user(): # ORG_EMAIL = "@gmail.com" # FROM_EMAIL = "your mail" + ORG_EMAIL # FROM_PWD = "your pass" FROM_EMAIL = raw_input("insert 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: User Details Function Step2: Login function Step3: Mail Server Step4: This function call Check_Unseen in every 15 sec.
7,851
<ASSISTANT_TASK:> Python Code: # Model Configuration UNITS = 2 ** 11 # 2048 ACTIVATION = 'relu' DROPOUT = 0.1 # Training Configuration BATCH_SIZE_PER_REPLICA = 2 ** 11 # powers of 128 are best # TensorFlow import tensorflow as tf print("Tensorflow version " + tf.__version__) # TF 2.3 version # Detect and init the TPU ...
<SYSTEM_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 next few sections set up the TPU computation, data pipeline, and neural network model. If you'd just like to see the results, feel free to s...
7,852
<ASSISTANT_TASK:> Python Code: cosmo = LambdaCDM(H0=70, Om0=0.3, Ode0=0.7, Tcmb0=2.725) # check to make sure we have defined the bpz filter path if not os.getenv('EZGAL_FILTERS'): os.environ['EZGAL_FILTERS'] = (f'{os.environ["HOME"]}/Projects/planckClusters/MOSAICpipe/bpz-1.99.3/FILTER/') model = ezgal.model('bc03...
<SYSTEM_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 Stellar Population Step2: Calculate a few things to get going. Step5: Define the functions that we'll need Step6: Start Calculating th...
7,853
<ASSISTANT_TASK:> Python Code: # Imports and utility functions import time import numpy as np import matplotlib.pyplot as plt from qutip.sesolve import sesolve from qutip.solver import Options, solver_safe from qutip import sigmax, sigmay, sigmaz, identity, tensor, basis, Bloch def timing_val(func): def wrapper(*ar...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Time dependent control functions Step2: Hamiltonians, initial state and measurements Step3: Solving the dynamics Step4: Function type Step5: ...
7,854
<ASSISTANT_TASK:> Python Code: results_file = '../data/lda_data_8.pickle' n_iters = 10 for n in range(n_iters): print "iteration %d" % n print results_file X, Y, Yaudio = classification.load_data_from_pickle(results_file) # get only 80% of the dataset.. to vary the choice of outliers X, _, Y, _ = tr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Estimate precision at K
7,855
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np from IPython.html.widgets import interact, interactive, fixed from IPython.display import display from IPython.html import widgets def print_sum(a, b): Print the sum of the arguments a and b. print(a + b) ...
<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: Interact basics Step3: Use the interact function to interact with the print_sum function. Step5: Write a function named print_string that prin...
7,856
<ASSISTANT_TASK:> Python Code: from scipy import misc as scm import os.path as op import matplotlib.pyplot as plt % matplotlib inline datadir = '/tmp/113_1/' im = scm.imread(op.join(datadir,'0090.png')) plt.imshow(im, cmap='gray') plt.show() import os import numpy as np files = os.listdir(datadir) # get a list of all...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step 1 Step1: Step 2 Step2: It's also important to summarize what we've done, so that the user can Summarizing these results and those that require mo...
7,857
<ASSISTANT_TASK:> Python Code: import numpy as np from sklearn.cluster import KMeans def kmeans_missing(X, n_clusters, max_iter=10): Perform K-Means clustering on data with missing values. Args: X: An [n_samples, n_features] array of data to cluster. n_clusters: Number of clusters to form. max...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Filling up missing data with cluster algorithm Step2: Example with fake data Step3: 可以看出,采用全局平均值填充缺失值后,数据分布差别较大;相反采用聚类算法填充缺失值的效果较好。 Step4: 可以...
7,858
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 from __future__ import print_function import numpy as np import SDSS import pandas as pd import matplotlib.pyplot as plt %matplotlib inline import copy # We want to select galaxies, and then are only interested in their positions on the sky. data = pd.re...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The Correlation Function Step2: Random Catalogs Step3: Now let's plot both catalogs, and compare. Step4: Estimating $\xi(\theta)$
7,859
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd import sklearn import matplotlib.pyplot as plt import seaborn as sns # Setup Seaborn sns.set_style("whitegrid") sns.set_context("poster") df_offers = pd.read_excel("./WineKMC.xlsx", sheetname=0) df_offers.columns = ["offer_id", "campaign", "varietal...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Data Step2: We see that the first dataset contains information about each offer such as the month it is in effect and several attributes about ...
7,860
<ASSISTANT_TASK:> Python Code: F=graphviz.Graph()#(engine='neato') F.graph_attr['rankdir'] = 'LR' F.edge('A_1','B_1') F.edge('A_1','B_2') F.edge('A_2','B_1') F.edge('A_3','B_1') F.edge('A_4','B_2') F.edge('A_5','B_2') F.edge('A_5','B_3') F F=graphviz.Graph() F.graph_attr['rankdir'] = 'LR' F.edge('A_1, A_2, A_3','B_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: The structure which we just described here happens to match a well-studied family of graphs known as Bipartite Graphs. There are tons of algorit...
7,861
<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...
7,862
<ASSISTANT_TASK:> Python Code: df = pd.read_csv('../data/date_fixed_running_data.csv') df.head() df['Unnamed: 0'].head() df = pd.read_csv('../data/date_fixed_running_data.csv', parse_dates=['Date']) df = pd.read_csv('../data/date_fixed_running_data.csv', parse_dates=[0]) df.head() cols = ['Date', 'Miles', 'Time'] 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: This is because when you save a data frame to a csv it doesn’t label the index column. So now our column is actually the ‘zero’ column. When you...
7,863
<ASSISTANT_TASK:> Python Code: import toytree newick = "((a,b),(c, d));" tre = toytree.tree(newick) tre.draw(); URL = "https://treebase.org/treebase-web/search/downloadATree.html?id=11298&treeid=31264" tre = toytree.tree(URL) tre.draw(tip_labels_align=True, height=800, width=600); <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: Newick tree files Step2: An example using a URL from treebase
7,864
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib import matplotlib.pyplot as mplt from scipy import linalg from scipy import io ### Ordinary Least Squares ### SOLVES 2-CLASS LEAST SQUARES PROBLEM ### LOAD DATA ### ### IF LoadClasses IS True, THEN LOAD DATA FROM FILES ### ### OTHERSIE, RANDOMLY GENERA...
<SYSTEM_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 read in the example data. Note that you will need to update the filepaths below to work on your machine. Step2: Now we can plot the da...
7,865
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np data_path = "C:/Users/Rishu/Desktop/dATA/boston/" boston_data=pd.read_csv(data_path+'train.csv') boston_data.info() boston_data.head() boston_data_test=pd.read_csv(data_path+'test.csv') boston_data_test.head() boston_data.describe() import matplot...
<SYSTEM_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 boston dataset - Train and Test Step2: Understanding the distribution and relationship of the data Step3: Plotting the target pric...
7,866
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pynucastro as pyrl files = ["c12-pg-n13-ls09", "c13-pg-n14-nacr", "n13--c13-wc12", "n13-pg-o14-lg06", "n14-pg-o15-im05", "n15-pa-c12-nacr", "o14--n14-wc12", "o15--n15-wc12", "o14-ap-f17-Ha9...
<SYSTEM_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 collection of rates has the main CNO rates plus a breakout rate into the hot CNO cycle Step2: To evaluate the rates, we need a composition...
7,867
<ASSISTANT_TASK:> Python Code: import logging from conf import LisaLogging LisaLogging.setup() # Generate plots inline %matplotlib inline import os # Support to access the remote target import devlib from env import TestEnv # RTApp configurator for generation of PERIODIC tasks from wlgen import RTA, Ramp # Setup targ...
<SYSTEM_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 required modules Step2: Target Configuration Step3: Workload Execution and Power Consumptions Samping Step4: Power Measurements Data
7,868
<ASSISTANT_TASK:> Python Code: # 基础库导入 from __future__ import print_function from __future__ import division import warnings warnings.filterwarnings('ignore') warnings.simplefilter('ignore') import numpy as np import pandas as pd import matplotlib.pyplot as plt import ipywidgets %matplotlib inline import os import sys ...
<SYSTEM_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: 1. A股训练集主裁训练 Step3: 2. 验证A股主裁是否称职 Step4: order_has_result的交易单中记录了所买入时刻的交易特征,如下所示: Step5: 可以通过一个一个迭代交易单,将交...
7,869
<ASSISTANT_TASK:> Python Code: ###################################### ###THIS IS PSEUDOCODE; WILL NOT RUN### ###################################### ###STEP 1: COMPUTATION OF FOREGROUND PROBABILITY### cdfMapVolume = [] for image in volume: #Get a distribution of intensities of the slice dist = generateDistr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Write Code Step2: 2.Generate Functionality Results Step3: 3. Analyze Functionality Results Step4: 2.Generate Results Step5: 3. Analyze Resul...
7,870
<ASSISTANT_TASK:> Python Code: # TensorFlow and tf.keras import matplotlib.pyplot as plt # Helper libraries import numpy as np import tensorflow as tf from tensorflow import keras print(tf.__version__) fashion_mnist = keras.datasets.fashion_mnist (train_images, train_labels), ( test_images, test_labels, ) = fa...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import the Fashion MNIST dataset Step2: Loading the dataset returns four NumPy arrays Step3: Explore the data Step4: Likewise, there are 60,0...
7,871
<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 !wget -Nq https://github.com/INM-6/elephant-tutorial-data/raw/mas...
<SYSTEM_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...
7,872
<ASSISTANT_TASK:> Python Code: import numpy as np from astropy.table import Table, join from astropy import units as u from astropy.coordinates import SkyCoord, search_around_sky import pickle from tqdm import tnrange, tqdm_notebook from IPython.display import clear_output from mltier1 import parallel_process, SingleML...
<SYSTEM_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 data Step2: Coordinates Step3: Import the ML parameeters Step4: Define the main functions Step6: The following function could be us...
7,873
<ASSISTANT_TASK:> Python Code: from __future__ import division, print_function, unicode_literals import pandas as pd s = pd.Series([2,-1,3,5]) s import numpy as np np.exp(s) s + [1000,2000,3000,4000] s + 1000 s < 0 s2 = pd.Series([68, 83, 112, 68], index=["alice", "bob", "charles", "darwin"]) s2 s2["bob"] s2[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: Now let's import pandas. People usually import it as pd Step2: Series objects Step3: Similar to a 1D ndarray Step4: Arithmetic operations on ...
7,874
<ASSISTANT_TASK:> Python Code: import math print("pi = %1.15f" %math.pi) print("pi = %1.15e" %math.pi) import numpy as np import scipy as scp print(" numpy pi = %1.15f" %np.pi) print(" scipy pi = %1.15f" %scp.pi) print("1+2 = ", 1+2) print("1.0+2 = ", 1.0+2) print("1.0+2.0 = ", 1.0+2.0) print("4/2 = ", 4/2) print("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: <h2>1.2 Basic operators <FONT FACE="courier" style="color Step2: <h3>1.3 Mathematical functions</h3> Step3: <h3>1.4 Booleans</h3> Step4: Let'...
7,875
<ASSISTANT_TASK:> Python Code: # just some basic setup for the purpose of this demo: %matplotlib inline from IPython.display import display import matplotlib.pyplot as plt import numpy as np from sklearn.manifold import TSNE #alternative you can use bh_sne: #from tsne import bh_sne # generate a set of 4900 random 3D ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The default method tries to warp the cloud towards a square shape. It does that by calculating the outer hull of the cloud and remapping it to a...
7,876
<ASSISTANT_TASK:> Python Code: import numpy as np import os import six.moves.urllib as urllib import sys import tarfile import tensorflow as tf import zipfile from collections import defaultdict from io import StringIO from matplotlib import pyplot as plt from PIL import Image import cv2 # This is needed to display th...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Env setup Step2: Object detection imports Step3: Model preparation Step4: Download Model Step5: Load a (frozen) Tensorflow model into memory...
7,877
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr> # Romain Trachel <trachelr@gmail.com> # Jean-Remi King <jeanremi.king@gmail.com> # # License: BSD (3-clause) import mne from mne import io, EvokedArray from mne.datasets import sample from mne.decoding import Ve...
<SYSTEM_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: Decoding in sensor space using a LogisticRegression classifier Step3: Let's do the same on EEG data using a scikit-learn...
7,878
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import pandas as pd import random import sys from sklearn import model_selection import tensorflow as tf !pip install git+https://github.com/google-research/tensorflow_constrained_optimization import tensorflow_constrained_optimization as...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Pairwise Regression Fairness Step2: Evaluation Metrics Step3: We will also need functions to evaluate the pairwise error rates for a linear mo...
7,879
<ASSISTANT_TASK:> Python Code: #!/usr/bin/env python # -*- Python -*- import sys import time import subprocess # # set up user environment # RtmToolsDir, MyRtcDir, etc. # # from set_env import * : you may provide a setup file like this # RtmToolsDir="../.." MyRtcDir=".." NS0="localhost:9876" # # import user tools ...
<SYSTEM_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 user environmet Step2: import user tools Step3: RtmEnv Step4: NameSpace Step5: RtcHandle Step6: activate and deactivate rtcs Step7: ...
7,880
<ASSISTANT_TASK:> Python Code: import pandas as pd log = pd.read_csv("../dataset/linux_blame_log.csv.gz") log.head() log.info() log['timestamp'] = pd.to_datetime(log['timestamp']) log.head() log['age'] = pd.Timestamp('today') - log['timestamp'] log.head() log['component'] = log['path'].str.split("/").str[:2].str.jo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Was haben wir hier eigentlich? Step2: <b>1</b> DataFrame (~ programmierbares Excel-Arbeitsblatt), <b>4</b> Series (= Spalten), <b>5665947</b> R...
7,881
<ASSISTANT_TASK:> Python Code: import numpy as np from pandas import DataFrame from sklearn.metrics import accuracy_score from sklearn.datasets import load_iris seed = 2017 np.random.seed(seed) data = load_iris() idx = np.random.permutation(150) X = data.data[idx] y = data.target[idx] from mlens.ensemble import SuperL...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Ensemble guide Step2: To check the performance of estimator in the layers, call the data Step3: To round off, let's see how the ensemble as a ...
7,882
<ASSISTANT_TASK:> Python Code: from pymongo import MongoClient import time import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt from matplotlib.pyplot import * import datetime as dt import random as rnd import warnings import datetime as dt import csv %matplotlib inline warnings....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Extraction of Data from MongoDB and Creating DataFrame Step2: First five rows from the dataframe Step3: Data filterxation Step4: Data Explora...
7,883
<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: Build the C++ "lstpu" example for Coral Step2: Download example from GitHub Step3: Build lstpu example for Dev Board Step4: The following lin...
7,884
<ASSISTANT_TASK:> Python Code: from learning import * from probabilistic_learning import * from notebook import * %psource DataSet iris = DataSet(name="iris") print(iris.examples[0]) print(iris.inputs) iris2 = DataSet(name="iris",exclude=[1]) print(iris2.inputs) print(iris.examples[:3]) print("attrs:", iris.attrs...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: CONTENTS Step2: Class Attributes Step3: To check that we imported the correct dataset, we can do the following Step4: Which correctly prints ...
7,885
<ASSISTANT_TASK:> Python Code: set1={"pop", "rock", "soul", "hard rock", "rock", "R&B", "rock", "disco"} set1 album_list =[ "Michael Jackson", "Thriller", 1982, "00:42:19", \ "Pop, Rock, R&B", 46.0, 65, "30-Nov-82", None, 10.0] album_set = set(album_list) album_set music_genres = set(["pop"...
<SYSTEM_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 process of mapping is illustrated in the figure Step2: Now let us create a set of genres Step3: Convert the following list to a set ['rap...
7,886
<ASSISTANT_TASK:> Python Code: import sys print(sys.version) import numpy as np import pandas as pd # RMS Titanic data visualization code from titanic_visualizations import survival_stats from IPython.display import display %matplotlib inline # Load the dataset in_file = 'titanic_data.csv' full_data = pd.read_csv(in_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: From a sample of the RMS Titanic data, we can see the various features present for each passenger on the ship Step3: The very same sample of th...
7,887
<ASSISTANT_TASK:> Python Code: # Problem 3.4, page 107 Anderson, Woessner and Hunt (2015) # import Python libraries/functionality for use in this notebook %matplotlib inline import numpy as np import matplotlib.pyplot as plt import scipy.special import sys, os from mpl_toolkits.axes_grid1 import make_axes_locatable # r...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We want to explore drawdown as a function of time Step2: We will want to normalize our plots Step3: Clobber the PNG output files Step4: Loop ...
7,888
<ASSISTANT_TASK:> Python Code: ########################################################################### # # Copyright 2021 Google Inc. # # 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 #...
<SYSTEM_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) Dependencies Step2: 1) Import dataset Step3: 1.1) Define KPI column and feature set Step4: 2) Build RBA Model Step5: 2.1) Print the model...
7,889
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import matplotlib import numpy as np %matplotlib inline matplotlib.style.use('seaborn') import pandas as pd from animerec.data import get_data users, anime = get_data() from sklearn.model_selection import train_test_split train, test = train_test_split(user...
<SYSTEM_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 plot the objective and see how it decreases. Step2: We can see quite clearly that this model does not overfit, just like the linear model...
7,890
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'awi', 'sandbox-2', 'landice') # 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...
7,891
<ASSISTANT_TASK:> Python Code: %pylab inline import sys import os sys.path.insert(0,'..') import graphmap from graphmap.graphmap_main import GraphMap from graphmap.memory_persistence import MemoryPersistence G = GraphMap(MemoryPersistence()) from graphmap.graph_helpers import NodeLink seattle_skyline_image_url = 'htt...
<SYSTEM_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 us import the module and create a GraphMap that persists in memory. Step2: Let us create two nodes with images of Seattle skyline and...
7,892
<ASSISTANT_TASK:> Python Code: !pip install -q -U pip !pip install -q tensorflow==2.2.0 !pip install -q -U google-auth google-api-python-client google-api-core import os import tensorflow as tf import numpy as np print(f'Tensorflow version: {tf.__version__}') PROJECT_ID = 'yourProject' # Change to your project. BUCKE...
<SYSTEM_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 libraries Step2: Configure GCP environment settings Step3: Authenticate your GCP account Step4: Create the embedding lookup model Step...
7,893
<ASSISTANT_TASK:> Python Code: import time from collections import namedtuple import numpy as np import tensorflow as tf with open('anna.txt', 'r') as f: text=f.read() vocab = set(text) vocab_to_int = {c: i for i, c in enumerate(vocab)} int_to_vocab = dict(enumerate(vocab)) chars = np.array([vocab_to_int[c] for 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: First we'll load the text file and convert it into integers for our network to use. Step3: Now I need to split up the data into batches, and in...
7,894
<ASSISTANT_TASK:> Python Code: try: import pint except ImportError: !pip install pint import pint try: from modsim import * except ImportError: !pip install modsimpy from modsim import * !python --version !jupyter-notebook --version # Configure Jupyter so figures appear in the notebook %matplo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The first time you run this on a new installation of Python, it might produce a warning message in pink. That's probably ok, but if you get a m...
7,895
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt outcome_0 = np.array([1.0, 0.0]) outcome_1 = np.array([0.0, 1.0]) a = 0.75 b = 0.25 prob_bit = a*outcome_0 + b*outcome_1 X,Y = prob_bit plt.figure() ax = plt.gca() ax.quiver(X,Y,angles='xy',scale_units='xy',scale=1) ax....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Given some state vector, like the one plotted above, we can find the probabilities associated to each outcome by projecting the vector onto the ...
7,896
<ASSISTANT_TASK:> Python Code: # As usual, a bit of setup import time, os, json import numpy as np from scipy.misc import imread, imresize import matplotlib.pyplot as plt from cs231n.classifiers.pretrained_cnn import PretrainedCNN from cs231n.data_utils import load_tiny_imagenet from cs231n.image_utils import blur_imag...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: TinyImageNet and pretrained model Step3: # Class visualization Step4: You can use the code above to generate some cool images! An example is s...
7,897
<ASSISTANT_TASK:> Python Code: def f(x): return x**3 + 4*x**2 -3 x = np.linspace(-3.1, 0, 100) plt.plot(x, x**3 + 4*x**2 -3) a = -3.0 b = -0.5 c = 0.5*(a+b) plt.text(a,-1,"a") plt.text(b,-1,"b") plt.text(c,-1,"c") plt.scatter([a,b,c], [f(a), f(b),f(c)], s=50, facecolors='none') plt.scatter([a,b,c], [0,0,0], s=50, 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: We can terminate the process whenever the function evaluated at the new midpoint is 'close enough' to zero. This method is an example of what ar...
7,898
<ASSISTANT_TASK:> Python Code: %matplotlib notebook Example: - Minimize Rosenbrock's Function with Nelder-Mead. - Plot of parameter convergence to function minimum. Demonstrates: - standard models - minimal solver interface - parameter trajectories using retall # Nelder-Mead solver from mystic.solv...
<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: mystic Step4: Diagnostic tools Step6: NOTE IPython does not handle shell prompt interactive programs well, so the above should be run from a c...
7,899
<ASSISTANT_TASK:> Python Code: # In the tf.keras.layers package, layers are objects. To construct a layer, # simply construct the object. Most layers take as a first argument the number # of output dimensions / channels. layer = tf.keras.layers.Dense(100) # The number of input dimensions is often unnecessary, as it can...
<SYSTEM_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 full list of pre-existing layers can be seen in the documentation. It includes Dense (a fully-connected layer), Step2: Implementing custom ...