Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
10,500
<ASSISTANT_TASK:> Python Code: import mne import os.path as op import numpy as np from matplotlib import pyplot as plt data_path = mne.datasets.sample.data_path() # Load a dataset that contains events raw = mne.io.read_raw_fif( op.join(data_path, 'MEG', 'sample', 'sample_audvis_raw.fif')) # If your raw object has ...
<SYSTEM_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: Now, we can create an Step3: Epochs behave similarly to Step4: You can select subsets of epochs by indexing the Step5: It is also...
10,501
<ASSISTANT_TASK:> Python Code: # Initial import statements %matplotlib inline import matplotlib.pyplot as plt import numpy as np from matplotlib.pyplot import * from numpy import * from numpy.linalg import * from scipy.linalg import lu_factor, lu_solve # Create a function which can be used later if needed def lu_decom...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Problem 3 Step2: Problem 6 Step3: Reliability Step4: If you want to invert matrices with small determinant, the solution is to ensure the tol...
10,502
<ASSISTANT_TASK:> Python Code: # Authors: Marijn van Vliet <w.m.vanvliet@gmail.com> # # License: BSD (3-clause) from matplotlib import pyplot as plt import mne from mne.datasets import sample data_path = sample.data_path() raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif' raw = mne.io.read_raw_fif(raw_fname)...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Setting up data paths and loading raw data (skip some data for speed) Step2: Since downsampling reduces the timing precision of events, we reco...
10,503
<ASSISTANT_TASK:> Python Code: ! pip uninstall -y kfp ! pip install kfp import kfp import json import os from kfp.onprem import use_k8s_secret from kfp import components from kfp.components import load_component_from_file, load_component_from_url from kfp import dsl from kfp import compiler import numpy as np import lo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Enter your gateway and the auth token Step2: Set the Log bucket and Tensorboard Image Step3: Set the client and create the experiment Step4: ...
10,504
<ASSISTANT_TASK:> Python Code: %%html <style> .example-container { background: #999999; padding: 2px; min-height: 100px; } .example-container.sm { min-height: 50px; } .example-box { background: #9999FF; width: 50px; height: 50px; text-align: center; vertical-align: middle; color: white; font-weight: bold; margin: 2px;}...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Widget Styling Step2: Parent/child relationships Step3: After the parent is displayed Step4: Fancy boxes Step5: TabWidget Step6: Alignment ...
10,505
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division %matplotlib inline import numpy as np import random import thinkstats2 import thinkplot class HypothesisTest(object): def __init__(self, data): self.data = data self.MakeModel() self.actual = self.TestStatistic(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: Hypothesis testing Step2: And here's an example that uses it to compute the p-value of an experiment where we toss a coin 250 times and get 140...
10,506
<ASSISTANT_TASK:> Python Code: from __future__ import division import pandas as pd from pandas import read_csv from pandas import datetime from matplotlib import pyplot as plt from pandas.plotting import autocorrelation_plot from statsmodels.tsa.arima_model import ARIMA from pandas import DataFrame from sklearn.metrics...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: p Step2: Train - Test
10,507
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 訓練後の整数量子化 Step2: MNIST モデルをビルドする Step3: TensorFlow Lite モデルに変換する Step4: TensorFlow Lite モデルになってはいますが、すべてのパラメータデータには 32 ビット浮動小数点値が使用されています。 St...
10,508
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pickle as pkl 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') def model_inputs(real_dim, z_dim): inputs_real = tf.placeholde...
<SYSTEM_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 Inputs Step2: Generator network Step3: Discriminator Step4: Hyperparameters Step5: Build network Step6: Discriminator and Generator L...
10,509
<ASSISTANT_TASK:> Python Code: %run db2odata.ipynb %run db2.ipynb %sql connect reset %sql connect %sql -sampledata %sql SELECT * FROM EMPLOYEE %odata register %odata RESET TABLE EMPLOYEE s = %odata -e SELECT lastname, salary from employee where salary > 50000 s = %odata -e SELECT * FROM EMPLOYEE %odata 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: Db2 Extensions Step2: <a id='top'></a> Step3: If you connected to the SAMPLE database, you will have the EMPLOYEE and DEPARTMENT tables availa...
10,510
<ASSISTANT_TASK:> Python Code: import seaborn as sns %matplotlib inline tips = sns.load_dataset('tips') tips.head(5) #find dist of total bills sns.distplot(tips['total_bill']) tips.total_bill.mean() tips_mean = tips.total_bill.mean() tips_sd = tips.total_bill.std() ax = sns.distplot(tips['total_bill']) # plot mean 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: Load sample dataset Step2: Distribution plots Step3: It is often useful to overlay the mean and SD with the histograms, below is one way to do...
10,511
<ASSISTANT_TASK:> Python Code: print(type(())) help(()) !python -m timeit "x = (1, 'a', 'b', 'a')" a = (1, 'a', 'b', 'a') a.count('a') a.index('b') a a[2] # The 3-rd item a[2:1] # Extract the tuple from the 2-nd item to the 1-st one a[2:2] # Extract from the 2-nd item to the 2-nd item a[2:3] # Extract from the 2-nd...
<SYSTEM_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. Tuple definition Step2: 1.3. Counting ocurrences in tuples Step3: 1.4. Searching for an item in a tuple Step4: 1.5. Slicing in tuples St...
10,512
<ASSISTANT_TASK:> Python Code: import SimpleITK as sitk # Utility method that either downloads data from the Girder repository or # if already downloaded returns the file name for reading from disk (cached data). %run update_path_to_download_script from downloaddata import fetch_data as fdata # Always write output to 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: Utility functions Step2: Read images Step3: Initial Alignment Step4: Registration Step5: Post registration analysis Step6: Now visually ins...
10,513
<ASSISTANT_TASK:> Python Code: # Greater than ( > ) if 1 > 0: print("One is more than zero") else: print("BITS Pilani Goa Campus is better than IIT Kanpur") # Less than ( < ) if 12 < 42: print("Yes, 12 is less than 42") else: print("Everyone registered in CTE Python will pass with distinction (90%+...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Chained Conditional Step2: The condition need not directly involve a logical operator. For example Step3: Iterations Step4: enumerate Step5:...
10,514
<ASSISTANT_TASK:> Python Code: shps = !ls /home/user/data/north_carolina/shape/*shp td = {} for shp in shps: with fiona.open( shp, 'r') as inp: td[ inp.name ] = inp.bounds ## Fiona inp.bounds => ( lower_lng, lower_lat, upper_lng, upper_lat) ## Create shapely geometry from the coords ## shapely/geometry/geo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Task
10,515
<ASSISTANT_TASK:> Python Code: import numpy as np np.random.seed(20) runningtimes=0 while (runningtimes <=10): x = np.random.randn(5) print(x) print('**') runningtimes=runningtimes+1 import numpy as np runningtimes=0 while (runningtimes <=10): np.random.seed(5) x = np.random.randn(5) print(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: Under stand how path is joined Step2: numpy.c_ function
10,516
<ASSISTANT_TASK:> Python Code: # imports import matplotlib.pyplot as plt import numpy as np from skbeam.core.image import construct_rphi_avg_image %matplotlib inline # first generate some random scattering pattern # There are missing regions from skbeam.core.utils import angle_grid, radial_grid shape = 800,800 x0,y0 =...
<SYSTEM_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 generate the image Step2: 2. Next re-partition image into a polar grid Step3: Now regenerate the image to test construct_rphi_image S...
10,517
<ASSISTANT_TASK:> Python Code: __copyright__ = "Reiner Lemoine Institut, Zentrum für nachhaltige Energiesysteme Flensburg" __license__ = "GNU Affero General Public License Version 3 (AGPL-3.0)" __url__ = "https://github.com/openego/data_processing/blob/master/LICENSE" __author__ = "wolfbunke, Ludee" 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: Tutorial - How to work with the OpenEnergy Platform (OEP) Step2: 0.1 About the Database and used Packages Step3: 1. Create a table / Table Arc...
10,518
<ASSISTANT_TASK:> Python Code: from __future__ import print_function l1 = list() l2 = [] print(l1) print(l2) print(len(l1)) print(len(l2)) l3 = [1, 2, 3] print(l3) print(len(l3)) l1.append(1) print(l1) l1.append(10) print(l1) l2.append(100) print(l2) print(l1) print(l2) print(l1 + l2) l1.extend(l2) print(l1) print...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The length of a list is acquired by the len functino Step2: Lists can be initialised if its values are known at run time Step3: Appending and ...
10,519
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ipsl', 'sandbox-1', 'aerosol') # 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: 1...
10,520
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import tensorflow as tf import tflearn from tflearn.data_utils import to_categorical reviews = pd.read_csv('reviews.txt', header=None) labels = pd.read_csv('labels.txt', header=None) reviews.head() from collections import Counter #Create the counte...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Preparing the data Step2: Counting word frequency Step3: Let's keep the first 10000 most frequent words. As Andrew noted, most of the words in...
10,521
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import pandas as pd import numpy as np from matplotlib import rc rc('text', usetex=True) !head -n 5 likelihoodvariancetest.txt multi = np.loadtxt('likelihoodvariancetest.txt') multi1000 = np.loadtxt('likelihoodvariancetest1000samples.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: And here we have the standard deviations Step2: If we maintain our key assumption from the Quantifying Scaling Accuracy notebook, that the sing...
10,522
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np file_name_string = 'C:/Users/Charles Kelly/Desktop/Exercise Files/02_07/Begin/EmployeesWithGrades.xlsx' employees_df = pd.read_excel(file_name_string, 'Sheet1', index_col=None, na_values=['NA']) employees_df["Grade"] = employees_df["Grade"].astype("...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Change data type Step2: Rename the categories Step3: Values in data frame have not changed
10,523
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import pysra %matplotlib inline # Increased figure sizes plt.rcParams["figure.dpi"] = 120 m = pysra.motion.SourceTheoryRvtMotion(6.0, 30, "wna") m.calc_fourier_amps() profile = pysra.site.Profile( [ pysra.site.Layer( ...
<SYSTEM_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 a point source theory RVT motion Step2: Create site profile Step3: Create the site response calculator Step4: Initialize the variation...
10,524
<ASSISTANT_TASK:> Python Code: %matplotlib inline from keras.datasets import mnist from keras.models import Sequential from keras.layers import Dense from keras.utils import to_categorical import numpy as np import matplotlib.pyplot as plt # Load data (X_train, y_train), (X_test, y_test) = mnist.load_data() print(X_tra...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: For those of you unfamiliar with the MNIST dataset, it is a set of 70000, 28x28 pixel images depicting handwritten digits from 0-9. It is a comm...
10,525
<ASSISTANT_TASK:> Python Code: def list_of_chars(list_chars): # TODO: Implement me if li return list_chars[::-1] # %load test_reverse_string.py from nose.tools import assert_equal class TestReverse(object): def test_reverse(self): assert_equal(list_of_chars(None), None) assert_equa...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Unit Test
10,526
<ASSISTANT_TASK:> Python Code: import soundfile as sf sig, fs = sf.read('data/singing.wav') %matplotlib inline import matplotlib.pyplot as plt import numpy as np t = np.arange(len(sig)) / fs plt.plot(t, sig) plt.xlabel('time / seconds') plt.grid() plt.specgram(sig, Fs=fs) plt.ylabel('frequency / Hz') plt.xlabel('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: Plotting Step2: Spectrogram Step3: Symbolic Math
10,527
<ASSISTANT_TASK:> Python Code: import torchaudio import torchvision import torch import matplotlib.pyplot as plt from IPython.display import Audio img = torchvision.io.read_image("data/birdie2.jpg") img = torchvision.transforms.ToPILImage()(img) display(img) img = torchvision.io.read_image("data/birdie2.jpg") normali...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: torchvision for loading input images Step2: Visualize the transforms done before model prediction Step3: plot_waveform function from torchaudi...
10,528
<ASSISTANT_TASK:> Python Code: # data_id = "7d" from fretbursts import * init_notebook() from IPython.display import display data_dir = './data/singlespot/' import os data_dir = os.path.abspath(data_dir) + '/' assert os.path.exists(data_dir), "Path '%s' does not exist." % data_dir from glob import glob file_list = 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: Load software and filenames definitions Step2: Data folder Step3: List of data files Step4: Data load Step5: Load the leakage coefficient fr...
10,529
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import load_iris from sklearn.cross_validation import train_test_split # Let's load the iris dataset iris = load_iris() X, y = iris.data, iris.target # split data into training and test sets using the handy train_test_split func # in this split, we are "holding out" ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: QUESTIONS Step2: From Decision Tree to Random Forest
10,530
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'hadgem3-gc31-lm', '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...
10,531
<ASSISTANT_TASK:> Python Code: import sys import os import re import collections import itertools import bcolz import pickle sys.path.append('../lib') import gc import random import smart_open import h5py import csv import tensorflow as tf import gensim import datetime as dt from tqdm import tqdm_notebook as tqdm 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: Data Step2: load data Step3: Word Vectors Pre Trained Step4: dont need word to id dict since this is indexed with words Step5: for tensorboa...
10,532
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # Eric Larson <larson.eric.d@gmail.com> # License: BSD (3-clause) import os.path as op import numpy as np from numpy.random import randn from scipy import stats as stats import mne from mne import (io, spatia...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set parameters Step2: Read epochs for all channels, removing a bad one Step3: Transform to source space Step4: Transform to common cortical s...
10,533
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy as sp import matplotlib.pyplot as plt import sympy as sym from scipy.integrate import odeint import scipy.linalg as spla from scipy import optimize, interpolate from scipy.linalg import solve_triangular, toeplitz, lu from scipy.optimize import root # pip 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: <div id='intro' /> Step2: b) Indexing (view) Step3: c) Indexing (copy) Step4: d) Vectorization (THE HEART OF THE HEART OF NUMERICAL COMPUTING...
10,534
<ASSISTANT_TASK:> Python Code: import numpy as np import sys import json import csv import pandas as pd import re import matplotlib.pyplot as plt import seaborn as sns csv.field_size_limit(sys.maxsize) def scores(path): id_to_scores = {} d = json.load( open( path, 'r')) # id --> score ...
<SYSTEM_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 image-sentence scores from the a json file Step2: Read a model's scores on each sentence-image pair Step3: SVO-Probes Step4: Comp...
10,535
<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...
10,536
<ASSISTANT_TASK:> Python Code: # Load libraries from sklearn import preprocessing import numpy as np # Create feature x = np.array([[-500.5], [-100.1], [0], [100.1], [900.9]]) # Create scaler scaler = preprocessing.StandardScaler() # Transform the feature st...
<SYSTEM_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 Feature Step2: Standardize Feature
10,537
<ASSISTANT_TASK:> Python Code: n_mock= 100000 sigma_true= 0.1 totmass_true= 0.25 z_mock, vz_mock, m_mock= wendym2m.sample_sech2(sigma_true,totmass_true,n=n_mock) _= bovy_plot.bovy_hist(numpy.fabs(z_mock),bins=31,normed=True, xlabel=r'$z$',ylabel=r'$\nu(z)$',lw=2.,histtype='step') gca().set_yscal...
<SYSTEM_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 density looks like a $\mathrm{sech}^2$ disk (cored near the center, exponential at large distances) Step2: Now we 'observe' this density di...
10,538
<ASSISTANT_TASK:> Python Code: cd .. from indra2.agent import Agent def newt_action(agent): print("I'm " + agent.name + " and I'm inventing modern mechanics!") newton = Agent("Newton", attrs={"place": 0.0, "time": 1658.0, "achieve": 43.9}, action=newt_action, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Agent class constructor accepts 5 parameters Step2: Now we will explore all the magic methods of agent class. Step3: str returns name of the a...
10,539
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nasa-giss', 'sandbox-2', 'ocean') # 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...
10,540
<ASSISTANT_TASK:> Python Code: 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.disaggregate import CombinatorialOptimisation train = Da...
<SYSTEM_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...
10,541
<ASSISTANT_TASK:> Python Code: import google.datalab.bigquery as bq import pandas as pd import matplotlib.pyplot as plt import numpy as np import scipy as sp from sklearn.linear_model import LinearRegression from sklearn.preprocessing import LabelEncoder from sklearn.preprocessing import OneHotEncoder from sklearn 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: SAM (System for Award Management) - exclusions Step2: There are 8,659 firms on the SAM exclusion list Step3: NPI and CAGE don't seem to be gre...
10,542
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np from math import radians, cos, sin, asin, sqrt import itertools from sklearn import neighbors from sklearn import preprocessing from sklearn import ensemble from sklearn.model_selection import LeaveOneGroupOut, LeavePGroupsOut import inversion 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 training data Step2: Build features Step3: Because solving the sum of squares equation involved the quadratic formula, in some cases imag...
10,543
<ASSISTANT_TASK:> Python Code: # type your help commands in the box and # execute the code in the box by typing shift-enter # (hold down the shift key while hitting the enter/return key) # The interpreter can be used as a calculator, and can also echo or concatenate strings. 3 + 3 3 * 3 3 ** 3 3 / 2 # classic divisi...
<SYSTEM_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 Basics Step2: Try It Yourself Step3: Variables can be reassigned Step4: The ability to reassign variable values becomes important when it...
10,544
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np def well2d(x, y, nx, ny, L=1.0): Compute the 2d quantum well wave function. # YOUR CODE HERE #raise NotImplementedError() Psi = (2/L)*np.sin((nx*np.pi*x)/L)*np.sin((ny*np.pi*y)/L) return Psi psi = w...
<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: Contour plots of 2d wavefunctions Step3: The contour, contourf, pcolor and pcolormesh functions of Matplotlib can be used for effective visuali...
10,545
<ASSISTANT_TASK:> Python Code: import salty smiles = salty.check_name("1-butyl-3-methylimidazolium") print(smiles) %matplotlib inline from rdkit import Chem from rdkit.Chem import Draw fig = Draw.MolToMPL(Chem.MolFromSmiles(smiles),figsize=(5,5)) ms = [Chem.MolFromSmiles("OC(=O)C(N)Cc1ccc(O)cc1"), Chem.MolFromSmiles(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: once we have a smiles representation of a molecule, we can convert it into a molecular object with RDKit Step2: Once we have a molecular object...
10,546
<ASSISTANT_TASK:> Python Code: class Heap: sNodeCount = 0 def __init__(self): Heap.sNodeCount += 1 self.mID = str(Heap.sNodeCount) def getID(self): return self.mID # used only by graphviz def _make_string(self, attributes): # get the name of the class of the 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: The function make_string is a helper function that is used to simplify the implementation of the method __str__. Step2: Graphical Representatio...
10,547
<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 ...
10,548
<ASSISTANT_TASK:> Python Code: X = X[X['lon'] < -122] X.plot(kind='scatter', x='lon', y='lat') from sklearn.cluster import KMeans #To work with out cluster we have to turn our panda dataframe into a numpy array, np_X = np.array(X) kmeans = KMeans(n_clusters=2) kmeans.fit(np_X) centroid = kmeans.cluster_centers_ labels...
<SYSTEM_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 points now all seem to be within SF borders Step3: I will now look at the total squared error in relation to the number of clusters, to fin...
10,549
<ASSISTANT_TASK:> Python Code: cd assignment/calibration_images/ cdata = CalibrationData() cdata.config() cdata.create_h5() import json print json.dumps(cdata.h5dict, indent=4) #Json used to print cdata.h5dict neatly arr = cdata.get_dset(camera=0, z_loc=-6) #Note: It returns a numpy array, not a h5py dataset! 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: The object cdata now manages all the calibration images. The images are converted to arrays into a file called calibration.h5. A HDF5 file can b...
10,550
<ASSISTANT_TASK:> Python Code: os.getcwd() import os import re import sys import vcf import time import pysam import myvariant import collections import numpy as np import pandas as pd sys.path.append(os.getcwd().replace("notebooks/dnaSeq/VAPr_Variant_Annotation_Prioritization", "src/dnaSeq/VAPr")) #variantannotation 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: <a id = "ANNOVAR"></a> Step2: Specify the name and location of the csv file that ANNOVAR produces as output Step3: <a id = "myvariant"></a> St...
10,551
<ASSISTANT_TASK:> Python Code: import pandas as pd %matplotlib inline import matplotlib.pyplot as plt # package for doing plotting (necessary for adding the line) import statsmodels.formula.api as smf # package we'll be using for linear regression import numpy as np import scipy as sp df = pd.read_csv("data/hanford.cs...
<SYSTEM_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. Read in the hanford.csv file Step2: 3. Calculate the basic descriptive statistics on the data Step3: 4. Calculate the coefficient of correl...
10,552
<ASSISTANT_TASK:> Python Code: # modules we'll use import pandas as pd import numpy as np # read in all our data nfl_data = pd.read_csv("../input/nflplaybyplay2009to2016/NFL Play by Play 2009-2017 (v4).csv") # set seed for reproducibility np.random.seed(0) # look at the first five rows of the nfl_data file. # I can ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The first thing to do when you get a new dataset is take a look at some of it. This lets you see that it all read in correctly and gives an idea...
10,553
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import seaborn as sns D = np.linspace(0.0, 15., 500) x = np.arange(500) plt.figure(figsize=(8,2)) plt.fill_between(x, D, 0) plt.xlabel('x position [a.u.]') plt.ylabel('D [a.u.]'); np.random.seed(12337) # reproducable 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: Trajectory simulation Step2: If we plot this simulated trajectory, we see how the distance between two subsequent positions of the particle is ...
10,554
<ASSISTANT_TASK:> Python Code: from __future__ import print_function # For the python2 people import pandas as pd # This is typically how pandas is loaded airlines = pd.read_table("airlines.txt") airports = pd.read_table("airports.txt") flights = pd.read_table("flights.txt") planes = pd.read_table("planes.txt") weathe...
<SYSTEM_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 data from a file Step2: Inspecting a dataframe // What's in the flights dataset? Step3: Series Step4: DataFrame Indexing Step5: Data...
10,555
<ASSISTANT_TASK:> Python Code: import pandas import numpy from folding_group import FoldingGroupClassifier from rep.data import LabeledDataStorage from rep.report import ClassificationReport from rep.report.metrics import RocAuc from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import roc_curve, ...
<SYSTEM_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 initial data Step2: Remove rows with NAN from data Step3: Add diff_pt and cos(diff_phi) Step4: Add max, sum among PIDs Step5: define...
10,556
<ASSISTANT_TASK:> Python Code: # the output of plotting commands is displayed inline within frontends, # directly below the code cell that produced it %matplotlib inline from time import time # this python library provides generic shallow (copy) and deep copy (deepcopy) operations from copy import deepcopy # 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: Twiss parameters with and without coupler kick Step2: Trajectories with Coupler Kick
10,557
<ASSISTANT_TASK:> Python Code: %matplotlib inline from numpy.random import choice from scipy.stats import beta class DirichletProcessSample(): def __init__(self, base_measure, alpha): self.base_measure = base_measure self.alpha = alpha self.cache = [] self.weights = [] ...
<SYSTEM_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 we saw earlier the Dirichlet process describes the distribution of a random probability distribution. The Dirichlet process takes two paramet...
10,558
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.DataFrame({'A': [0, 1, 1, 1, 0, 1], 'B': [1, 0, 1, 1, 1, 0], 'C': [1, 1, 0, 1, 1, 1], 'D': [1, 1, 1, 0, 1, 1]}) df["category"] = df.idxmin(axis=1) <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:
10,559
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy x = numpy.linspace(0, 1) y1 = numpy.sin(numpy.pi * x) + 0.1 * numpy.random.rand(50) y2 = numpy.cos(3.0 * numpy.pi * x) + 0.2 * numpy.random.rand(50) from matplotlib import pyplot pyplot.plot(x, y1) pyplot.show() pyplot.plot(x, y1) pyplot.xlabel('x') pypl...
<SYSTEM_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 above command is only needed if you are plotting in a Jupyter notebook. Step2: And then produce a line plot Step3: We can add labels and t...
10,560
<ASSISTANT_TASK:> Python Code: import os from google.cloud import bigquery import pandas as pd %load_ext google.cloud.bigquery PROJECT = "qwiklabs-gcp-03-3247cf88ddb1" #"cloud-training-demos" # Replace with your PROJECT BUCKET = PROJECT # defaults to PROJECT REGION = "us-central1" # Replace with your REGION os.envi...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Replace the variable values in the cell below Step2: Create a Dataset from BigQuery Step3: Let's do some regular expression parsing in BigQuer...
10,561
<ASSISTANT_TASK:> Python Code: import os import mdtraj import mdtraj.reporters from simtk import unit import simtk.openmm as mm from simtk.openmm import app pdb = mdtraj.load('data/native.pdb') topology = pdb.topology.to_openmm() forcefield = app.ForceField('amber99sbildn.xml', 'amber99_obc.xml') system = forcefield...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: And a few things from OpenMM Step2: First, let's find a PDB for alanine dipeptide, the system we'll Step3: Lets use the amber99sb-ildn forcefi...
10,562
<ASSISTANT_TASK:> Python Code: def boston_housing(data_set='boston_housing'): if not data_available(data_set): download_data(data_set) all_data = np.genfromtxt(os.path.join(data_path, data_set, 'housing.data')) X = all_data[:, 0:13] Y = all_data[:, 13:14] return data_details_return({'X' : 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: Step 1 Step1: The function name allows users to call data = GPy.util.datasets.boston_housing() to acquire the data. You should use a name that makes it...
10,563
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 from enlib import enmap,wcs as mwcs import numpy as np import sys,os res = 1.0 shape, wcs = enmap.fullsky_geometry(res=res*np.pi/180./60., proj="car") shape = (3,)+shape ny, nx = shape[-2:] vy,vx = enmap.pix2sky(shape, wcs, [np.arange(ny),np.zeros(ny)]...
<SYSTEM_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 make a full-sky arcminute resolution geometry. I've only been able to reproduce this bug for res=1.0. Step2: We do a pix2sky that is needed ...
10,564
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt import plotnine as p9 import seaborn as sns titanic = pd.read_csv("data/titanic.csv") with plt.style.context('seaborn-whitegrid'): # context manager for styling the figure fig, ax = plt.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: When should I use Seaborn versus Matplotlib? Step2: Pandas/Matplotlib plot... Step3: Using Seaborn Step4: An important difference is the impe...
10,565
<ASSISTANT_TASK:> Python Code: import extractVariables as ev def collect_variables(expr): return frozenset(var for var in ev.extractVars(expr) if var not in dir(__builtins__) if var not in ['and', 'or', 'not'] ) def arb(S): for x in 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: The function collect_variables(expr) takes a string expr that can be interpreted as a Python expression as input and collects all variables occu...
10,566
<ASSISTANT_TASK:> Python Code: from __future__ import print_function from sklearn import __version__ as sklearn_version print('Sklearn version:', sklearn_version) from sklearn import datasets iris = datasets.load_iris() print(iris.DESCR) # Print some data lines print(iris.data[:10]) print(iris.target) #Randomize and 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: Load data Step2: Linear model Step3: Decision tree Step4: Test another clasifier Step5: ROC area
10,567
<ASSISTANT_TASK:> Python Code:: from sklearn.metrics import classification_report, log_loss, roc_auc_score print('Classification Report:',classification_report(y_test, y_pred)) print('Log Loss:',log_loss(y_test, y_pred)) print('ROC AUC:',roc_auc_score(y_test, y_pred)) <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:
10,568
<ASSISTANT_TASK:> Python Code: # First disable the log so the output is neater import logging, sys logging.disable(sys.maxsize) from findatapy.market import Market, MarketDataRequest # In this case we are saving predefined tick tickers to disk, and then reading back from findatapy.market.ioengine import IOEngine md_req...
<SYSTEM_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 print the output... Step2: Let's type in our S3 bucket address, which you'll need to change below. Note the use of s3 Step3: We can writ...
10,569
<ASSISTANT_TASK:> Python Code: import numpy as np example_array = np.ones((2, 3)) print(example_array) my_zeros_array = # your code goes here my_random_array = # your code goes here print(my_zeros_array) print(my_random_array) atom1_xyz = [5, 2, 8] atom2_xyz = [8, 4, 6] atom1_xyz_np = # your code goes here atom2_xyz...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Creation of numpy arrays Step2: Create an array filled with zeros and one filled with random numberers in the interval [0,1), each with a shape...
10,570
<ASSISTANT_TASK:> Python Code: # RUN THIS CELL import torch import torch.nn as nn from sklearn.preprocessing import MinMaxScaler import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline from pandas.plotting import register_matplotlib_converters register_matplotlib_converters() df = pd.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: Prepare the data Step2: 2. Normalize the training set Step3: 3. Prepare data for LSTM Step4: 4. Define the model Step5: 5. Define loss and o...
10,571
<ASSISTANT_TASK:> Python Code: %sql postgresql://localhost/inchi_split \ select count(*) from zinc_clean_nonstandard; d = %sql \ select formula,count(zinc_id) freq from zinc_clean_nonstandard group by formula \ order by freq desc limit 10; d d = %sql \ select formula,skeleton,hydrogens,count(zinc_id) ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Big caveat here Step2: grouping on the main layer Step3: Look at a few of the common main layer groups Step4: Charges Step5: Stereo grouping...
10,572
<ASSISTANT_TASK:> Python Code: # These are all the modules we'll be using later. Make sure you can import them # before proceeding further. from __future__ import print_function import numpy as np import tensorflow as tf from six.moves import cPickle as pickle import math pickle_file = 'notMNIST.pickle' with open(pick...
<SYSTEM_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 reload the data we generated in notmist.ipynb. Step2: Reformat into a shape that's more adapted to the models we're going to train Step3:...
10,573
<ASSISTANT_TASK:> Python Code: import sys sys.path.append("/home/moser/MG_2016/pyMG/") import scipy as sp import numpy as np import matplotlib.pyplot as plt %matplotlib inline import pymg from project.helmholtz1d import Helmholtz1D from project.helmholtz1d_periodic import Helmholtz1D_Periodic from project.gauss_seidel ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Plotten Sie mithilfe von matrix_plot die Systemmatrizen für $\sigma = 0$ und $n=10$. Step2: Aufgabe Step3: Frage Step4: Frage Step5: Frage ...
10,574
<ASSISTANT_TASK:> Python Code: import pandas from time import time import cobra.test from cobra.flux_analysis import \ single_gene_deletion, single_reaction_deletion, \ double_gene_deletion, double_reaction_deletion cobra_model = cobra.test.create_test_model("textbook") ecoli_model = cobra.test.create_test_mode...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Single Deletions Step2: These can also be done for only a subset of genes Step3: This can also be done for reactions Step4: Double Deletions ...
10,575
<ASSISTANT_TASK:> Python Code: import time import numpy as np import tensorflow as tf import utils from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import zipfile dataset_folder_path = 'data' dataset_filename = 'text8.zip' dataset_name = 'Text8 Dataset' class DLProgress(tq...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load the text8 dataset, a file of cleaned up Wikipedia articles from Matt Mahoney. The next cell will download the data set to the data folder. ...
10,576
<ASSISTANT_TASK:> Python Code: path = 'Sessions_Page.json' path2 = 'Goal1CompletionLocation_Goal1Completions.json' with open(path, 'r') as f: sessions_page = json.loads(f.read()) with open(path2, 'r') as f: goals_page = json.loads(f.read()) type (sessions_page) sessions_page.keys() sessions_page['reports'][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: Создаем в датафреймах отдельные с...
10,577
<ASSISTANT_TASK:> Python Code: import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True, reshape=False) DO NOT MODIFY THIS CELL def fully_connected(prev_layer, num_units): Create a fully connectd layer with the given layer...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: Batch Normalization using tf.layers.batch_normalization<a id="example_1"></a> Step6: We'll use the following function to create convolutional l...
10,578
<ASSISTANT_TASK:> Python Code: import requests response = requests.get('https://api.spotify.com/v1/search?query=lil&type=artist&market=US&limit=50') data = response.json() data.keys() artist_data = data['artists'] artist_data.keys() lil_names = artist_data['items'] #lil_names = list of dictionaries = list of artist na...
<SYSTEM_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 multiple parameters Step2: 2) What genres are most represented in the search results? Step3: ANSWER Step4: 3) Use a for loop to determi...
10,579
<ASSISTANT_TASK:> Python Code: import graphlab sales = graphlab.SFrame('kc_house_data.gl/kc_house_data.gl') train_data,test_data = sales.random_split(.8,seed=0) example_features = ['sqft_living', 'bedrooms', 'bathrooms'] example_model = graphlab.linear_regression.create(train_data, target = 'price', features = examp...
<SYSTEM_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: Split data into training and testing. Step3: Learning a multiple regression model Step4: Now that we have fit...
10,580
<ASSISTANT_TASK:> Python Code: import os class Params: pass # Set to run on GCP Params.GCP_PROJECT_ID = 'ksalama-gcp-playground' Params.REGION = 'europe-west1' Params.BUCKET = 'ksalama-gcs-cloudml' Params.PLATFORM = 'local' # local | GCP Params.DATA_DIR = 'data/news' if Params.PLATFORM == 'local' else 'gs://{}/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: Create a ML Data Files using Dataflow Step2: 2. Beam Pipeline Step3: 5. Run Pipeline Step4: TF Text Classification Model with TF Hub for Text...
10,581
<ASSISTANT_TASK:> Python Code: from IPython.core.display import Image Image("http://upload.wikimedia.org/wikipedia/commons/thumb/2/28/IEC60825_MPE_W_s.png/640px-IEC60825_MPE_W_s.png") #### # Parámetros a modificar. INICIO #### web_laser = 'http://www.punterolaser.com' # Incluir la dirección de la página web web_anchur...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Tarea 1 (a). Irradiancia máxima Step2: Tarea 3. Elección del filtro interferencial Step3: Tarea 3 (b). Verificación del filtro
10,582
<ASSISTANT_TASK:> Python Code: %cd C:/temp/ import pandas as pd train = pd.read_csv("labeledTrainData.tsv", header=0, delimiter="\t", quoting=3) print(train.columns.values) print(train.shape) print train["review"][0] from bs4 import BeautifulSoup example1 = BeautifulSoup(train["review"][0]) print(example1.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: "header=0" indicates that the first line of the file contains column names, "delimiter=\t" indicates that the fields are separated by tabs, and ...
10,583
<ASSISTANT_TASK:> Python Code: # imports import pandas as pd import matplotlib.pyplot as plt %matplotlib inline # read data into a DataFrame data = pd.read_csv('http://www-bcf.usc.edu/~gareth/ISL/Advertising.csv', index_col=0) data.head() # print the size of the DataFrame object, i.e., the size of the dataset data.sha...
<SYSTEM_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 features? Step2: There are 200 observations, corresponding to 200 markets. Step3: Questions Step4: Interpreting Model Coefficients Step5:...
10,584
<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...
10,585
<ASSISTANT_TASK:> Python Code: %matplotlib inline %load_ext autoreload %autoreload 2 from __future__ import division import numpy as np import matplotlib.pyplot as plt fs = 8000.0 f0 = 220.0 # Hz duration = 0.05 # 1.0 t = np.linspace(0, duration, num=fs*duration) N_overtones = 7 harmonics = np.arange(1, N_overtones) 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: You can listen to them here Step2: One GrFNN to rule them all Step3: THE PREVIOUS CODE GENERATED THE FIGURES ADDED TO THE PAPER ON APRIL 28 NE...
10,586
<ASSISTANT_TASK:> Python Code: import os from picamera import PiCamera from picamera.color import Color from time import sleep camera = PiCamera() # import a bunch of stuff that we'll use to manipulate our images... import pandas as pd from skimage.io import imread from skimage import filters from skimage.segmentation ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: TADA ... wait, nothing happened. Step2: How about some text on the image. Step3: Once images are captured, let's try to get a 'color' from eac...
10,587
<ASSISTANT_TASK:> Python Code: # Import libraries necessary for this project import numpy as np import pandas as pd from IPython.display import display # Allows the use of display() for DataFrames # Import supplementary visualizations code visuals.py import visuals as vs # Pretty display for notebooks %matplotlib inlin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: From a sample of the RMS Titanic data, we can see the various features present for each passenger on the ship Step3: The very same sample of th...
10,588
<ASSISTANT_TASK:> Python Code: %pylab inline import numpy import sklearn from sklearn.preprocessing import Imputer import matplotlib.pyplot as plt mean = [50, 60] cov = [[5,5],[100,200]] x1,y1 = numpy.random.multivariate_normal(mean,cov,1000).T mean = [65, 70] cov = [[20,10],[2,10]] x2,y2 = numpy.random.multivariate_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: Simulating 2D data for anomaly detection Step3: Outlier detection algorithm Step 1 Step4: Now lets plot the 'real' and 'synthetic' data to exa...
10,589
<ASSISTANT_TASK:> Python Code: coin_code = data { int<lower=0> n; // number of tosses int<lower=0> y; // number of heads } transformed data {} parameters { real<lower=0, upper=1> p; } transformed parameters {} model { p ~ beta(2, 2); y ~ binomial(n, p); } generated quantities {} coin_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: PyStan Step2: Fit model Step3: MAP Step4: MCMC Step5: Loading from a file Step6: We can convert to a DataFrame if necessary Step8: Estimat...
10,590
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np %matplotlib inline from sklearn import datasets diabetes = datasets.load_diabetes() # Description at http://www4.stat.ncsu.edu/~boos/var.select/diabetes.html X = diabetes.data y = diabetes.target print(X.shape, y.shape) from sklearn 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: All the different models in scikit-learn follow a consistent structure. Step2: Although this single number might seem unimpressive, metrics ar...
10,591
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy.stats a = np.random.randn(40) b = 4*np.random.randn(50) _, p_value = scipy.stats.ttest_ind(a, b, equal_var = False) <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:
10,592
<ASSISTANT_TASK:> Python Code: %ls lidar import tables lineData = tables.openFile(r"lidar/20150927-0000-01.FRFNProp.line.data.mat","r") #science = tables.openFile(r"lidar/20150927-0000-01.FRFNProp.line.science.mat","r") for f in lineData.root: for g in f: print g z = lineData.root.lineGriddedFilteredData....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Recent matlab files are just hdf5, which we can get from pytables Step2: Grab the filtered water levels on the grid in FRF coordinates Step3: ...
10,593
<ASSISTANT_TASK:> Python Code: %matplotlib inline from bigbang.archive import Archive from bigbang.archive import load as load_archive import bigbang.parse as parse import bigbang.analysis.graph as graph import bigbang.ingress.mailman as mailman import bigbang.analysis.process as process import networkx as nx import ma...
<SYSTEM_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 a valid date frame for building the network. Step2: Filter data according to date frame and export to .gexf file
10,594
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import os, glob from osgeo import gdal files_to_mosaic = glob.glob('/Users/olearyd/Git/data/TEAK_Aspect_Tiles/*_aspect.tif') files_to_mosaic files_string = " ".join(files_to_mosaic) print(files_string) command = "gdal_merge.py -o /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: Make a list of files to mosaic using glob.glob, and print the result. In this example, we are selecting all files ending with _aspect.tif in the...
10,595
<ASSISTANT_TASK:> Python Code: %pylab inline %matplotlib inline # import all shogun classes from modshogun import * kernel = CombinedKernel() num=30; num_components=4 means=zeros((num_components, 2)) means[0]=[-1,1] means[1]=[2,-1.5] means[2]=[-1,-3] means[3]=[2,1] covs=array([[1.0,0.0],[0.0,1.0]]) gmm=GMM(num_compon...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Introduction Step2: Prediction on toy data Step3: Generating Kernel weights Step4: Binary classification using MKL Step5: To justify the wei...
10,596
<ASSISTANT_TASK:> Python Code: from sympy import * from geom_util import * from sympy.vector import CoordSys3D N = CoordSys3D('N') alpha1, alpha2, alpha3 = symbols("alpha_1 alpha_2 alpha_3", real = True, positive=True) init_printing() %matplotlib inline %reload_ext autoreload %autoreload 2 %aimport geom_util A,K = sym...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Lame params Step2: Metric tensor Step3: ${\displaystyle \hat{G}=\sum_{i,j} g_{ij}\vec{R}^i\vec{R}^j}$ Step4: Christoffel symbols Step5: Grad...
10,597
<ASSISTANT_TASK:> Python Code:: from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33) <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:
10,598
<ASSISTANT_TASK:> Python Code: tt = (1, 2, (30, 40)) hash(tt) t1 = (1, 2, [30, 40]) # 其中列表是可变的,所以没有哈希值 hash(t1) tf = (1, 2, frozenset([30, 40])) #frozenset 是冻结的集合,不可变的,所以有哈希值 hash(tf) a = dict(one = 1, two = 2, three = 3) b = {'one': 1, 'two': 2, 'three': 3} c = dict(zip(['one', 'two', 'three'], [1, 2, 3])) d = dict([...
<SYSTEM_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: 除了常规语法以及 dict 构建之外,我们可以使用字典推导来构建字典,dictcomp 会由任何一个可迭代对象产生一对 key Step3: 字典有一个内置方法 d.update(m, [**kargs]) 它会先判断 m,如果 m 有 keys 方法, ...
10,599
<ASSISTANT_TASK:> Python Code: import pandas as pd data_df = pd.read_csv('raw-data.csv', index_col='eventID') data_df.head() import matplotlib.pylab as plt import seaborn as sns # Show plots in notebook %matplotlib inline # Set some styling options sns.set_style("darkgrid") sns.set_context("paper", font_scale=1.4) fea...
<SYSTEM_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. Inspect the Distribution for a Feature Step2: Extract the values of the KDE curve for fitting purposes Step3: Let's plot it to make sure it...