Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
6,200
<ASSISTANT_TASK:> Python Code: MODEL_NAME = 'reg-model-01' TRAIN_DATA_FILE = 'data/train-data.csv' VALID_DATA_FILE = 'data/valid-data.csv' TEST_DATA_FILE = 'data/test-data.csv' RESUME_TRAINING = False PROCESS_FEATURES = True MULTI_THREADING = False HEADER = ['key','x','y','alpha','beta','target'] HEADER_DEFAULTS = [[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: 1. Define Dataset Metadata Step2: 2. Define Data Input Function Step3: 3. Define Feature Columns Step4: 4. Create an Estimator Step5: b. Set...
6,201
<ASSISTANT_TASK:> Python Code: import os.path as op import numpy as np from mayavi import mlab import mne from mne.datasets import sample from mne.minimum_norm import read_inverse_operator, apply_inverse from mne.simulation import simulate_stc, simulate_evoked seed = 42 # parameters for inverse method method = 'sLORET...
<SYSTEM_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 set some parameters. Step2: Load the MEG data Step3: Estimate the background noise covariance from the baseline period Step4: Gener...
6,202
<ASSISTANT_TASK:> Python Code: # system functions that are always useful to have import time, sys, os # basic numeric setup import numpy as np import math # inline plotting %matplotlib inline # plotting import matplotlib from matplotlib import pyplot as plt # seed the random number generator rstate = np.random.default_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 2-D Gaussian Shells Step2: Default Run Step3: Bounding Options Step4: We can see the amount of overhead associated with 'balls' and 'cubes' i...
6,203
<ASSISTANT_TASK:> Python Code: import os from google.cloud import bigquery PROJECT = !gcloud config list --format 'value(core.project)' PROJECT = PROJECT[0] BUCKET = PROJECT REGION = "us-central1" os.environ["BUCKET"] = BUCKET os.environ["REGION"] = REGION %%bash ## Create a BigQuery dataset for babyweight if it does...
<SYSTEM_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 environment variables so that we can use them throughout the entire lab. We will be using our project ID for our bucket. Step2: The source ...
6,204
<ASSISTANT_TASK:> Python Code: my_cat = 'cheshire' catepillar_question = 'Who are you?' _catepillar_question = 'Who are you?' catepillar_Question1 = 'Who are you?' 1catepillar_question = 'Who are you?' my_cat = 'cheshire' my_cat = 'grinning' my_cat = 'cheshire' print(my_cat) # see if you can display the value assig...
<SYSTEM_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 my_cat is the variable, and 'cheshire' is the value assigned to that variable. In general in Python, the thing on the left hand side of the...
6,205
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'test-institute-2', 'sandbox-2', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributo...
<SYSTEM_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...
6,206
<ASSISTANT_TASK:> Python Code: ENDPOINT = "<YOUR_ENDPOINT>" PROJECT_ID = !(gcloud config get-value core/project) PROJECT_ID = PROJECT_ID[0] %%writefile kfp-cli/Dockerfile # TODO IMAGE_NAME = "kfp-cli" TAG = "latest" IMAGE_URI = f"gcr.io/{PROJECT_ID}/{IMAGE_NAME}:{TAG}" !gcloud builds # COMPLETE THE COMMAND %%writef...
<SYSTEM_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 KFP CLI builder Step2: Build the image and push it to your project's Container Registry. Step3: Exercise Step4: Understanding th...
6,207
<ASSISTANT_TASK:> Python Code: from cobra import Model, Reaction, Metabolite # Best practise: SBML compliant IDs cobra_model = Model('example_cobra_model') reaction = Reaction('3OAS140') reaction.name = '3 oxoacyl acyl carrier protein synthase n C140 ' reaction.subsystem = 'Cell Envelope Biosynthesis' reaction.lower_bo...
<SYSTEM_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 need to create metabolites as well. If we were using an existing model, we could use get_by_id to get the apporpriate Metabolite objects inst...
6,208
<ASSISTANT_TASK:> Python Code: from notebook_preamble import J, V, define define('BTree-iter == [not] [pop] roll< [dupdip rest rest] cons [step] genrec') J('[] [23] BTree-iter') # It doesn't matter what F is as it won't be used. J('["tommy" 23 [] []] [first] BTree-iter') J('["tommy" 23 ["richard" 48 [] []] ["jenny" 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: Adding Nodes to the BTree Step2: (As an implementation detail, the [[] []] literal used in the definition of BTree-new will be reused to supply...
6,209
<ASSISTANT_TASK:> Python Code: import pandas as pd # Crear una seríe indicando la producción por mes produccion = pd.Series( [120,130,110,150,170,180,170,160,190,175,160,141], index=['ene','feb','mar','abr','may','jun','jul','ago','sep','oct','nov','dec'] ) print(produccion) # Crear una serie ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Pandas es una librería orientada a objetos y los objetos más importantes que incluye son las Series y los DataFrames. Step2: Atributos y Método...
6,210
<ASSISTANT_TASK:> Python Code: from biofloat import ArgoData ad = ArgoData() wmo_list = ad.get_oxy_floats_from_status() sdf, _ = ad._get_df(ad._STATUS) sdf.ix[:, 'WMO':'GREYLIST'].head() %pylab inline def dist_plot(df, title): from datetime import date ax = df.hist(bins=100) ax.set_xlabel('AGE (days)') ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Get the default list of floats that have oxygen data. Step2: We can explore the distribution of AGEs of the Argo floats by getting the status d...
6,211
<ASSISTANT_TASK:> Python Code: #importing all required modules #important otherwise pop-up window may not work %matplotlib inline import numpy as np import scipy as sp from scipy.integrate import odeint, ode, romb, cumtrapz import matplotlib as mpl import matplotlib.pyplot as plt from math import * import seaborn from...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: RLC circuit is governed by the following formulas Step2: RLC circuit fed with dc voltage Step3: RLC Circuit with sinusoidal voltage
6,212
<ASSISTANT_TASK:> Python Code: import os os.listdir('partonopeus') inputFiles = {} for inputFile in os.listdir('partonopeus'): siglum = inputFile[0] contents = open('partonopeus/' + inputFile,'rb').read() inputFiles[siglum] = contents from lxml import etree print(etree.tostring(etree.XML(inputFiles['A']))...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We create a dictionary to hold our input files, using the single-letter filename before the '.xml' extension as the key and the file itself as t...
6,213
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cas', 'sandbox-1', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "em...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 2...
6,214
<ASSISTANT_TASK:> Python Code: from landlab.components import SpeciesEvolver, Profiler from landlab.components.species_evolution import ZoneController from landlab.io import read_esri_ascii from landlab.plot import imshow_grid import matplotlib.pyplot as plt import numpy as np # Create a model grid and set a topograph...
<SYSTEM_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 the grid Step2: Create a grid field of air temperature at the land surface Step3: Setup SpeciesEvolver and zones Step4: View record_d...
6,215
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mpi-m', 'sandbox-2', 'seaice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "em...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 2...
6,216
<ASSISTANT_TASK:> Python Code: import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) import timeit import warnings from itertools import product warnings.filterwarnings("ignore") pd.options.mode.chained_assignment = None # default='warn' from ipyleaflet 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: Просуммируйте общее количество поездок такси из каждой географической зоны и посчитайте количество ячеек, из которых в мае не было совершено ни ...
6,217
<ASSISTANT_TASK:> Python Code: import numpy as np from matplotlib import pyplot as plt # Number of row and columns in the matrix nrows = 200 # Number of maximum iterations maxiters = 500 # Radius of neighbors that affect the value of the current cell (radius of 1 means that only the 8 cells immediately # adjacent hav...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Model Parameters Step2: The<code> makematrix()</code> function takes as argument the number of rows and columns of the matrix to model Step3: ...
6,218
<ASSISTANT_TASK:> Python Code: import pandas as pd # pandas for handling mixed data sets import numpy as np # numpy for basic math and matrix operations # create a data frame containing variables of disparate scale scratch_df = pd.DataFrame({'x1': pd.Series(np.random.choice(1000, 20)), ...
<SYSTEM_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 sample data set Step2: Standardize
6,219
<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...
6,220
<ASSISTANT_TASK:> Python Code: a = 3 print(type(a)) b = [1, 2.5, 'This is a string'] print(type(b)) c = 'Hello world!' print(type(c)) a = [1, 2, 3, 4] print('This is the zeroth value in the list: {}'.format(a[0])) <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: If you come from a background of matlab, remember that indexing in python
6,221
<ASSISTANT_TASK:> Python Code: import numpy as np import numpy.linalg as la import matplotlib.pyplot as plt import matplotlib.image as mpimg %matplotlib inline def plot_all(m, d, m_est, d_pred): Helper function for plotting. You can ignore this. fig = plt.figure(figsize=(10,6)) ax0 = fig.add_subpl...
<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: Linear inverse solutions in NumPy Step3: Mauricio's 1D problem in 2D Step4: Form the discrete kernel, G. Step5: Compute the data; this is the...
6,222
<ASSISTANT_TASK:> Python Code: import logging # python logging module # basic format for logging logFormat = "%(asctime)s - [%(levelname)s] (%(funcName)s:%(lineno)d) %(message)s" # logs will be stored in tweepy.log logging.basicConfig(filename='tweepytrends.log', level=logging.INFO, format=logFormat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Authentication and Authorisation Step3: Post this step, we will have full access to twitter api's Step9: Streaming with tweepy
6,223
<ASSISTANT_TASK:> Python Code: #@title # Copyright 2020 Google LLC. # 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...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Here is how you can set the fastmath backend to tensorflow-numpy and verify that it's been set. Step2: 2. Convert Trax to Keras Step3: 3. Expo...
6,224
<ASSISTANT_TASK:> Python Code: from statistics import mean def occ(n): "The expected occupancy for a row of n houses (under misanthrope rules)." return (0 if n == 0 else 1 if n == 1 else mean(occ(L) + 1 + occ(R) for (L, R) in runs(n))) def runs(n): A list [(L, 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: The Puzzle of the Misanthropic Neighbors Step2: Let's check that occ(4) is 2, as we computed it should be Step3: And that runs(7) is what we d...
6,225
<ASSISTANT_TASK:> Python Code: %load_ext watermark %watermark -u -v -d -p matplotlib,numpy %matplotlib inline from mpl_toolkits.mplot3d import Axes3D import numpy as np from matplotlib import pyplot as plt # Generate some 3D sample data mu_vec1 = np.array([0,0,0]) # mean vector cov_mat1 = np.array([[1,0,0],[0,1,0],[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: <font size="1.5em">More info about the %watermark extension</font> Step2: <br> Step3: <br> Step4: <br> Step5: <br> Step6: <br>
6,226
<ASSISTANT_TASK:> Python Code: try: import verta except ImportError: !pip install verta HOST = "app.verta.ai" PROJECT_NAME = "Spam Detection" EXPERIMENT_NAME = "tf–idf" # import os # os.environ['VERTA_EMAIL'] = # os.environ['VERTA_DEV_KEY'] = from __future__ import print_function import json import os impor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: This example features Step2: Imports Step3: Run Workflow Step4: Instantiate Client Step5: Fit Model Step6: Define Model Class Step7: Earli...
6,227
<ASSISTANT_TASK:> Python Code: import numpy as np list1 = [1, 2, 3, 4, 5] # Define a list array1 = np.array(list1) # Pass the list to np.array() type(array1) # Check the object's type print("array1 = ", array1) # Check the content of the array (printing in Python 3) print ("a...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We can create an ndarray by passing a list to the np.array() function Step2: To create an array with more than one dimension, we can pass a nes...
6,228
<ASSISTANT_TASK:> Python Code: dot = Digraph(comment='Design of Experiments') dot.body.extend(['rankdir=LR', 'size="10,10"']) dot.node_attr.update(shape='rectangle', style='filled', fontsize='20', fontname="helvetica") dot.node('X', 'Controllable Factors', color='mediumseagreen', width='3') dot.node('Z', 'Noise Factors...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: What Is It For? Step2: (((( Step3: Factorial Design Step5: Statistical Power Step6: Calculating Power with dexpy Step7: Fractional Factoria...
6,229
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as pl pl.style.use('ggplot') import numpy as np from scipy.stats import gamma from sklearn.gaussian_process import GaussianProcessRegressor from sklearn.gaussian_process.kernels import WhiteKernel, RBF from revrand import StandardLinearModel, Ge...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Dataset settings and creation Step2: Algorithm Settings Step3: Parameter learning Step4: Model Querying Step5: Score the models Step6: Plot...
6,230
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt from ttim import * import pandas as pd H = 7 #aquifer thickness zt = -18 #top boundary of aquifer zb = zt - H #bottom boundary of aquifer Q = 788 #constant discharge #unkonwn parameters: kaq, Saq ml = ModelMaq(kaq=60,...
<SYSTEM_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 basic parameters for the model Step2: Create conceptual model Step3: Load data of two observation wells Step4: Calibrate using only the d...
6,231
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'miroc', 'miroc-es2h', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 2...
6,232
<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: Transfer learning and fine-tuning Step2: Data preprocessing Step3: Show the first nine images and labels from the training set Step4: As the ...
6,233
<ASSISTANT_TASK:> Python Code: data_in_shape = (5, 5, 2) conv = Conv2D(4, (3,3), strides=(1,1), padding='valid', data_format='channels_last', dilation_rate=(1,1), activation='linear', use_bias=True) layer_0 = Input(shape=data_in_shape) layer_1 = conv(layer_0) model = Model(inputs=layer_0, ou...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: [convolutional.Conv2D.1] 4 3x3 filters on 5x5x2 input, strides=(1,1), padding='valid', data_format='channels_last', dilation_rate=(1,1), activat...
6,234
<ASSISTANT_TASK:> Python Code: import os import inspect import sys import pandas as pd import charts from opengrid.library import houseprint import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = 16,8 hp = houseprint.Houseprint() # for testing: # hp = houseprint.Houseprint(spreadsheet='uni...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Houseprint Step2: A Houseprint object can be saved as a pickle. It loses its tmpo session however (connections cannot be pickled) Step3: TMPO ...
6,235
<ASSISTANT_TASK:> Python Code: from resources.iot.device import IoT_sensor_consumer from IPython.core.display import display import ipywidgets as widgets from resources.iot.device import IoT_mqtt_publisher, IoT_sensor widgets.FloatProgress(value=30.0, min=0, max=100.0, bar_style='danger', orientation='vertical') widge...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Barra Step2: Label Step3: Criando dois componentes visuais Step4: Renderizando componentes visuais Step5: Criando um componente que consome ...
6,236
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'csiro-bom', 'sandbox-2', 'aerosol') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name"...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
6,237
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import problem_unittests as tests import tarfile cifar10_dataset_folder_path = 'cifar-10-batches-py' class DLProgress(tqdm): last_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: Step1: Image Classification Step2: Explore the Data Step5: Implement Preprocess Functions Step8: One-hot encode Step10: Randomize Data Step12: Che...
6,238
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns plt.rcParams = plt.rcParamsOrig from tqdm.notebook import trange class HMM: def __init__(self, p_start, p_trans, p_emit, p_stop=None): assert p_trans.shape[0] == p_emit.shape[0] ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step5: 1. Hidden Markov Model (10 poin) Step6: Contoh kasus di bawah ini diadaptasi dari sini. Contoh ini adalah penggunaan HMM untuk mencari sequence...
6,239
<ASSISTANT_TASK:> Python Code: # Author: Denis A. Engemann <denis.engemann@gmail.com> # # License: BSD (3-clause) import os import os.path as op import numpy as np from scipy.misc import imread import matplotlib.pyplot as plt import mne from mne import io from mne.datasets import spm_face from mne.minimum_norm import a...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Get data Step2: Estimate covariances Step4: Show the resulting source estimates
6,240
<ASSISTANT_TASK:> Python Code: import modin.pandas as pd import pandas import numpy as np import time frame_data = np.random.randint(0, 100, size=(2**18, 2**8)) df = pd.DataFrame(frame_data).add_prefix("col") pandas_df = pandas.DataFrame(frame_data).add_prefix("col") modin_start = time.time() print(df.mask(df < 50)) mo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Concept for exercise Step2: Speed improvements Step3: Congratulations! You have just implemented new DataFrame functionality!
6,241
<ASSISTANT_TASK:> Python Code: ! pip3 install -U google-cloud-automl --user ! pip3 install google-cloud-storage import os if not os.getenv("AUTORUN"): # Automatically restart kernel after installs import IPython app = IPython.Application.instance() app.kernel.do_shutdown(True) PROJECT_ID = "[your-pro...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Install the Google cloud-storage library as well. Step2: Restart the Kernel Step3: Before you begin Step4: Region Step5: Timestamp Step6: A...
6,242
<ASSISTANT_TASK:> Python Code: import numpy as np import timeit import aurora as au # import Aurora import aurora.autodiff as ad # importing Aurora's automatic differentiation framework import matplotlib.pyplot as plt import seaborn as sbn sbn.set() BATCH_SIZE = 64 LR = 1e-4 USE_GPU = False NUM_ITERS = 20 # utility 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: Let's Explore the Dataset Step2: Building the Computational Graph Step3: Training Our Model Step4: Reporting Testing Accuracy and Plotting Tr...
6,243
<ASSISTANT_TASK:> Python Code: import numpy as np from sklearn.datasets import fetch_olivetti_faces random_state = 32 dataset = fetch_olivetti_faces(shuffle=True, random_state=random_state) X, y = dataset['data'], dataset['target'] n_x, n_y = dataset['images'][0].shape X_data = X.reshape(-1, n_x, n_y).transpose(1, 2, 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: Get the connectivity (spatial structure) Step2: Custering Step3: Results visualization
6,244
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import problem_unittests as tests import tarfile cifar10_dataset_folder_path = 'cifar-10-batches-py' # Use Floyd's cifar-10 dataset if ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Image Classification Step2: Explore the Data Step5: Implement Preprocess Functions Step8: One-hot encode Step10: Randomize Data Step12: Che...
6,245
<ASSISTANT_TASK:> Python Code: import csv # module used for reading and converting .CSV files import os # module that enables local operating system dependent commands filepath = 'C:/Users/Radley/Downloads/' # store file location as a string filename = 'lbl.csv' # store the file name as a ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Normally, you're file of interest is not located in the default working directory of Python. os.chdir() changes the working directory so we can ...
6,246
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() import httplib2 # pip install httplib2 import json # déjà installée, sinon : pip install json import apiclient.discovery # pip install google-api-python-client import bs4 # déjà ja installée, sinon : pip install bs4 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: Le traitement automatique des langues (ou Natural Language Processing) propose un ensemble de méthodes permettant (entre autres) Step2: Récupé...
6,247
<ASSISTANT_TASK:> Python Code: 2 * 4 - (7 - 1) / 3 + 1.0 1 / 0 1.0 / 0.0 3 / 2 3 // 2 2 ** 16 2 + 3j 1j # Valor absoluto abs(2 + 3j) abs(_13) int(18.6) round(18.6) float(1) complex(2) str(256568) a = 2. type(a) isinstance(a, float) print('hola mundo') max(1,5,8,7) min(-1,1,0) a = 1 + 2j b = 3.14159 b 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: Las divisiones por cero lanzan un error Step2: <div class="alert alert-info">Más adelante veremos cómo tratar estos errores. Por otro lado, cua...
6,248
<ASSISTANT_TASK:> Python Code: # execute this cell np.random.seed(0) x = np.concatenate([stats.cauchy(-5, 1.8).rvs(500), stats.cauchy(-4, 0.8).rvs(2000), stats.cauchy(-1, 0.3).rvs(500), stats.cauchy(2, 0.8).rvs(1000), stats.cauchy(4, 1.5).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: Hey, nice histogram! Step2: Problem 1b Step4: Problem 1d Step5: Problem 2a Step6: Problem 2b Step7: Problem 3c Step8: Problem 3d Step9: ...
6,249
<ASSISTANT_TASK:> Python Code: import urllib import json import time import pandas as pd import datetime from arctic import Arctic import arctic import subprocess import platform import os import krakenex if platform.system() == "Darwin": os.chdir('/users/'+os.getlogin()+'/MEGA/App') if platform.system() == "Darwin...
<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: The kraken API can be installed via pip Step3: Let's now run the functions to see what happens Step4: The function get_kraken_balance() return...
6,250
<ASSISTANT_TASK:> Python Code: import sys sys.path.insert(1, '..') import crowdastro.data import io import astropy.io.votable import requests import requests_cache requests_cache.install_cache(cache_name='gator_cache', backend='sqlite', expire_after=None) def fetch(subject): if subject['metadata']['source'].starts...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: How many objects are in SWIRE $\cap$ RGZ&ndash;ATLAS? Step2: So there are $56190$ galaxies in SWIRE $\cap$ RGZ&ndash;ATLAS. Let's also get that...
6,251
<ASSISTANT_TASK:> Python Code: from collections import defaultdict import numpy as np from mock import patch from grove.simon.simon import Simon, create_valid_2to1_bitmap mask = '110' bm = create_valid_2to1_bitmap(mask, random_seed=42) expected_map = { '000': '001', '001': '101', '010': '000', '011': '...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Simon's algorithm can be used to find the mask $m$ of a 2-to-1 periodic Boolean function defined by Step2: To understand what a 2-to-1 function...
6,252
<ASSISTANT_TASK:> Python Code: all_scores = pd.read_excel("Grades/Book1.xlsx") all_scores["Is A"] = all_scores["Final Score"] >= 90 # https://courses.cs.vt.edu/~cs1604/grading.html letter_grade = [] for grade in all_scores["Final Score"]: if grade >= 90: letter_grade.append("A") elif grade >= 80: ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Importing Clusters "Clustered_Sessions.csv" Step2: Clustered_Users Step3: Graphs Step4: Correlation and Regression - Scatter Plots Step5: S...
6,253
<ASSISTANT_TASK:> Python Code: # 这个项目设计来帮你熟悉 python list 和线性代数 # 你不能调用任何NumPy以及相关的科学计算库来完成作业 # 本项目要求矩阵统一使用二维列表表示,如下: A = [[1,2,3], [2,3,3], [1,2,5]] B = [[1,2,3,5], [2,3,3,5], [1,2,5,1]] # 向量也用二维列表表示 C = [[1], [2], [3]] #TODO 创建一个 4*4 单位矩阵 I = [[1,0,0,0], [0,1,0,0], [0,0,1,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: 1.2 返回矩阵的行数和列数 Step2: 1.3 每个元素四舍五入到特定小数数位 Step3: 1.4 计算矩阵的转置 Step4: 1.5 计算矩阵乘法 AB Step5: 2 Gaussign Jordan 消元法 Step6: 2.2 初等行变换 Step7: 2.3...
6,254
<ASSISTANT_TASK:> Python Code: from IPython.display import display from dividedDifferences import get_coeff, get_polynomial from sympy import init_printing from sympy import symbols, simplify from sympy import Eq, S, Function init_printing() # The values in the points we use for the extrapolation f0, f1, f2, f3 = symbo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Intro Step2: sorted after increasing value of the coordinate $x$. These points takes the following values Step3: Our goal is to use these four...
6,255
<ASSISTANT_TASK:> Python Code: url = "https://lists.wikimedia.org/pipermail/analytics/" arx = Archive(url,archive_dir="../archives") #threads = arx.get_threads() len(arx.get_threads()) y = [t.get_num_messages() for t in arx.get_threads()] plt.hist(y, bins=30) plt.xlabel('number of messages in a thread') plt.show() n...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We can count the number of threads in the archive easily. The first time you run Archive.get_thread it may take some time to compute, but the re...
6,256
<ASSISTANT_TASK:> Python Code: import pints import pints.toy as toy import numpy as np import matplotlib.pyplot as plt # Load a forward model model = toy.LogisticModel() # Create some toy data real_parameters = [0.015, 500] # growth rate, carrying capacity times = np.linspace(0, 1000, 100) org_values = model.simulate(...
<SYSTEM_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 1d histograms Step2: Plotting 2d histograms and a matrix of parameter distribution plots Step3: Matrix of parameter distribution plot...
6,257
<ASSISTANT_TASK:> Python Code: # Simple Function def greet(): '''Simple Greet Function''' print('Hello World') greet() # Function with arguments def greet(name): '''Simple Greet Function with arguments''' print('Hello ', name) greet('John') # printing the doc string print(greet.__doc__) # Fu...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Example 2 Step2: Example 3 Step3: Scope and Lifetime of Variables Step4: Variables defined outside the function are visible from inside which...
6,258
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import torch MyNet = torch.nn.Sequential(torch.nn.Linear(4, 15), torch.nn.Sigmoid(), torch.nn.Linear(15, 3), ) MyNet.load_state_dict(torch.load("my_model.pt")) input ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
6,259
<ASSISTANT_TASK:> Python Code: import numpy as np from numpy import * from bokeh import * from bokeh.plotting import * output_notebook() from matmodlab2 import * from pandas import read_excel from scipy.optimize import leastsq diff = lambda x: np.ediff1d(x, to_begin=0.) trace = lambda x, s='SIG': x[s+'11'] + x[s+'22'] ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Summary Step2: Hydrostatic Response Step3: It appears that the unloading occurs at data point 101 and continues until the end of the data. Th...
6,260
<ASSISTANT_TASK:> Python Code: from wikidataintegrator import wdi_core, wdi_login, wdi_helpers from wikidataintegrator.ref_handlers import update_retrieved_if_new_multiple_refs import pandas as pd from pandas import read_csv import requests from tqdm.notebook import trange, tqdm import ipywidgets import widgetsnbexten...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Retrieve and map WDIDs Step3: Query Wikidata for instances of drugs whose names match to product label names Step4: Merge tables to convert dr...
6,261
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'retina' import numpy as np import pandas as pd import matplotlib.pyplot as plt data_path = 'Bike-Sharing-Dataset/hour.csv' rides = pd.read_csv(data_path) rides.head() rides[:24*10].plot(x='dteday', y='cnt') dummy_fields = ['seas...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load and prepare the data Step2: Checking out the data Step3: Dummy variables Step4: Scaling target variables Step5: Splitting the data into...
6,262
<ASSISTANT_TASK:> Python Code: %matplotlib inline path = "data/dogscats/sample/" #path = "data/dogscats" from __future__ import division,print_function import os, json from glob import glob import numpy as np np.set_printoptions(precision=4, linewidth=100) from matplotlib import pyplot as plt from importlib import 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: Define path to data Step2: A few basic libraries that we'll need for the initial exercises Step3: We have created a file most imaginatively ca...
6,263
<ASSISTANT_TASK:> Python Code: from games import * from notebook import psource, pseudocode %psource Game %psource TicTacToe moves = dict(A=dict(a1='B', a2='C', a3='D'), B=dict(b1='B1', b2='B2', b3='B3'), C=dict(c1='C1', c2='C2', c3='C3'), D=dict(d1='D1', d2='D2', d...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: GAME REPRESENTATION Step2: Now let's get into details of all the methods in our Game class. You have to implement these methods when you create...
6,264
<ASSISTANT_TASK:> Python Code: #Normal inputs import pandas as pd import numpy as np import seaborn as sns import pylab as plt %matplotlib inline from IPython.display import Image, display #Make the notebook wider from IPython.core.display import display, HTML display(HTML("<style>.container { width:90% !important; }<...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Save CSV to disk (df.to_csv()) Step2: 2. Tidy data Step3: 2.2 What is tidy data? Step4: 2.3 Tidying messy datasets Step5: Data to study Step...
6,265
<ASSISTANT_TASK:> Python Code: df = pd.read_csv('../data/raw_running_data.csv') print(type(df)) df.head(10) ?pd.read_csv() df.dtypes df.columns df.index df['Date'].head() df = pd.read_csv('../data/raw_running_data.csv', parse_dates=['Date']) df.Date.head() df.set_index('Date', inplace=True) df.plot() ?df.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: You'll also notice that there are a TON of extra parameters that can be passed into this function, we can skip rows, specify dtypes, if there's ...
6,266
<ASSISTANT_TASK:> Python Code: # Imports import sys import pandas as pd import csv %matplotlib inline import matplotlib.pyplot as plt plt.rcParams['figure.figsize'] = (20.0, 10.0) # %load util.py #!/usr/bin/python # Util file to import in all of the notebooks to allow for easy code re-use # Calculate Percent of Attende...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Reading the Data Step2: Sanitizing the Data Step3: Analysis and Visualization (V1) Step4: Analysis and Visualization (V2) Step5: this is sti...
6,267
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', validation_size=0) img = mnist.train.images[2] plt.imshow(img.reshape((28, 28)), cmap='G...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Network Architecture Step2: Training Step3: Denoising Step4: Checking out the performance
6,268
<ASSISTANT_TASK:> Python Code: from nltk.book import * print(sent1) print(sent3) print(sent5) print(text6) print(text6.name) print("This text has %d words" % len(text6.tokens)) print("The first hundred words are:", " ".join( text6.tokens[:100] )) print(text5[0]) print(text3[0:11]) print(text4[0:51]) text6.concordan...
<SYSTEM_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 import statement reads the book samples, which include nine sentences and nine book-length texts. It has also helpfully put each of these t...
6,269
<ASSISTANT_TASK:> Python Code: def x_2z_over_dst(z): w = 2*pi # beta = 1, wn =w wd = w*sqrt(1-z*z) # Clough Penzien p. 43 A = z/sqrt(1-z*z) def f(t): return (cos(wd*t)+A*sin(wd*t))*exp(-z*w*t)-cos(w*t) return pl.vectorize(f) t = pl.linspace(0,20,1001) print(t) zetas = (.02, .05, .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: Above we compute some constants that depend on $\zeta$, Step2: We want to see what happens for different values of $\zeta$, so we create Step3:...
6,270
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt from math import log as ln from itertools import cycle # used to create a loopable colormap def get_Atom_prop(Atom,Prop): ''' This is a helper to get certain values from the tables You can't get the symbol...
<SYSTEM_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 defines the location of a file that holds all the atomic data we need. the files holds values fro the calculation of the sputter yield acco...
6,271
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pandas as pd import statsmodels.api as sm import matplotlib.pyplot as plt macrodata = sm.datasets.macrodata.load_pandas().data macrodata.index = pd.period_range('1959Q1', '2009Q3', freq='Q') endog = macrodata['infl'] endog.plot(figsize=(15, 5)...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Basic example Step2: Constructing and estimating the model Step3: Forecasting Step4: The get_forecast method is more general, and also allows...
6,272
<ASSISTANT_TASK:> Python Code: import numpy as np from pylab import * %matplotlib inline import os import sys #TODO: specify your caffe root folder here caffe_root = "X:\caffe_siggraph/caffe-windows-master" sys.path.insert(0, caffe_root+'/python') import caffe #TODO: change to your own network and deploying file PRET...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: caffe Step2: Now we can load up the network. You can change the path to your own network here. Make sure to use the matching deploy prototxt fi...
6,273
<ASSISTANT_TASK:> Python Code: #!pip install -I "phoebe>=2.4,<2.5" import phoebe import numpy as np b = phoebe.default_binary() b.set_value('q', value=0.7) b.set_value('incl', component='binary', value=87) b.set_value('requiv', component='primary', value=0.8) b.set_value('teff', component='secondary', value=6500) b.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 always, let's do imports and initialize a logger and a new bundle. Step2: Now we'll try to exaggerate the effect by spinning up the secondar...
6,274
<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, software ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Reformer Step2: Setting up data and model Step4: As we see above, "Crime and Punishment" has just over half a million tokens with the BPE voca...
6,275
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np np.random.seed(10) A = tf.constant(np.random.randint(low=0, high=5, size=(10, 20, 30))) B = tf.constant(np.random.randint(low=0, high=5, size=(10, 20, 30))) import numpy as np def g(A,B): return tf.constant(np.einsum( 'ikm, jkm-> ijk', 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:
6,276
<ASSISTANT_TASK:> Python Code: import datetime from functools import reduce import json import os import numpy as np import pandas as pd from planet import api import rasterio from sklearn.cluster import MiniBatchKMeans from sklearn.ensemble import RandomForestClassifier from utils import Timer import visual # Import 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: Download Scenes Step2: Download portions of OrthoTile strips that overlap AOI Step3: Get mosaic image names Step4: Classify Scenes Step5: Vi...
6,277
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas import matplotlib.pyplot as plt plt.rcParams['figure.figsize'] = (16.0, 8.0) df = pandas.read_csv('./stroopdata.csv') df.describe() df.hist() import math df['differences'] = df['Incongruent']-df['Congruent'] N =df['differences'].count() print "Sample siz...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Provide one or two visualizations that show the distribution of the sample data. Write one or two sentences noting what you observe about the pl...
6,278
<ASSISTANT_TASK:> Python Code: import medusa from medusa.test import create_test_ensemble ensemble = create_test_ensemble("Staphylococcus aureus") import pandas as pd biolog_base = pd.read_csv("../medusa/test/data/biolog_base_composition.csv", sep=",") biolog_base # convert the biolog base to a dictionary, which we 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: Let's simulate growth on two different carbon sources, D-glucose (metabolite id Step2: Now let's visualize the distributions of predicted flux ...
6,279
<ASSISTANT_TASK:> Python Code: #%qtconsole # For inspecting variables. # Standard import os from glob import glob # Unix style pathname pattern expansion. import csv import pickle import time # Scientific Computing and Visualization import numpy as np; np.random.seed(13) # Lucky seed. import matplotlib.pyplot as plt...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 0&nbsp;&nbsp;&nbsp;Load Data Step2: 1&nbsp;&nbsp;&nbsp;Dataset Summary, Exploration, and&nbsp;Balancing Step3: Exploratory Visualization Step4...
6,280
<ASSISTANT_TASK:> Python Code: # imports import numpy as np import matplotlib.pyplot as plt from landlab import RasterModelGrid, imshow_grid from landlab.components import TidalFlowCalculator # set up the grid grid = RasterModelGrid( (3, 101), xy_spacing=2.0 ) # only 1 row of core nodes, between 2 boundary rows gr...
<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: As we would expect, the numerical solution is slightly lower than the analytical solution, because our simplified analytical solution does not t...
6,281
<ASSISTANT_TASK:> Python Code: import logging import os.path logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) from gensim import corpora, models, similarities if (os.path.exists("/tmp/deerwester.dict")): dictionary = corpora.Dictionary.load('/tmp/deerwester.dict') cor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: if you want to see logging events. Step2: In this tutorial, I will show how to transform documents from one vector representation into another....
6,282
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd column_names = ['user_id', 'item_id', 'rating', 'timestamp'] df = pd.read_csv('u.data', sep='\t', names=column_names) df.head() movie_titles = pd.read_csv("Movie_Id_Titles") movie_titles.head() df = pd.merge(df,movie_titles,on='item_id') df.head(...
<SYSTEM_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 then read in the u.data file, which contains the full dataset. You can read a brief description of the dataset here. Step2: Let's take a...
6,283
<ASSISTANT_TASK:> Python Code: print "Hello World!" x=42 print x+10 print x/4 x="42" print x+10 print x+"10" x=[1, 2, 3] y=[4,5, 6] print x print x*2 print x+y print range(10) print range(20, 50, 3) print [] x=range(10) print x print "First value", x[0] print "Last value", x[-1] print "Fourth to sixth values", x[3:...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: There are, however, a few lines that you will usually see in a Python script. The first line often starts with #! and is called the shebang. For...
6,284
<ASSISTANT_TASK:> Python Code: import skrf import numpy as np import matplotlib.pyplot as mplt nw = skrf.network.Network('./190ghz_tx_measured.S2P') vf = skrf.VectorFitting(nw) vf.vector_fit(n_poles_real=4, n_poles_cmplx=4) vf.plot_convergence() vf.get_rms_error() # plot frequency responses fig, ax = mplt.subplots(...
<SYSTEM_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 example is a lot more tricky to fit, because the responses contain a few "bumps" and noise from the measurement. In such a case, finding a ...
6,285
<ASSISTANT_TASK:> Python Code: class Module(object): def __init__ (self): self.output = None self.gradInput = None self.training = True Basically, you can think of a module as of a something (black box) which can process `input` data and produce `ouput` data. This is like a...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step12: Module is an abstract class which defines fundamental methods necessary for a training a neural network. You do not need to change anything her...
6,286
<ASSISTANT_TASK:> Python Code: data_path = '../../SFPD_Incidents_-_from_1_January_2003.csv' data = pd.read_csv(data_path) mask = (data.Category == 'PROSTITUTION') & (data.Y != 90) filterByCat = data[mask] reducted = filterByCat[['PdDistrict','X','Y']] X = data.loc[mask][['X','Y']] centers = {} def knn(k): md = 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: Then we want to filter the data set. Step2: To reduce the amount of data we need to load on the page, we only extract the columns that we need....
6,287
<ASSISTANT_TASK:> Python Code: %matplotlib inline # Imports from Python packages. import matplotlib.pyplot as plt from matplotlib.ticker import FuncFormatter from scipy.stats import ttest_rel, ttest_ind import pandas as pd import numpy as np import os # Imports from FinanceOps. from data_keys import * from data 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: Load Data Step12: Mathematical Model Step14: Print Statistics Step16: Plotting Function Step17: Case Study Step18: The statistics above sho...
6,288
<ASSISTANT_TASK:> Python Code: %lsmagic %pwd %pwd? %%javascript IPython.toolbar.add_button_group([ { 'label':'renumber all code cells', 'icon':'icon-list-ol', 'callback':function() { var cells = IPython.notbook.get_cells(); cells = cells.filter(function(c) { return c 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: 現在のディレクトリを確認 Step2: コマンドの説明を確認するには?をつける
6,289
<ASSISTANT_TASK:> Python Code: %matplotlib inline from bigbang.archive import Archive from bigbang.archive import load as load_archive from bigbang.thread import Thread from bigbang.thread import Node from bigbang.utils import remove_quoted import matplotlib.pyplot as plt import datetime import csv from collections 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: First, collect data from a public email archive. Step2: Let's check the number of threads in this mailing list corpus Step3: We can plot the ...
6,290
<ASSISTANT_TASK:> Python Code: from nilmtk import DataSet iawe = DataSet('/data/iawe.h5') elec = iawe.buildings[1].elec elec fridge = elec['fridge'] fridge.available_columns() df = next(fridge.load()) df.head() series = next(fridge.power_series()) series.head() series = next(fridge.power_series(ac_type='reactive'))...
<SYSTEM_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 us see what measurements we have for the fridge Step2: Loading data Step3: Load a single column of power data Step4: or, to get reactive ...
6,291
<ASSISTANT_TASK:> Python Code: import requests r = requests.get("http://en.wikipedia.org/wiki/Main_Page") type(r.request), type(r.content), type(r.headers) from pprint import pprint pprint(r.content[0:1000]) r.request.headers r.headers r.content[:1000] r.text[:1000] from bs4 import BeautifulSoup page = Beautiful...
<SYSTEM_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 response object contains various information about the request you sent to the server, the resources returned, and information about the re...
6,292
<ASSISTANT_TASK:> Python Code: import pandas as pd from sklearn import linear_model import matplotlib.pyplot as plt # read data in pandas frame dataframe = pd.read_csv('datasets/house_dataset1.csv') # assign x and y x_feature = dataframe[['Size']] y_labels = dataframe[['Price']] # check data by printing first few rows ...
<SYSTEM_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 data Step2: Train model Step3: Predict output using trained model Step4: Plot results Step5: Do it yourself Step6: Predict labels usin...
6,293
<ASSISTANT_TASK:> Python Code: import matplotlib.pylab as plt import numpy as np import seaborn as sns; sns.set() %matplotlib inline import keras from keras.models import Sequential, Model from keras.layers import Dense from keras.optimizers import Adam import salty from numpy import array from numpy import argmax from...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: only N+ contain positive charges in this dataset Step2: We may want to remove cations with more than 25 heavy atoms Step3: so some keras versi...
6,294
<ASSISTANT_TASK:> Python Code: import os import sys import pytz import inspect import numpy as np import pandas as pd import datetime as dt import matplotlib.pyplot as plt import tmpo from opengrid import config from opengrid.library import plotting from opengrid.library import houseprint c=config.Config() %matplotlib ...
<SYSTEM_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 notebook shows step by step how water leaks of different severity can be detected Step2: The purpose is to automatically detect leaks, und...
6,295
<ASSISTANT_TASK:> Python Code: import torch import torch.nn as nn import torch.optim as optim import torchvision import numpy as np from matplotlib import pyplot as plt device = 'cuda' if torch.cuda.is_available() else 'cpu' print("We are using the following device for learning:",device) batch_size_train = 60000 ...
<SYSTEM_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 and load MNIST dataset (Preprocessing) Step2: Plot 8 random images Step3: Specify Autoencoder Step4: Helper function to get a random m...
6,296
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt # use seaborn's default plotting styles for matplotlib import seaborn; seaborn.set() from gatspy.datasets import fetch_rrlyrae rrlyrae = fetch_rrlyrae() lcid = rrlyrae.ids[0] t, y, dy, filts = rrlyrae.get_lightcurve(lci...
<SYSTEM_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 we'll fit the multiband periodogram model to this data. For more information on the model, refer to the VanderPlas and Ivezic paper mentione...
6,297
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import matplotlib as mpl mpl.rc("image", aspect="equal") import SimpleITK as sitk # Download data to work on %run update_path_to_download_script from downloaddata import fetch_data as fdata img = sitk.GaussianSource(size=[64] * 2) plt.im...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let us begin by developing a convenient method for displaying images in our notebooks. Step2: Multi-dimension slice indexing Step3: Cropping S...
6,298
<ASSISTANT_TASK:> Python Code: # First check the Python version import sys if sys.version_info < (3,4): print('You are running an older version of Python!\n\n' \ 'You should consider updating to Python 3.4.0 or ' \ 'higher as the libraries built for this course ' \ 'have only been test...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Session 1 - Introduction to Tensorflow Step2: Places your images in a folder such as dirname = '/Users/Someone/Desktop/ImagesFromTheInternet'. ...
6,299
<ASSISTANT_TASK:> Python Code: from google.cloud import bigquery from datetime import datetime import matplotlib.pyplot as plt, seaborn as sns PROJECT_ID = 'yourProject' # Change to your project. !gcloud config set project $PROJECT_ID try: from google.colab import auth auth.authenticate_user() print("Colab 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: Configure GCP environment settings Step2: Authenticate your GCP account Step3: Explore the sample data Step4: Count the number of songs that ...