Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
14,800
<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...
14,801
<ASSISTANT_TASK:> Python Code: %matplotlib inline # All the imports from __future__ import print_function, division import pom3_ga, sys import pickle # TODO 1: Enter your unity ID here __author__ = "pwang13" def normalize(problem, points): Normalize all the objectives in each point and return them meta = ...
<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: To compute most measures, data(i.e objectives) is normalized. Normalization is scaling the data between 0 and 1. Why do we normalize? Step10: D...
14,802
<ASSISTANT_TASK:> Python Code: class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): return self.items...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: cf. 3 Stacks and Queues, Cracking the Coding Interview, 6th Ed., McDowell, stack uses LIFO - as in a stack of dinner plates, the most recent ite...
14,803
<ASSISTANT_TASK:> Python Code: import os import sys module_path = os.path.abspath(os.path.join('..')) if module_path not in sys.path: sys.path.append(module_path) sys.path.append(module_path + '/rl_coach') from typing import Union import numpy as np from rl_coach.agents.ddpg_agent import DDPGAgent, DDPGAge...
<SYSTEM_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 define the HAC algorithm and agent parameters. Step2: Now we'll define the agent itself - HACDDPGAgent - which subclasses the DDPG ag...
14,804
<ASSISTANT_TASK:> Python Code:: from sklearn.model_selection import GridSearchCV import xgboost as xgb # create a dictionary containing the hyperparameters # to tune and the range of values to try PARAMETERS = {"subsample":[0.75, 1], "colsample_bytree":[0.75, 1], "max_depth":[2, 6], ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
14,805
<ASSISTANT_TASK:> Python Code: #Import libraries import sys, os import pandas as pd import numpy as np #Get file names; these files are created by the CreateUsageTable.py and CreateSupplyTable.py respectively dataDir = '../../Data' tidyuseFN = dataDir + os.sep + "UsageDataTidy.csv" tidysupplyFN = dataDir + os.sep + "Su...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Summarize USE table by county Step2: Import and summarize supply table by county Step3: Join Use and Supply Tables on Year and FIPS Step4: Su...
14,806
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import print_function # only necessary if using Python 2.x import numpy as np from pyshtools import SHCoeffs lmax = 30 coeffs = SHCoeffs.from_zeros(lmax) coeffs.set_coeffs(values=[1], ls=[10], ms=[0]) grid = coeffs.expand() fig, ax = grid.plot3d(elevati...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: To plot the data, we first expand it on a grid, and then use the method plot3d() Step2: Let's try a somewhat more complicated function. Here we...
14,807
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np # if using a Jupyter notebook, includue: %matplotlib inline mu = 80 sigma = 7 x = np.random.normal(mu, sigma, size=200) plt.hist(x, 20, density=True, histtype='bar', facecolor='b', alpha=0.5) plt.show...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: For our dataset, let's define a mean (average) mu = 80 and a standard deviation (spread) sigma = 7. Then we'll use numpy's np.random.normal() fu...
14,808
<ASSISTANT_TASK:> Python Code: # server = subprocess.Popen(['python', '../go_persistent_server.py']) # time.sleep(3) # web = subprocess.Popen(['python', '../go_web.py']) # time.sleep(3) web_interface = WebInterface() results = web_interface.add_trigger( 'junk', 'insert_ts', None, 'db:one:ts') assert results...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step8: Having set up the triggers, now insert the time series, and upsert the metadata
14,809
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np dftrain = pd.read_csv('data/bike_sharing_train.csv') dfval = pd.read_csv('data/bike_sharing_val.csv') dftest = pd.read_csv('data/bike_sharing_test.csv') ntrain = len(dftrain) nval = len(dftrain) + len(dfval) df = pd.concat([dftrain,dfval,dftest]) pri...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: b) Entrene un árbol de regresión para resolver el problema usando parámetros por defecto. Con este fin, construya una matriz $X_{train}$ de form...
14,810
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline train = pd.read_csv('titanic_train.csv') train.head() sns.heatmap(train.isnull(),yticklabels=False,cbar=False,cmap='viridis') sns.set_style('whitegrid') sns.countplot(x='Surv...
<SYSTEM_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 Data Step2: Exploratory Data Analysis Step3: Roughly 20 percent of the Age data is missing. The proportion of Age missing is likely small ...
14,811
<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 wr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Adversarial regularization for image classification Step2: Import libraries. We abbreviate neural_structured_learning to nsl. Step3: Hyperpara...
14,812
<ASSISTANT_TASK:> Python Code: PROJECT_ID = "YOUR PROJECT ID" BUCKET_NAME = "gs://YOUR BUCKET NAME" REGION = "YOUR REGION" SERVICE_ACCOUNT = "YOUR SERVICE ACCOUNT" content_name = "pt-img-cls-gpu-cust-cont-torchserve" gcs_output_uri_prefix = f"{BUCKET_NAME}/{content_name}" ! gsutil ls $gcs_output_uri_prefix ! curl -O ...
<SYSTEM_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 Artifact Step2: Vertex Prediction using Custom TorchServe Container Step3: Model Archive for TorchServe Step4: Option Step5: Initia...
14,813
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy import stats import matplotlib.pyplot as plt import itertools import urllib2 import scipy.stats as stats %matplotlib inline np.set_printoptions(precision=3, threshold=1000000, suppress=True) np.random.seed(1) alpha = .025 url = ('https://raw.githubusercontent...
<SYSTEM_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 4a Step2: Step 4b Step3: Step 5 Step4: Apply to data
14,814
<ASSISTANT_TASK:> Python Code: # setup from pyrise import products as prod obsid = prod.OBSERVATION_ID('PSP_003072_0985') # test orbit number assert obsid.orbit == '003072' # test setting orbit property obsid.orbit = 4080 assert obsid.orbit == '004080' # test repr assert obsid.__repr__() == 'PSP_004080_0985' # test ta...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: PRODUCT_ID Step2: SOURCE_PRODUCT_ID Step3: http Step4: HiRISE_URL Step5: others
14,815
<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: 使用 tf.data 加载文本数据 Step2: 三个版本的翻译分别来自于 Step3: 将文本加载到数据集中 Step4: 将这些标记的数据集合并到一个数据集中,然后对其进行随机化操作。 Step5: 你可以使用 tf.data.Dataset.take 与 print 来查看...
14,816
<ASSISTANT_TASK:> Python Code: import numpy as np from SimPEG import Mesh import matplotlib.pyplot as plt %matplotlib inline plt.set_cmap(plt.get_cmap('viridis')) # use a nice colormap! # define a 1D mesh mesh1D = Mesh.TensorMesh([5]) # with 5 cells fig, ax = plt.subplots(1,1, figsize=(12,2)) ax.plot(mesh1D.gridN, 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: Over a single cell, the divergence is Step2: Doing it as a for loop is easy to program for the first time, Step3: the above is still a loop....
14,817
<ASSISTANT_TASK:> Python Code: from beakerx import * import pandas as pd tableRows = pd.read_csv('../resources/data/interest-rates.csv') Plot(title="Title", xLabel="Horizontal", yLabel="Vertical", initWidth=500, initHeight=200) x = [1, 4, 6, 8, 10] y = [3, 6, 4, 5, 9] pp = Plot(title='Bars, Lines, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Plot items Step2: Lines, Points with Pandas Step3: Areas, Stems and Crosshair Step4: Constant Lines, Constant Bands Step5: TimePlot Step6: ...
14,818
<ASSISTANT_TASK:> Python Code: # Run some setup code for this notebook. import sys import os sys.path.append('..') import graphlab products = graphlab.SFrame('datasets/') products['sentiment'] products.head(10)['name'] print '# of positive reviews =', len(products[products['sentiment']==1]) print '# of negative revi...
<SYSTEM_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 review dataset Step2: One column of this dataset is 'sentiment', corresponding to the class label with +1 indicating a review with positiv...
14,819
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import seaborn as sns import numpy as np def find_peaks(x): a = np.array(x) l = [] for i in range(len(a)): if i == 0 and a[i] > a[i+1]: l.append(i) elif i == len(a)-1 and a[i]> a[i-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: Peak finding Step2: Here is a string with the first 10000 digits of $\pi$ (after the decimal). Write code to perform the following
14,820
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import pandas as pd from mpl_toolkits.basemap import Basemap from shapely.geometry import Point, Polygon, MultiPoint, MultiPolygon from shapely.prepared import prep import fiona from matplotlib.collections import PatchCollection from desc...
<SYSTEM_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 Wrangling Step2: data manipulation Step3: calculate speed during trips (in km/hr) Step4: Make a new dataframe containing the difference ...
14,821
<ASSISTANT_TASK:> Python Code: # RUN THIS CELL FIRST!!! import time from pydrill.client import PyDrill import psycopg2 import pandas as pd drill = PyDrill(host='128.206.116.250', port=8048) if not drill.is_active(): raise ImproperlyConfigured('Please run Drill first') # Start the Timer start = time.perf_counter() ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Pydrill Step3: Postgres Step5: Simple enough. Just as a reminder, the % operator in SQL matches any or no characters. Step7: Postgres Step9: ...
14,822
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 %matplotlib inline #export from exp.nb_00 import * import operator def test(a,b,cmp,cname=None): if cname is None: cname=cmp.__name__ assert cmp(a,b),f"{cname}:\n{a}\n{b}" def test_eq(a,b): test(a,b,operator.eq,'==') test_eq(TEST,'test') # To ru...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Jump_to lesson 8 video Step2: Get data Step3: Initial python model Step4: Matrix multiplication Step5: This is kinda slow - what if we could...
14,823
<ASSISTANT_TASK:> Python Code: # enable plotting in notebook %matplotlib notebook from simulation_results import example_simulations import physical_validation simulation_nvt_vrescale_low = example_simulations.get( "900 water molecules, NVT at 298K with v-rescale thermostat" ) num_molecules = 900 simulation_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: The results imported here are the time series of kinetic and potential energy from example simulations, which are Step2: Check NVT simulations ...
14,824
<ASSISTANT_TASK:> Python Code: # -- inputs X_test[0] # -- predicted output (using Keras) yhat[0] from tensorflow.core.framework import graph_pb2 # -- read in the graph f = open("models/graph.pb", "rb") graph_def = graph_pb2.GraphDef() graph_def.ParseFromString(f.read()) import tensorflow as tf # -- actually import 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: Inspect the protobuf containing the model's architecture and logic
14,825
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper import problem_unittests as tests source_path = 'data/small_vocab_en' target_path = 'data/small_vocab_fr' source_text = helper.load_data(source_path) target_text = helper.load_data(target_path) view_sentence_range = (0, 10) DON'T MODIFY AN...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Language Translation Step3: Explore the Data Step6: Implement Preprocessing Function Step8: Preprocess all the data and save it Step10: Chec...
14,826
<ASSISTANT_TASK:> Python Code: import numpy as np from pylab import * %matplotlib inline import warnings warnings.filterwarnings('ignore') # Now moving on to the SFR-M*-Size analysis %run ~/Dropbox/pythonCode/LCSanalyzeblue.py # using John Moustakas's stellar mass estimates figure() plot(s.s.ABSMAG[:,4][s.blueflag2],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: As of 1/6/16, need to make one more pass through the sample and remove galaxies that are blended with nearby companion. Not sure if people thin...
14,827
<ASSISTANT_TASK:> Python Code: # Import py_entitymatching package import py_entitymatching as em import os import pandas as pd # Get the datasets directory datasets_dir = em.get_install_path() + os.sep + 'datasets' # Get the paths of the input tables path_A = datasets_dir + os.sep + 'person_table_A.csv' path_B = datas...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Then, read the (sample) input tables for blocking purposes Step2: Removing Features from Feature Table
14,828
<ASSISTANT_TASK:> Python Code: # Import the needed packages, SymPy import sympy as sp from sympy import init_printing init_printing() # Define the variables # Complex variable s = sp.symbols('s') # FOTD Coeffficients T1,T2,T3,T4 = sp.symbols('T_1 T_2 T_3 T_4') K1,K2,K3,K4 = sp.symbols('K_1 K_2 K_3 K_4') # Time Delay 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: Interpretation Step2: We now have a system of 4 Equations we can set to zero. We have to solve for four variables, the parameter of the decoupl...
14,829
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from IPython.html.widgets import interact, interactive, fixed from IPython.display import display from IPython.display import SVG s = <svg width="100" height="100"> <circle cx="50" cy="50" r="20" fill="aquamarine" /...
<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 with SVG display Step5: Write a function named draw_circle that draws a circle using SVG. Your function should take the parameters of ...
14,830
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from scipy.interpolate import interp1d with np.load('trajectory.npz') as data: t = data['t'] x = data['x'] y = data['y'] print(t,x,y) assert isinstance(x, np.ndarray) and len(x)==40 assert isinstance(y, 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: 2D trajectory interpolation Step2: Use these arrays to create interpolated functions $x(t)$ and $y(t)$. Then use those functions to create the ...
14,831
<ASSISTANT_TASK:> Python Code: %run "../src/start_session.py" %run "../src/recurrences.py" %run "../src/sums.py" from oeis import oeis_search, ListData import knowledge sys.setrecursionlimit(10000000) s = oeis_search(id=45) s(data_only=True, data_representation=ListData(upper_limit=20)) with bind(IndexedBase('f'), si...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: OEIS Step2: Recurrence Step3: Unfolding Step4: Involution Step5: Subsuming Step6: We can abstract the following conjecture Step7: Instanti...
14,832
<ASSISTANT_TASK:> Python Code: crisisInfo = { "boston": { "name": "Boston Marathon Bombing", "time": 1366051740, # Timestamp in seconds since 1/1/1970, UTC # 15 April 2013, 14:49 EDT -> 18:49 UTC "directory": "boston", "keywords": ["boston", "exploision", ...
<SYSTEM_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 Your Crisis Step2: <hr> Step3: <hr> Step4: Top Twitter Users Step5: Many of these tweets are not relevant to the event at hand. Step6...
14,833
<ASSISTANT_TASK:> Python Code: b = phoebe.default_binary() # set parameter values b.set_value('q', value = 0.6) b.set_value('incl', component='binary', value = 84.5) b.set_value('ecc', 0.2) b.set_value('per0', 63.7) b.set_value('sma', component='binary', value= 7.3) b.set_value('vgamma', value= -32.84) # add an rv 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: Initialize the bundle Step2: rv_geometry Step3: The rv_geometry estimator is meant to provide an efficient starting point for q, vgamma, asini...
14,834
<ASSISTANT_TASK:> Python Code: !ls | grep "mo" !wc -l anonymous-msweb-preprocessed.data && echo !head anonymous-msweb-preprocessed.data !cp anonymous-msweb-preprocessed.data log.txt !cat mostFrequentVisitors.txt | cut -f 1,2 -d',' > urls.txt !wc -l urls.txt && echo !head urls.txt %%writefile join.py from mrjob.job 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: Count lines in log dataset. View the first 10 lines. Rename data to log.txt Step2: Convert the output of 4.4 to be just url and url_id. Save as...
14,835
<ASSISTANT_TASK:> Python Code: from time import time import numpy as np import matplotlib.pyplot as plt from collections import deque import random %matplotlib inline def benchmark(counts): def times(f): def ret(): timings = [] for c in counts: start = time() ...
<SYSTEM_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 with the obvious Step2: Looks pretty linear to me. Apparently string += runs in O(1). That was honestly a shocking discovery to me....
14,836
<ASSISTANT_TASK:> Python Code: %matplotlib inline import sys sys.path.append('../..') from matplotlib import pylab from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt pylab.rcParams['figure.figsize'] = 12, 10 import functools import numpy import scipy import scipy.special from crocodile.clean import...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Generate baseline coordinates for an observation with a hypothetical north-pole VLA over 6 hours, with a visibility recorded every 10 minutes. T...
14,837
<ASSISTANT_TASK:> Python Code: import tensorflow as tf tf.__version__ from tensorflow.contrib import keras from keras.datasets import cifar100 (X_train, Y_train), (X_test, Y_test) = cifar100.load_data(label_mode='fine') from keras import backend as K img_rows, img_cols = 32, 32 if K.image_data_format() == 'channels_fi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Tensorboard Integration Step2: TensorBoard Callback Step4: ```python Step5: Runing Tensorboard Step6: tf.Queue integration with Keras
14,838
<ASSISTANT_TASK:> Python Code: %pylab inline import seaborn as sns import warnings warnings.filterwarnings("ignore") import pandas as pd names = ["Name_2MASS","Name_alt","Spectral_Type","T_eff","AJ","L_bol","IMF"] tbl6 = pd.read_csv("http://iopscience.iop.org/0067-0049/173/1/104/fulltext/71585.tb6.txt", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Table 6 - Derived Properties for Members of Chamaeleon I Step2: Custom analysis Step3: Save data tables locally.
14,839
<ASSISTANT_TASK:> Python Code: !python3 -m pip install pip --upgrade --quiet --user !python3 -m pip install kfp --upgrade --quiet --user !python3 -m pip install tfx==0.21.2 --quiet --user # Set `PATH` to include user python binary directory and a directory containing `skaffold`. PATH=%env PATH %env PATH={PATH}:/home/j...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Note Step2: In this example we'll need TFX SDK later than 0.21 to leverage the RuntimeParameter feature. Step3: TFX Components
14,840
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt %matplotlib inline import seaborn as sns sns.set() # setting seaborn default for plots train = pd.read_csv('train.csv') test = pd.read_csv('test.csv') train.head() train.shape train.describe() train.describe(inclu...
<SYSTEM_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 Datasets Step2: Looking into the training dataset Step3: Below is a brief information about each columns of the dataset Step4: We can...
14,841
<ASSISTANT_TASK:> Python Code: __author__ = "kyubyong. kbpark.linguist@gmail.com" import numpy as np np.__version__ x = np.arange(4).reshape((2, 2)) print("x=\n", x) print("ans=\n", np.amin(x, 1)) x = np.arange(4).reshape((2, 2)) print("x=\n", x) print("ans=\n", np.amax(x, 1, keepdims=True)) x = np.arange(10).reshap...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Order statistics Step2: Q2. Return the maximum value of x along the second axis. Reduce the second axis to the dimension with size one. Step3: ...
14,842
<ASSISTANT_TASK:> Python Code: # Import required libraries from tpot import TPOTClassifier from sklearn.cross_validation import train_test_split import pandas as pd import numpy as np #Load the data Marketing=pd.read_csv('Data_FinalProject.csv') Marketing.head(5) Marketing.groupby('loan').y.value_counts() Marketing.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: Data Exploration Step2: Data Munging Step3: At present, TPOT requires all the data to be in numerical format. As we can see below, our data se...
14,843
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np x = np.linspace(-10, 10, 201) def f(x): return x**2 y = f(x) fig, ax = plt.subplots(1, figsize=(8,4)) ax.plot(x,y, 'g', label='line') ax.fill_between(x,y, color='blue', alpha=0.3, label='area under graph') ax.grid(True) ax.legend() 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: Contents Step2: <a id='Fundamental_Theorem_of_Calculus'></a>
14,844
<ASSISTANT_TASK:> Python Code: # The kernel for this notebook is running Python 3, but we'll see: from __future__ import print_function import mxnet as mx from mxnet import nd, autograd, gluon mx.random.seed(1) data_ctx = mx.cpu() model_ctx = mx.cpu() num_inputs = 2 num_outputs = 1 num_examples = 10000 def real_fn(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: Set the context Step2: Linear regression Step3: Notice that each row in X consists of a 2-dimensional data point and that each row in y consis...
14,845
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib from scipy.io import loadmat from sklearn.preprocessing import OneHotEncoder data = loadmat('../data/andrew_ml_ex33507/ex3data1.mat') data X = data['X'] y = data['y'] X.shape, y.shape#看下维度 # 目前考虑输入是图片...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 模型展示 Step2: 反向传播 Step3: 初始话参数 Step4: 反向传播 Step5: 梯度检验
14,846
<ASSISTANT_TASK:> Python Code: # -*- coding: utf-8 -*- %matplotlib inline import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from pyfme.aircrafts import Cessna310 from pyfme.environment.environment import Environment from pyfme.environment.atmosphere import ISA1976 from pyfme.env...
<SYSTEM_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 variables Step2: Initial conditions
14,847
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import numpy as np import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = (15.0, 8.0) # First, we need to know what's in the data file. !head -15 R11ceph.dat class Cepheids(object): def __init__(self,filename): ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: A Look at Each Host Galaxy's Cepheids Step2: OK, now we are all set up! Let's plot one of the datasets. Step3: Q Step4: Q Step5: Now, let's ...
14,848
<ASSISTANT_TASK:> Python Code: import graphlab sales = graphlab.SFrame('kc_house_data.gl/') import numpy as np # note this allows us to refer to numpy as np instead def get_numpy_data(data_sframe, features, output): data_sframe['constant'] = 1 # this is how you add a constant column to an SFrame # add the 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: Load in house sales data Step2: If we want to do any "feature engineering" like creating new features or adjusting existing ones we should do t...
14,849
<ASSISTANT_TASK:> Python Code: from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import tensorflow as tf import collections import os from google.colab import auth auth.authenticate_user() #@title Choices about the dataset you want to load. #...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: If you choose chain_length 3 the data will look like this Step3: Load the data. Step4: Looking at what we loaded.
14,850
<ASSISTANT_TASK:> Python Code: # When not running on Kaggle, comment out this import from kaggle_datasets import KaggleDatasets # When not running on Kaggle, set a fixed GCS path here GCS_PATH = KaggleDatasets().get_gcs_path('jigsaw-multilingual-toxic-comment-classification') print(GCS_PATH) import os, time, logging 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: Overview Step2: TPU or GPU detection Step3: Configuration Step5: Model Step6: Dataset Step8: Set up our data pipelines for training and eva...
14,851
<ASSISTANT_TASK:> Python Code: import pandas as pd %matplotlib inline # 如果不知道函数名是什么,可以只敲击函数前几个,然后按tab键,就会有下拉框提示 titanic = pd.read_csv('train.csv') titanic.head() titanic.info() # 把所有数值类型的数据做一个简单的统计 titanic.describe() # 统计None值个数 titanic.isnull().sum() # 可以填充整个datafram里边的空值, 可以取消注释,实验一下 # titanic.fillna(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: 导入数据 Step2: 快速预览 Step3: | 单词 | 翻译 Step4: 处理空值 Step5: 尝试从性别进行分析 Step6: 通过上面图片可以看出:性别特征对是否生还的影响还是挺大的 Step7: 分析票价 Step8: 可以看出低票价的人的生还率比较低 S...
14,852
<ASSISTANT_TASK:> Python Code: import rebound sim = rebound.Simulation() sim.add(m=1) sim.add(m=0.1, e=0.041, a=0.4, inc=0.2, f=0.43, Omega=0.82, omega=2.98) sim.add(m=1e-3, e=0.24, a=1.0, pomega=2.14) sim.add(m=1e-3, e=0.24, a=1.5, omega=1.14, l=2.1) sim.add(a=-2.7, e=1.4, f=-1.5,omega=-0.7) # hyperbolic orbit %matpl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: To plot these initial orbits in the $xy$-plane, we can simply call the OrbitPlot function and give it the simulation as an argument. Step2: Not...
14,853
<ASSISTANT_TASK:> Python Code: import graphlab sales = graphlab.SFrame('kc_house_data.gl/') import numpy as np # note this allows us to refer to numpy as np instead def get_numpy_data(data_sframe, features, output): data_sframe['constant'] = 1 # this is how you add a constant column to an SFrame # add the 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: Load in house sales data Step2: If we want to do any "feature engineering" like creating new features or adjusting existing ones we should do t...
14,854
<ASSISTANT_TASK:> Python Code: plot = ChristmasPlot('Fake', n_dataset=3, methods=['yass', 'kilosort', 'spyking circus'], logit_y=True, eval_type="Accuracy") for method in plot.methods: for i in range(plot.n_dataset): x = (np.random.rand(30) - 0.5) * 10 y = 1 / (1 + np.exp(-x + np.random.rand())) ...
<SYSTEM_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 SNR vs Metric Step2: Generate the curve plots
14,855
<ASSISTANT_TASK:> Python Code: '\\'.join(['folder1','folder2','folder3','file.png']) # join all elements using the escaped (literal) '\' string import os # contains many file path related functions print(os.path.join('folder1','folder2','folder3','file.png')) # takes string arguments and returns OS-appropriate path pr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: But this string only works on Windows; to create an OS insensitive path, using the os module Step2: If no explicit path is specified, Python wi...
14,856
<ASSISTANT_TASK:> Python Code: # Example Dataset Review Entry __ = { 'beer/ABV': 7.2, 'beer/beerId': '59261', 'beer/brewerId': '67', 'beer/name': 'Sierra Nevada Torpedo Extra IPA', 'beer/style': 'India Pale Ale &#40;IPA&#41;', 'review/appearance': 1.0, 'review/aroma': 0.8, 'review/overal...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step5: User Level Results Step7: High-level Feature Trends Step8: Review Counts Step9: Average Number of Beer Styles Reviewed Step10: Average Overa...
14,857
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline from matplotlib.pylab import rcParams rcParams['figure.figsize'] = 12, 10 import random x = np.array([i*np.pi/180 for i in range(60,300,4)]) np.random.seed(10) #Setting seed for reproducability y =...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Creating the data Step2: Fit simple linear regression Step3: Determining overfitting Step4: Fit a Linear regression model on the 15 powers St...
14,858
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: データ増強 Step2: データセットをダウンロードする Step3: 花のデータセットには 5 つのクラスがあります。 Step4: データセットから画像を取得し、それを使用してデータ増強を実演してみましょう。 Step5: Keras 前処理レイヤーを使用する Step6: ...
14,859
<ASSISTANT_TASK:> Python Code: # Imports import numpy as np import matplotlib from matplotlib import pyplot as plt %matplotlib inline ## use `%matplotlib notebook` for interactive figures # plt.style.use('ggplot') import sklearn import tigramite from tigramite import data_processing as pp from tigramite.toymodels ...
<SYSTEM_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. Structural causal processes with contemporaneous and lagged dependencies Step2: The true graph $\mathcal{G}$ here has shape (N, N, 2+1) sinc...
14,860
<ASSISTANT_TASK:> Python Code: class MyClass: def __init__(self, val): self.set_val(val) def get_val(self): return self._val def set_val(self, val): if val > 0: self._val = val else: raise ValueError('val must be greater 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: Wie wir sehen, ist die Eigenschaft _val durchaus von außerhalb verfügbar. Allerdings signalisiert das Underline, dass vom Programmierer der Klas...
14,861
<ASSISTANT_TASK:> Python Code: # Versão da Linguagem Python from platform import python_version print('Versão da Linguagem Python Usada Neste Jupyter Notebook:', python_version()) # Imports import time import numpy as np import pandas as pd import matplotlib as mat from matplotlib import pyplot as plt from sklearn.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: Exercício Step2: Extração e Transformação de Dados Step3: Exploração de Dados Step4: Plot
14,862
<ASSISTANT_TASK:> Python Code: # AR parameters p = 4 a = 1.0 * np.random.rand(p) - 0.5 print "Original AR parameters:\n", a # Time series data N = 1000 n = np.arange(0, N) # Input white noise eparam = (0, 1.0) e = np.sqrt(eparam[1]) * np.random.randn(N) + eparam[0] # Generate AR time series. y = genARProcess(p, a, epar...
<SYSTEM_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 AR parameters using the entire dataset Step2: Whiten the AR process output using the $\hat{a}$ Step3: Non-stationary AR process with...
14,863
<ASSISTANT_TASK:> Python Code: from openhunt.mordorutils import * spark = get_spark() sd_file = "https://raw.githubusercontent.com/OTRF/Security-Datasets/master/datasets/atomic/windows/defense_evasion/host/empire_psinject_PEinjection.zip" registerMordorSQLTable(spark, sd_file, "sdTable") df = spark.sql( ''' SELECT `@...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Download & Process Security Dataset Step2: Analytic I
14,864
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division import time from matplotlib import rcParams import matplotlib.pyplot as plt %matplotlib inline rcParams['figure.figsize'] = (13, 6) plt.style.use('ggplot') from nilmtk import DataSet, TimeFrame, MeterGroup, HDFDataStore from nilmtk.disaggreg...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Dividing data into train and test set Step2: Let us use building 1 for demo purposes Step3: Let's split data at April 30th Step4: REDD data s...
14,865
<ASSISTANT_TASK:> Python Code: import os from copy import deepcopy import numpy as np import mne sample_data_folder = mne.datasets.sample.data_path() sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample', 'sample_audvis_raw.fif') raw = mne.io.read_raw_fif(sample_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: Marking bad channels Step2: Here you can see that the Step3: We can do the same thing for the bad MEG channel (MEG 2443). Since we Step4: No...
14,866
<ASSISTANT_TASK:> Python Code: from pandas import DataFrame import sqlite3 query = CREATE TABLE test (a VARCHAR(20), b VARCHAR(20), c REAL, d INTEGER ); con = sqlite3.connect(':memory:') con.execute(query) con.commit() data = [('Atlanta', 'Georgia', 1.25, 6), ('Tallahassee', 'Florida', 2.6, 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: Step2: Loading data from SQL into a DataFrame is fairly straightforward, and pandas has some functions to simplify the process. As an example, I’ll use...
14,867
<ASSISTANT_TASK:> Python Code: #general imports import pygslib #get the data in gslib format into a pandas Dataframe cluster= pygslib.gslib.read_gslib_file('../datasets/cluster.dat') true= pygslib.gslib.read_gslib_file('../datasets/true.dat') true['Declustering Weight'] = 1 npoints = len(cluster['Primary']) tru...
<SYSTEM_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 ready for work Step2: QQ-Plot
14,868
<ASSISTANT_TASK:> Python Code: import os.path as op import numpy as np import mne data_path = mne.datasets.opm.data_path() subject = 'OPM_sample' subjects_dir = op.join(data_path, 'subjects') raw_fname = op.join(data_path, 'MEG', 'OPM', 'OPM_SEF_raw.fif') bem_fname = op.join(subjects_dir, subject, 'bem', ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Prepare data for localization Step2: Examine our coordinate alignment for source localization and compute a Step3: Perform dipole fitting Step...
14,869
<ASSISTANT_TASK:> Python Code: !pip install -I "phoebe>=2.0,<2.1" %matplotlib inline import phoebe from phoebe import u import numpy as np import matplotlib.pyplot as plt logger = phoebe.logger() b = phoebe.default_binary(contact_binary=True) b.add_dataset('lc', times=np.linspace(0,1,101), dataset='lc01') b.add_datas...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: As always, let's do imports and initialize a logger and a new bundle. See Building a System for more details. Step2: Adding Datasets and Compu...
14,870
<ASSISTANT_TASK:> Python Code: %pylab inline ! grep "multipv 1" log4.txt | grep -v lowerbound | grep -v upperbound > log4_g.txt def parse_info(l): D = {} k = l.split() i = 0 assert k[i] == "info" i += 1 while i < len(k): if k[i] == "depth": D[k[i]] = int(k[i+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 Speed of Search Step2: So nodes per second is roughly constant Step3: The hashtable usage is at full capacity Step4: Number of nodes need...
14,871
<ASSISTANT_TASK:> Python Code: import jax.numpy as jnp from jax import grad, jit, vmap from jax import random # A helper function to randomly initialize weights and biases # for a dense neural network layer def random_layer_params(m, n, key, scale=1e-2): w_key, b_key = random.split(key) return scale * random.norma...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Hyperparameters Step2: Auto-batching predictions Step3: Let's check that our prediction function only works on single images. Step5: At this ...
14,872
<ASSISTANT_TASK:> Python Code: !pip install tensorflow==1.15 dm-sonnet==1.36 tensor2tensor==1.14 import time import numpy as np import tensorflow.compat.v1 as tf tf.logging.set_verbosity(tf.logging.ERROR) # Hide TF deprecation messages import matplotlib.pyplot as plt %cd /tmp %rm -rf /tmp/deepmind_research !git clone ...
<SYSTEM_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 pre-trained model weights from Google Cloud Storage Step2: Pre-trained model config Step3: Generate class-conditional samples Step4: ...
14,873
<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: 在 Tensorflow 中训练提升树(Boosted Trees)模型 Step2: 数据集由训练集和验证集组成: Step3: 训练集和评估集分别有 627 和 264 个样本。 Step4: 大多数乘客在 20 岁或 30 岁。 Step5: 男乘客大约是女乘客的两倍。 S...
14,874
<ASSISTANT_TASK:> Python Code: import pandas as pd import scipy as sp from scipy import stats import matplotlib.pyplot as plt %matplotlib inline %config InlineBackend.figure_format = 'svg' exec(open('settings.py').read(), globals()) cell_numbers = pd.read_csv('../data/cell_number_data.csv') outgrowth = pd.read_csv('../...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Check for significant differences Step2: ttest vs day0 Step3: Plot
14,875
<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: pix2pix Step2: Load the dataset Step3: Each original image is of size 256 x 512 containing two 256 x 256 images Step4: You need to separate r...
14,876
<ASSISTANT_TASK:> Python Code: def insertion_sort(unsorted_list): x = ipytracer.List1DTracer(unsorted_list) display(x) for i in range(1, len(x)): j = i - 1 key = x[i] while x[j] > key and j >= 0: x[j+1] = x[j] j = j - 1 x[j+1] = key return x.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: work Step2: Code2 - ChartTracer Step3: work
14,877
<ASSISTANT_TASK:> Python Code: # As usual, a bit of setup from __future__ import print_function import time import numpy as np import matplotlib.pyplot as plt from cs231n.classifiers.fc_net import * from cs231n.data_utils import get_CIFAR10_data from cs231n.gradient_check import eval_numerical_gradient, eval_numerical_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Fully-Connected Neural Nets Step4: Affine layer Step5: Affine layer Step6: ReLU layer Step7: ReLU layer Step8: "Sandwich" layers Step9: Lo...
14,878
<ASSISTANT_TASK:> Python Code: import graphlab sales = graphlab.SFrame('kc_house_data.gl/kc_house_data.gl') c = sales.random_split(.8,seed=0) train_data=c # Let's compute the mean of the House Prices in King County in 2 different ways. prices = sales['price'] # extract the price column of the sales SFrame -- this is...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load house sales data Step2: Split data into training and testing Step3: Useful SFrame summary functions Step4: As we see we get the same ans...
14,879
<ASSISTANT_TASK:> Python Code: import os import re import operator import matplotlib.pyplot as plt import warnings import gensim import numpy as np warnings.filterwarnings('ignore') # Let's not pay heed to them right now import nltk nltk.download('stopwords') # Let's make sure the 'stopword' package is downloaded & up...
<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: Analysing our corpus. Step4: Preprocessing our data. Remember Step5: Finalising our dictionary and corpus Step6: Topic modeling with LSI Step...
14,880
<ASSISTANT_TASK:> Python Code: def countGreater(arr , n , k ) : l = 0 r = n - 1 leftGreater = n while(l <= r ) : m = int(l +(r - l ) / 2 ) if(arr[m ] > k ) : leftGreater = m r = m - 1  else : l = m + 1   return(n - leftGreater )  if __name__== ' __main __' : arr =[3 , 3 , 4 , 7 , 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:
14,881
<ASSISTANT_TASK:> Python Code: import copy import cPickle import glob import gzip import os import random import shutil import subprocess import cdpybio as cpb import matplotlib.pyplot as plt import numpy as np import pandas as pd import peer import pybedtools as pbt import scipy.stats as stats import seaborn as sns im...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Cohort Information Step2: Most were collected at passage 12-16 although a few are at later passages. Step3: Kinship Matrix Step4: LD prune 1K...
14,882
<ASSISTANT_TASK:> Python Code: data = pd.read_csv('../benchMarkingResult.txt', header=None, sep='\t', names=('iteration', 'basic_result', 'efficient_result')) x = data.iteration y1 = data.basic_result y2 = 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: Plot the Basic and Efficient data first Step2: do a linear regression for the 2 lines and evaluate the r-squared value Step3: both r-squared l...
14,883
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 from __future__ import print_function import numpy as np import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = (6.0, 6.0) plt.rcParams['savefig.dpi'] = 100 from straightline_utils import * (x,y,sigmay) = generate_data() plo...
<SYSTEM_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 Data Step2: Characterizing the posterior PDF Step3: And now to draw some samples Step4: Looks reasonable Step5: It looks like we made a ...
14,884
<ASSISTANT_TASK:> Python Code: import plotly.graph_objs as go from plotly.offline import init_notebook_mode,iplot init_notebook_mode(connected=True) import pandas as pd df = pd.read_csv('./2014_World_Power_Consumption') df.head() data = {'type':'choropleth', 'locations':df['Country'],'locationmode':'country names', ...
<SYSTEM_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 pandas and read the csv file Step2: Referencing the lecture notes, create a Choropleth Plot of the Power Consumption for Countries using...
14,885
<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_constraint('semidetached', 'primary') b['requiv@constraint@primary'] b['requiv...
<SYSTEM_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: Semi-Detached Systems Ste...
14,886
<ASSISTANT_TASK:> Python Code: % matplotlib inline import pandas as pd import glob import matplotlib.pyplot as plt GRLM = "345_GRLM10.txt"; print GRLM df_grlm = pd.read_csv(GRLM, skiprows=43, delim_whitespace=True, names="mission,cycle,date,hour,minute,lake_height,error,mean(decibels),IonoCorrection,TropCorrection".spl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: GRLM Altimetry data from July 22 2008 to September 3, 2016 Step2: Interpolate the missing data points Step3: Add time information to the dataf...
14,887
<ASSISTANT_TASK:> Python Code: a = 10 b = 20 c = "Hello" print a, b, c list_items = ["milk", "cereal", "banana", 22.5, [1,2,3]] ## A list can contain another list and items of different types print list_items print "3rd item in the list: ", list_items[2] # Zero based index starts from 0 so 3rd item will have index 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: Lists Step2: Sets Step3: Dictionaries Step4: Functions Step5: Loading Data Step6: Pandas Step7: Filtering data Step8: Titanic data Step9...
14,888
<ASSISTANT_TASK:> Python Code: # initialize your CORDEX submission form template from dkrz_forms import form_handler from dkrz_forms import checks my_email = "..." # example: sf.email = "Mr.Mitty@yahoo.com" my_first_name = "..." # example: sf.first_name = "Harold" my_last_name = "..." # example: sf.last_name ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: please provide information on the contact person for this CORDEX data submission request Step2: Type of submission Step3: Requested general in...
14,889
<ASSISTANT_TASK:> Python Code: import numpy as np # importing this way allows us to refer to numpy as np mylist = [1., 2., 3., 4.] mynparray = np.array(mylist) mynparray one_vector = np.ones(4) print one_vector # using print removes the array() portion one2Darray = np.ones((2, 4)) # an 2D array with 2 "rows" and 4 "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: Creating Numpy Arrays Step2: You can initialize an array (of any dimension) of all ones or all zeroes with the ones() and zeros() functions Ste...
14,890
<ASSISTANT_TASK:> Python Code: cadena_caracteres = "Hola mundo" print dir(cadena_caracteres) print 'Hola mundo' print 'Pero el print también imprime un Enter al terminar la línea' print 'Pero al imprimir con la coma al final', print 'cambia el enter por un espacio' print 'También puedo escribir lo mismo' ' en dos par...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: String formating Step2: Pero si no queremos imprimir ese último Enter lo que tenemos que hacer es poner una coma al final de la línea Step3: ¿...
14,891
<ASSISTANT_TASK:> Python Code: data_original = np.loadtxt('stanford_dl_ex/ex1/housing.data') data = np.insert(data_original, 0, 1, axis=1) np.random.shuffle(data) train_X = data[:400, :-1] train_y = data[:400, -1] test_X = data[400:, :-1] test_y = data[400:, -1] m, n = train_X.shape def cost_function(theta, X, y): ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Create train & test sets. Step2: Define the cost function and how to compute the gradient.<br> Step3: Run a timed optimization and store the i...
14,892
<ASSISTANT_TASK:> Python Code: from pynq import Overlay from pynq.drivers import Audio Overlay('base.bit').download() pAudio = Audio() pAudio.record(3) pAudio.save("Recording_1.pdm") pAudio.load("/home/xilinx/pynq/drivers/tests/pynq_welcome.pdm") pAudio.play() import time import numpy as np start = time.time() af_ui...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Record and play Step2: Load and play Step3: Play in notebook Step4: Step 2 Step5: Step 3 Step6: Plotting PCM data Step7: Frequency spectru...
14,893
<ASSISTANT_TASK:> Python Code: import requests response = requests.get("https://api.forecast.io/forecast/e554f37a8164ce189acd210d00a452e0/47.4079,9.4647") weather_data = response.json() weather_data.keys() print(weather_data['timezone']) print("Longitude:", weather_data['longitude'], "Latitude", weather_data['latitude...
<SYSTEM_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 time zone of Trogen is correct! This is where I live. Step2: The longitude is mentioned first, and then the latitude. Usually, it is the ot...
14,894
<ASSISTANT_TASK:> Python Code: import coiled cluster = coiled.Cluster(n_workers=10) from dask.distributed import Client client = Client(cluster) print('Dashboard:', client.dashboard_link) <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 point the distributed client to the Dask cluster on Coiled and output the link to the dashboard
14,895
<ASSISTANT_TASK:> Python Code: #Create references to important directories we will use over and over import os, sys DATA_HOME_DIR = '/home/nathan/olin/spring2017/line-follower/line-follower/data' #import modules import numpy as np from glob import glob from PIL import Image from tqdm import tqdm from scipy.ndimage impo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Create paths to data directories Step7: Helper Functions Step8: Data Step9: Test the shape of the arrays Step10: Visualize the training data...
14,896
<ASSISTANT_TASK:> Python Code: import deltascope as ds import deltascope.alignment as ut import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.preprocessing import normalize from scipy.optimize import minimize import os import tqdm import json import datetime # ---------------------------...
<SYSTEM_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 raw data Step2: We'll generate a list of pairs of stypes and channels for ease of use. Step3: We can now read in all datafiles specifie...
14,897
<ASSISTANT_TASK:> Python Code: import numpy as np from load import mnist X_train, X_test, y_train2, y_test2 = mnist(onehot=True) y_train = np.argmax(y_train2, axis=1) y_test = np.argmax(y_test2, axis=1) X_train[1].reshape((28, 28)).round(2)[:, 4:9].tolist() from pylab import imshow, show, cm import matplotlib.pylab 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: 12 - Introduction to Deep Learning Step2: Naive model Step3: Lets try an other example Step4: Logistic Regression Step5: ``` Step6: initia...
14,898
<ASSISTANT_TASK:> Python Code: import astropy.coordinates as coord import astropy.table as at from astropy.time import Time import astropy.units as u import matplotlib.pyplot as plt import numpy as np %matplotlib inline import corner import pymc3 as pm import pymc3_ext as pmx import exoplanet as xo import arviz as az 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: Here we will again load some pre-generated data meant to represent well-sampled, precise radial velocity observations of a single luminous sourc...
14,899
<ASSISTANT_TASK:> Python Code: # !pip install ray[tune] !pip install scikit-optimize==0.8.1 !pip install sklearn==0.18.2 import time from typing import Dict, Optional, Any import ray import skopt from ray import tune from ray.tune.suggest import ConcurrencyLimiter from ray.tune.suggest.skopt import SkOptSearch ray.ini...
<SYSTEM_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 below to see all the imports we need for this example. Step2: Let's start by defining a simple evaluation function. Again, an explicit ma...