Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
8,500
<ASSISTANT_TASK:> Python Code: # Load libraries from sklearn.linear_model import RidgeCV from sklearn.datasets import load_boston from sklearn.preprocessing import StandardScaler # Load data boston = load_boston() X = boston.data y = boston.target # Standarize features scaler = StandardScaler() X_std = scaler.fit_tra...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load Boston Housing Dataset Step2: Standardize Features Step3: Create Ridge Regression With Candidate Alpha Values Step4: Fit Ridge Regressio...
8,501
<ASSISTANT_TASK:> Python Code: import sys import os import shutil import warnings warnings.filterwarnings('ignore') from tensorflow import logging logging.set_verbosity(logging.ERROR) os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import matplotlib %matplotlib inline sys.path.append('../../..') from batchflow import Pipeline...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Reducing Extra Dataset Loads Step2: Then we define a grid of parameters whose nodes will be used to form separate experiments Step3: These par...
8,502
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy.ndimage import generic_filter from numba import jit, guvectorize, float64 import pyprind import matplotlib.pyplot as plt %matplotlib inline def denoise(a, b): for channel in range(2): for f_band in range(4, a.shape[1] - 4): for t_step...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: python Step2: scipy Step3: numba Step4: serial version Step5: parallel version Step6: check results Step7: check if the different implemen...
8,503
<ASSISTANT_TASK:> Python Code: # suponemos que ponemos un año de verdad, por eso no pongo condiciones año = int(input("Ingrese su año: ")) añooriginal = año resultado = "" while año != 0: if año >= 1000: veces = año // 1000 resultado += "M" * veces año %= 1000 elif año >= 900: 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: La idea es ir achicando el año, con el mayor numero romano posible, sin embargo nos dimos cuenta que teniamos problemas con los "9", por lo que ...
8,504
<ASSISTANT_TASK:> Python Code: import logging import numpy as np import pandas as pd import matplotlib.pyplot as plt root = logging.getLogger() root.addHandler(logging.StreamHandler()) %matplotlib inline # download from Google Drive: https://drive.google.com/open?id=0B9cazFzBtPuCOFNiUHYwcVFVODQ # Representative exampl...
<SYSTEM_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. Choose a representative species for a case study Step2: 2. Rasterize the species, to get a matrix of pixels Step3: 2.1 Plot to get an idea ...
8,505
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import scipy as sp from scipy.stats import randint as sp_randint from scipy.signal import argrelextrema import matplotlib as mpl import matplotlib.pyplot as plt import pandas as pd from sklearn import preprocessing from sklearn.metrics import f1_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: Now we extract just the feature variables we need to perform the classification. The predictor variables are the five log values and two geolog...
8,506
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import scipy.io import math import sklearn import sklearn.datasets from opt_utils_v1a import load_params_and_grads, initialize_parameters, forward_propagation, backward_propagation from opt_utils_v1a import compute_cost, predict, predict_...
<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: 1 - Gradient Descent Step4: Expected Output Step6: Expected Output Step8: Expected Output Step10: Expected Output Step12: Expected Output S...
8,507
<ASSISTANT_TASK:> Python Code: !pip install -U -q apache-beam[gcp] import os from datetime import datetime import apache_beam as beam import numpy as np import tensorflow.io as tf_io PROJECT_ID = "yourProject" # Change to your project. BUCKET = "yourBucketName" # Change to the bucket you created. REGION = "yourData...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import libraries Step2: Configure GCP environment settings Step3: Authenticate your GCP account Step4: Process the item embeddings data Step5...
8,508
<ASSISTANT_TASK:> Python Code: x = 7**273 print(x) print(type(x)) format(0.1, '.80f') .1 + .1 + .1 == .3 .1 + .1 == .2 from decimal import Decimal, getcontext getcontext().prec=80 format(Decimal(1)/Decimal(7), '.80f') format(1/7, '.80f') #12345678901234567 (17 digits) Decimal(1)/Decimal(7) print('{:.50f}'.forma...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Floats Step2: This can give us surprises Step3: For "infinite" precision float arithmetic you can use decimal or mpmath Step4: Getting 30 dig...
8,509
<ASSISTANT_TASK:> Python Code: from pymongo import MongoClient import json client = MongoClient() db = client.Twitter import pandas as pd import time import re from nltk.tokenize import RegexpTokenizer import HTMLParser # In Python 3.4+ import html import nltk from nltk.corpus import stopwords start_time = time.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: LOAD data from Mongo Step2: Preproccessing Step3: save/load the model Step4: efforts with pyLDAvis (visualize the LDA topics) Step5: Interac...
8,510
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper data_dir = './data/simpsons/moes_tavern_lines.txt' text = helper.load_data(data_dir) # Ignore notice, since we don't use it for analysing the data text = text[81:] view_sentence_range = (0, 10) DON'T MODIFY ANYTHING IN THIS CELL import num...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: TV Script Generation Step3: Explore the Data Step6: Implement Preprocessing Functions Step9: Tokenize Punctuation Step11: Preprocess all the...
8,511
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd import numpy as np from sklearn.cross_validation import train_test_split from sklearn import cross_validation, metrics from sklearn import preprocessing import matplotlib import matplotlib.pyplot as plt # read .csv from provided dataset csv_filename1...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Unsupervised Learning Step2: Applying agglomerative clustering via scikit-learn Step3: Step4: K Means Step5: Affinity Propogation Step6: M...
8,512
<ASSISTANT_TASK:> Python Code: # Import libraries necessary for this project import numpy as np import pandas as pd from time import time from IPython.display import display # Allows the use of display() for DataFrames # Import supplementary visualization code visuals.py import visuals as vs # Pretty display for notebo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Implementation Step2: Preparing the Data Step3: For highly-skewed feature distributions such as 'capital-gain' and 'capital-loss', it is commo...
8,513
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'hadgem3-gc31-mh', '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...
8,514
<ASSISTANT_TASK:> Python Code: print("Hello World!") # lines that begin with a # are treated as comment lines and not executed # print("This line is not printed") print("This line is printed") g = 3.0 * 2.0 print(g) g a = 1 b = 2.3 c = 2.3e4 d = True e = "Spam" type(a), type(b), type(c), type(d), type(e) a + b, typ...
<SYSTEM_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 variable Step2: Print out the value of the variable Step3: or even easier Step4: Datatypes Step5: NumPy (Numerical Python) is the f...
8,515
<ASSISTANT_TASK:> Python Code: ctx = get_extension_context("cudnn", type_config="half") loss_scale = 8 loss.backward(loss_scale) solver.scale_grad(1. / loss_scale) # do some gradient clipping, etc. after this solver.update() loss_scale = 8 scaling_factor = 2 counter = 0 interval = 2000 ... loss.backward(loss_scale, ...
<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-by-Step Instruction Step1: 2. Use loss scaling to prevent underflow Step2: 3. Use dynamic loss scaling to prevent overflow/underflow Step4: Note...
8,516
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'gfdl-esm4', '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...
8,517
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd from datetime import datetime as dt from scipy import stats prices_pd = pd.read_csv("data/Weed_Price.csv", parse_dates=[-1]) type(prices_pd) prices_pd.head() prices_pd.head(10) prices_pd.tail() prices_pd.dtypes prices_pd.sort_values(['State', ...
<SYSTEM_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: read_csv 함수의 리턴값은 DataFrame 이라는 자료형이다. Step3: DataFrame 자료형 Step4: 인자를 주면 원하는 만큼 보여준다. Step5: 파일이 매우 많은 수의 데이터를 포함하고 있을...
8,518
<ASSISTANT_TASK:> Python Code: area = 120000.0 # km^2, area covered by transects population = 120 # Total number of features (guess) no_lines = 250 # Total number of transects line_length = 150 # km, mean length of a transect feature_width = 0.5 # km, width of features density = population / area len...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Just for fun, we can — using the original formula in the reference — calculate the population size from an observation Step2: It's a linear rel...
8,519
<ASSISTANT_TASK:> Python Code: from airflow import DAG from airflow.operators.bash_operator import BashOperator from datetime import datetime, timedelta # start_date를 현재날자보다 과거로 설정하면, backfill(과거 데이터를 채워넣는 액션)이 진행됩니다 default_args = { 'owner': 'airflow', 'depends_on_past': False, 'start_date': datetime(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 01. Work_Flow_Management(using_Airflow) Step2: 위 소스를 [Airflow Home]/dags/ 에 test.py로 저장해주세요!
8,520
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'test-institute-3', 'sandbox-3', 'landice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
8,521
<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: Eager execution Step2: TensorFlow 2.0 では、 Eager Execution はデフォルトで有効化されます。 Step3: これで TensorFlow の演算を実行してみましょう。結果はすぐに返されます。 Step4: Eager Execu...
8,522
<ASSISTANT_TASK:> Python Code: #!pip install -I "phoebe>=2.4,<2.5" import phoebe from phoebe import u # units logger = phoebe.logger() b = phoebe.default_binary() phoebe.list_available_features() help(phoebe.parameters.feature.spot) b.add_feature('spot', component='primary', feature='spot01') b.get_feature('spot01')...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Available Features Step2: The API docs for each of these can be found in phoebe.parameters.feature. Each entry will list the allowable compone...
8,523
<ASSISTANT_TASK:> Python Code: !mkdir mydirectory !ls > mydirectory/myfiles.txt !rm myfiles.txt !rm mydirectory/myfiles.txt !ls mydirectory !date > datefile.txt !cat datefile.txt !date > datefile.txt !cat datefile.txt !date >> datefile.txt !date >> datefile.txt !cat datefile.txt !wget https://github.com/gwsb-istm-621...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: ">" vs ">>" Step2: lower|sort|uniq or sort|lower|uniq Step3: Among the set of three functions Step4: More about grep Step5: There are many, ...
8,524
<ASSISTANT_TASK:> Python Code: # Import all necessary libraries, this is a configuration step for the exercise. # Please run it before the simulation code! import numpy as np import matplotlib.pyplot as plt # Show the plots in the Notebook. plt.switch_backend("nbagg") ##################################################...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exercise 1 Step2: Exercise 2 Step3: Exercise 3
8,525
<ASSISTANT_TASK:> Python Code: from IPython.display import clear_output !pip install evojax !pip install torchvision # We use torchvision.datasets.MNIST in this tutorial. !pip install mediapy clear_output() import jax import jax.numpy as jnp from evojax.task.mnist import MNIST import mediapy as media import matplotli...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Evolving Spiking Neural Networks with EvoJAX! Step2: Inputs - Spike Encoding Step3: Single Spiking Neuron - Leaky Integrate and Fire Step5: S...
8,526
<ASSISTANT_TASK:> Python Code: from keras.layers import Embedding # The Embedding layer takes at least two arguments: # the number of possible tokens, here 1000 (1 + maximum word index), # and the dimensionality of the embeddings, here 64. embedding_layer = Embedding(1000, 64) from keras.datasets import imdb from kera...
<SYSTEM_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 Embedding layer is best understood as a dictionary mapping integer indices (which stand for specific words) to dense vectors. It takes Step...
8,527
<ASSISTANT_TASK:> Python Code: from sklearn import linear_model import csv import numpy as np from matplotlib import pyplot as plt from sklearn.preprocessing import Imputer from sklearn.linear_model import lasso_path from sklearn.linear_model import LassoCV from sklearn.metrics import r2_score from sklearn.metrics 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: Data pre-processing Step2: The missing values to be imputed before fit the model Step3: Exploratory analysis Step4: Model establishement Step...
8,528
<ASSISTANT_TASK:> Python Code: try: import cirq except ImportError: print("installing cirq...") !pip install --quiet cirq print("installed cirq.") import cirq import matplotlib.pyplot as plt q = cirq.LineQubit.range(4) circuit = cirq.Circuit([cirq.H.on_each(*q), cirq.measure(*q)]) result = cirq.Sim...
<SYSTEM_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 usage Step2: Plotting circuits with sparse output Step3: Sparse plots Step4: Histogram for processed results. Step5: Modifying plot pr...
8,529
<ASSISTANT_TASK:> Python Code: # Authors: Jean-Remi King <jeanremi.king@gmail.com> # Asish Panda <asishrocks95@gmail.com> # # License: BSD (3-clause) import numpy as np import matplotlib.pyplot as plt import mne from mne.datasets import sample from mne.decoding import UnsupervisedSpatialFilter from sklearn.dec...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Transform data with PCA computed on the average ie evoked response Step2: Transform data with ICA computed on the raw epochs (no averaging)
8,530
<ASSISTANT_TASK:> Python Code: %matplotlib inline #path = "data/dogscats/" path = "data/dogscats/sample/" 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 import utils import 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: 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...
8,531
<ASSISTANT_TASK:> Python Code: %matplotlib inline # Importations import matplotlib.pyplot as plt import pandas as pd import numpy as np adult=pd.read_csv('adultTrainTest.csv') adult.head() def create_categorical_data(df, column_name): cat_columns = pd.Categorical(df[column_name], ordered=False) return cat_col...
<SYSTEM_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 Préparation des données Step2: 1.3 Description élémentaire Step3: Q Que dire de la distribution de la variable age, de celle income ? Step...
8,532
<ASSISTANT_TASK:> Python Code: conf = (SparkConf(). setMaster("mesos://zk://10.132.126.37:2181/mesos"). setAppName("RY from jupyter"). set("spark.executor.uri", "http://apache.petsads.us/spark/spark-1.2.0/spark-1.2.0-bin-hadoop2.4.tgz"). set("spark.mesos.coarse", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Actions Step2: To understand flatMap, I needed to use an action to convert the RDD to a list. The solution Step3: parallelized collections Ste...
8,533
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'sandbox-3', 'landice') # 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...
8,534
<ASSISTANT_TASK:> Python Code: import sys sys.path.append('utils/') import numpy as np import loadGlasser as lg import scripts3_functions as func import scipy.stats as stats from IPython.display import display, HTML import matplotlib.pyplot as plt import statsmodels.sandbox.stats.multicomp as mc import statsmodels.api ...
<SYSTEM_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.0 Basic parameters Step4: 1.0 Load in vertex-wise betas across all miniblocks for all brain regions Step5: 2.0 - Estimate information estima...
8,535
<ASSISTANT_TASK:> Python Code: import numpy as np a = np.array( [[[ 0, 1, 2, 3], [ 2, 3, 4, 5], [ 4, 5, 6, 7]], [[ 6, 7, 8, 9], [ 8, 9, 10, 11], [10, 11, 12, 13]], [[12, 13, 14, 15], [14, 15, 16, 17], [16, 17, 18, 19]]] ) b = np.array( [[0, 1, 2], [2, 1, 3], [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:
8,536
<ASSISTANT_TASK:> Python Code: import tensorflow as tf from tensorflow.python.client import timeline import pylab import numpy as np import os %matplotlib inline %config InlineBackend.figure_format = 'retina' tf.logging.set_verbosity(tf.logging.INFO) tf.reset_default_graph() sess = tf.Session() print(sess) from datet...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Reset TensorFlow Graph Step2: Create TensorFlow Session Step3: Load Model Training and Test/Validation Data Step4: Randomly Initialize Variab...
8,537
<ASSISTANT_TASK:> Python Code: import sys sys.version sys.version_info import numpy as np np.__version__ import requests requests.__version__ import pandas as pd pd.__version__ import scipy scipy.__version__ import scidbpy scidbpy.__version__ from scidbpy import connect sdb = connect('http://localhost:8080') 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: NumPy Step2: Requests Step3: Pandas (optional) Step4: SciPy (optional) Step5: 2) Importar scidbpy Step6: conectarse al servidor de Base de ...
8,538
<ASSISTANT_TASK:> Python Code: import sys sys.path.insert(0,'../code/functions/') from random import randrange as rand from skimage.measure import label import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import pickle def generatePointSet(): center = (rand(0, 99), rand(0, 99)...
<SYSTEM_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 We Expect Our Simulation Data Will Look Like Step2: Why Our Simulation is Correct Step3: Simulation Analysis Step4: Algorithm Code Step5...
8,539
<ASSISTANT_TASK:> Python Code: df3a.dropna(axis=1, how='all',inplace=True) df3a.columns.tolist() df3a.application_type.unique() ##Only one type, may not be that useful so not keeping it. cols_to_keep=['id','loan_amnt','funded_amnt','funded_amnt_inv','term','int_rate','installment','grade','sub_grade','emp_title','emp_...
<SYSTEM_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 can look for data to do some exploratory stuff. Step2: Remove the rows with NA for loan status
8,540
<ASSISTANT_TASK:> Python Code: # Plots will be show inside the notebook %matplotlib notebook import matplotlib.pyplot as plt # NumPy is a package for manipulating N-dimensional array objects import numpy as np # Pandas is a data analysis package import pandas as pd import problem_unittests as tests # Load data and pr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: With Pandas we can load the aforementioned CSV data. Step2: With the data loaded we can plot it as a scatter plot using matplotlib. Step4: Mod...
8,541
<ASSISTANT_TASK:> Python Code: import torch import pyro pyro.set_rng_seed(101) loc = 0. # mean zero scale = 1. # unit variance normal = torch.distributions.Normal(loc, scale) # create a normal distribution object x = normal.rsample() # draw a sample from N(0,1) print("sample", x) print("log prob", normal.log_prob(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: Primitive Stochastic Functions Step2: Here, torch.distributions.Normal is an instance of the Distribution class that takes parameters and provi...
8,542
<ASSISTANT_TASK:> Python Code: import scipy import scipy.optimize import numpy as np def test_func(x): return (x[0])**2+(x[1])**2 def test_grad(x): return [2*x[0],2*x[1]] starting_point = [1.8, 1.7] direction = [-1, -1] result = scipy.optimize.line_search(test_func, test_grad, np.array(starting_point), np.array...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
8,543
<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...
8,544
<ASSISTANT_TASK:> Python Code: import vcsn a = vcsn.context('lal_char(ab), b').de_bruijn(1) a a.shortest() a.shortest(4) a.shortest(len = 4) a.shortest(num = 10, len = 4) a.shortest(num = 10, len = 3) %%automaton -s bin context = "lal_char(01), z" $ -> 0 0 -> 0 0, 1 0 -> 1 1 1 -> $ 1 -> 1 <2>0, <2>1 bin.shortest...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Boolean Automata Step2: Calling a.shortest() is equivalent to a.shortest(1) which is equivalent to a.shortest(1, 0) Step3: To get the first fo...
8,545
<ASSISTANT_TASK:> Python Code: def add1(x): return x+1 print(add1(1)) def xsq(x): return x**2 print(xsq(5)) for i in range(0,10): print(xsq(i)) def removefs(data): newdata='' for d in data: if(d=="f" or d=="F"): pass else: newdata+=(d) return newdata prin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The true power of functions is being able to call it as many times as we would like. In the previous example, we called the square function, xsq...
8,546
<ASSISTANT_TASK:> Python Code: # Enter your username: YOUR_GMAIL_ACCOUNT = '******' # Whatever is before @gmail.com in your email address # Libraries for this section: import os import datetime import numpy as np import pandas as pd import cv2 import matplotlib.pyplot as plt import matplotlib.image as mpimg import tens...
<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: Let's visualize what we're working with and get the pixel count for our images. They should be square for this to work, but luckily we padded t...
8,547
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import h5py import scipy from PIL import Image from scipy import ndimage from lr_utils import load_dataset %matplotlib inline # Loading the data (cat/non-cat) train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_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: 2 - Overview of the Problem set Step2: We added "_orig" at the end of image datasets (train and test) because we are going to preprocess them. ...
8,548
<ASSISTANT_TASK:> Python Code: from IPython.core.display import HTML css_file = 'pynoddy.css' HTML(open(css_file, "r").read()) %matplotlib inline # here the usual imports. If any of the imports fails, make sure that pynoddy is installed # properly, ideally with 'python setup.py develop' or 'python setup.py install' 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: Using the Monte-Carlo experiment class Step2: We now generate a specified amount of samples (8 in this example) and run them through Noddy. Not...
8,549
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np %matplotlib inline z = np.linspace(-5,5,num=1000) def draw_activation_plot(a,quadrants=2,y_ticks=[0],y_lim=[0,5]): #Create figure and axis fig = plt.figure() ax = fig.add_subplot(1, 1, 1) #Move left axis ax.spi...
<SYSTEM_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 plot drawing function Step2: ReLU Step3: Leaky ReLU Step4: tanh Step5: sigmoid
8,550
<ASSISTANT_TASK:> Python Code: %matplotlib inline import sys import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt import flopy print(sys.version) print('numpy version: {}'.format(np.__version__)) print('matplotlib version: {}'.format(mpl.__version__)) print('flopy version: {}'.format(flopy.__vers...
<SYSTEM_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 up some open interval tops and bottoms and some heads Step2: Make a flopy modflow model Step3: Get transmissivities along the diagonal ce...
8,551
<ASSISTANT_TASK:> Python Code: S = 25.8e-2 * 43.7e-2 # m3 m = 3.2 # kg # Masse surfacique : rhoS = m/S print( rhoS ) k = 0.0262 # W/m/K, conductivité thermique nu = 1.57e-5 # m2·s−1 , viscosité cinématique air, alpha = 2.22e-5 # m2·s−1, diffusivité thermique Pr = 0.708 # Prandl L = 4 # m, dimension caractéristique ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Convection Step2: Convection naturelle Step3: Si taille de tuile comme dim carac Step4: Isolation toiture Step5: Flux velux et fenêtre Step6...
8,552
<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: Fermi-Hubbard experiment example Step2: To track the progress of simulating experiments, we use the tqdm package. Step3: We can now import Cir...
8,553
<ASSISTANT_TASK:> Python Code: # Authors: Denis Engemann <denis.engemann@gmail.com> # Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # # License: BSD (3-clause) import numpy as np import mne from mne.preprocessing import ICA from mne.preprocessing import create_ecg_epochs, create_eog_epochs 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: Setup paths and prepare raw data Step2: 1) Fit ICA model using the FastICA algorithm Step3: 2) identify bad components by analyzing latent sou...
8,554
<ASSISTANT_TASK:> Python Code: #!/bin/bash #regtest_start_network.sh import os import shutil #os.system("killall --regex bitcoin.*") idir = os.environ['HOME']+'/regtest' if os.path.isdir(idir): shutil.rmtree(idir) os.mkdir(idir) connects = {'17591' : '17592', '17592' : '17591'} for port in connects.keys(): adir...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Import the python bitcoin module created by Peter Todd. Step2: Connect nodes to bitcoin-rpc module Step3: Network attributes Step4: Block Cha...
8,555
<ASSISTANT_TASK:> Python Code: import os # 操作系统路径分隔符 print(os.sep) # 操作系统平台名称 print(os.name) # 获取当前路径 os.getcwd() # 记录一下这是 zhang yimeng 当时执行后的结果:'C:\\Users\\yimeng.zhang\\Desktop\\Class\\python基础\\python_basic' # 这是我现在在 windows 电脑上执行的结果:'C:\\dev_python\\python_study\\python_study_basic_notebook' # 切换路径 # os.chdir('/Use...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: os.path 常用函数 Step2: 文件和目录操作之二 Step3: 写文件 Step4: 操作系统和文件系统差异处理 Step6: 我们在 fishbase 的 fish_file 包内,也实现了一个搜索文件的功能,也使用了 python 自带的 pathlib 函数包。
8,556
<ASSISTANT_TASK:> Python Code: import numpy as np nums1 = np.random.randint(1,11, 15) nums1 set1 = set(nums1) set1 nums2 = np.random.randint(1,11, 12) nums2 set2 = set(nums2) set2 set2.difference(set1) set1.difference(set2) # Intersection set1 & set2 # Union set1 | set2 # Difference (set1 - set2) | (set2 - set1) # ...
<SYSTEM_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 look at what set() does! Step2: Let's create a 2nd list and set. Step3: ...and look at the differences! Step4: See https
8,557
<ASSISTANT_TASK:> Python Code: import decimal fmt = '{0:<25}{1:<25}' print(fmt.format('Input', 'Output')) print(fmt.format('-'*25, '-'*25)) #Integer print(fmt.format(5, decimal.Decimal(5))) #String print(fmt.format('3.14', decimal.Decimal('3.14'))) #Float f = 0.1 print(fmt.format(repr(f), decimal.Decimal(str(f)))) prin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Decimals can also be created from tuples containing a sign flag Step2: Formatting Step3: Arithmetic Step4: Special Value Step5: Context Step...
8,558
<ASSISTANT_TASK:> Python Code: # Alphabetical order for nonstandard python modules is conventional # We're doing "import superlongname as abbrev" for our laziness -- # -- this way we don't have to type out the whole thing each time. # Python plotting library import matplotlib.pyplot as plt # Dataframes in Python 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: Correlation metrics Step2: Let's use FacetGrid from seaborn to plot the data onto four axes, and plot the regression line ` Step3: Below is a ...
8,559
<ASSISTANT_TASK:> Python Code: from qutip import * import matplotlib.pyplot as plt import numpy as np periodic_atom_chain8 = Lattice1d(num_cell=8, boundary = "periodic") k8 = periodic_atom_chain8.k() [ks8, pw8] = k8.eigenstates() ks8 # In units of 2*pi/(L*a), if ks[1] = 1, the wavevector/crystal-momentum of the # ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Relationship of crystal momentum eigen-vectors with the Hamiltonian Step2: So, eigenvectors of the crystal momentum are eigenvectors of the Ham...
8,560
<ASSISTANT_TASK:> Python Code: import os.path as op import numpy as np 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 = 'sLORETA' snr = 3. lambda2 = 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: First, we set some parameters. Step2: Load the MEG data Step3: Estimate the background noise covariance from the baseline period Step4: Gener...
8,561
<ASSISTANT_TASK:> Python Code: ol = shellOneLiner.ShellOneLiner('echo Hello; LANG=C date; cat datafile') head(ol,5) l = map((lambda n: ['%s' % str(n)]),range(80,100)) print l di = list2iter(l) ol = shellOneLiner.ShellOneLiner('echo Hello; LANG=C date; head', input=di) head(ol,5) ol = shellOneLiner.ShellOneLiner('dmer...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: インスタンス生成時に input オプションにイテレータ型オブジェクトを設定する事で、シェルスクリプトの標準入力に対する入力を設定する事ができる。shellOneLiner のインスタンス、および input オプションで指定されるオブジェクトは、デフォルトでは配列のイテレータ型である[...
8,562
<ASSISTANT_TASK:> Python Code: import os import sys import numpy # Path for TubeTK libs #Values takend from TubeTK launcher sys.path.append("C:/src/TubeTK_Python_ITK/TubeTK-build/lib/") sys.path.append("C:/src/TubeTK_Python_ITK/TubeTK-build/lib/Release") # Setting TubeTK Build Directory TubeTK_BUILD_DIR=None if 'TubeTK...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Next, we load the first input image and show it's origin, spacing, etc. Step2: We get the numpy array for the image and visualize it Step3: Le...
8,563
<ASSISTANT_TASK:> Python Code: import sys sys.path.append("../") from IoTPy.core.stream import Stream, run from IoTPy.agent_types.op import map_element from IoTPy.helper_functions.recent_values import recent_values w = Stream('w') x = Stream('x') y = Stream('y') z = (x+y)*w # z[n] = (x[n] + y[n])*w[n] w.extend([1, 10,...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Combining Streams with Binary Operators Step2: Examples of zip_stream and zip_map Step3: Defining Aggregating Functions on Streams Step4: Mer...
8,564
<ASSISTANT_TASK:> Python Code: import hashlib import os import pickle from urllib.request import urlretrieve import numpy as np from PIL import Image from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelBinarizer from sklearn.utils import resample from tqdm import tqdm from zipfil...
<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: The notMNIST dataset is too large for many computers to handle. It contains 500,000 images for just training. You'll be using a subset of this...
8,565
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division %matplotlib inline import warnings warnings.filterwarnings('ignore') from thinkbayes2 import Pmf, Suite import thinkplot d6 = Pmf() for x in [1,2,3,4,5,6]: d6[x] = 1 d6.Print() d6.Normalize() d6.Print() d6.Mean() d6.Random() thin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Working with Pmfs Step2: A Pmf is a map from possible outcomes to their probabilities. Step3: Initially the probabilities don't add up to 1. S...
8,566
<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 3 Step2: <a name="assignment-synopsis"></a> Step3: We'll now make use of something I've written to help us store this data. It provid...
8,567
<ASSISTANT_TASK:> Python Code: !pip install gdown !mkdir ./data import gdown def data_import(): ids = { "tables_of_fgm.h5":"1XHPF7hUqT-zp__qkGwHg8noRazRnPqb0" } url = 'https://drive.google.com/uc?id=' for title, g_id in ids.items(): try: output_file = open("/content/data/" + title, 'wb') ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Function libaries Step2: data_reader Step3: model Step4: build neural network model Step5: model training Step6: TPU training Step7: Train...
8,568
<ASSISTANT_TASK:> Python Code: from trappy.stats.Topology import Topology from bart.sched.SchedMultiAssert import SchedMultiAssert from bart.sched.SchedAssert import SchedAssert import trappy import os import operator import json #Define a CPU Topology (for multi-cluster systems) BIG = [1, 2] LITTLE = [0, 3, 4, 5] CLUS...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Periodic Yield Step2: CPU Hog Step3: Changing Reservations
8,569
<ASSISTANT_TASK:> Python Code: %%capture !pip install requests; import requests pdbAPI = "https://search.rcsb.org/rcsbsearch/v1/query?json=" disulfide_filter = '{"type": "terminal", "service": "text", "parameters": {"operator": "greater_or_equal", "value": 1, "attribute": "rcsb_entry_info.disulfide_bond_count"}}' NMR_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Building the PDB Query (Search API) Step2: Now we can combine these three filters together using AND Step3: And add the return information. N...
8,570
<ASSISTANT_TASK:> Python Code: #This notebook also uses the `(some) LaTeX environments for Jupyter` #https://github.com/ProfFan/latex_envs wich is part of the #jupyter_contrib_nbextensions package from myhdl import * from myhdlpeek import Peeker import numpy as np import pandas as pd import matplotlib.pyplot as plt %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: \title{myHDL Combinational Logic Elements Step2: Demultiplexers Step4: myHDL Module Step6: myHDL Testing Step7: Verilog Conversion Step9: \...
8,571
<ASSISTANT_TASK:> Python Code: import pandas as pd from bokeh.charts import TimeSeries, output_notebook, show # Get data # Process data # Output option # Create timeseries chart # Show chart # Style your timeseries chart # Show new chart # Compute moving average # Create chart with moving average # Show chart with m...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exercise Step2: Exercise
8,572
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import print_function, division import numpy import scipy.stats import matplotlib.pyplot as pyplot from ipywidgets import interact, interactive, fixed import ipywidgets as widgets import first # seed the random number generator so we all get the same res...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Part One Step2: We'll look at a couple of variables, including pregnancy length and birth weight. The effect size we'll consider is the differ...
8,573
<ASSISTANT_TASK:> Python Code: r1 = Symbol('r1') # magnitude of vector r1 (electron 1 to nucleus distance) r2 = Symbol('r2') # magnitude of vector r2 (electron 2 to nucleus distance) r12 = Symbol('r12') # |r2-r1| (magnitude of vector r2-r1) beta = Symbol('beta') R1 = exp(-2*r1) R2 = exp(-2*r2) G = exp(r12/2/(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: Step3: Simple trial wavefunction
8,574
<ASSISTANT_TASK:> Python Code: x = 5. # assign value of 5 to variable x if x < 10: # the statement we are testing. IF this statement is true... print(x) # this block of text will execute. the next line after if, while, or for should always be indented. if x == 5.: # recall the "==" is used to TEST whether two val...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Iteration with For Loops Step2: List Comprehension in Python Step3: Combining Control Flow Loops Step4: File I/O Step5: File I/O Step6: The...
8,575
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import matplotlib.pyplot as plt import numpy as np from scikits.odes import ode #data of the oscillator k = 4.0 m = 1.0 #initial position and speed data on t=0, x[0] = u, x[1] = \dot{u}, xp = \dot{x} initx = [1, 0.1] def rhseqn(t, x, xdot): we 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: Step2: We need a first order system, so convert the second order system Step3: To solve the ODE you define an ode object, specify the solver to use, ...
8,576
<ASSISTANT_TASK:> Python Code: import re import json import time import nltk import dask import dask.bag as db import nltk from nltk.corpus import stopwords dask.__version__ nltk.__version__ data = db.from_filenames("RC_2015-05", chunkbytes=100000).map(json.loads) data.take(1) no_stopwords = lambda x: x not in stop...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Note Step2: Create a data variable that points to the big 33 GB file and set the chunkbytes to 100 MB, map each item to json.loads since I know...
8,577
<ASSISTANT_TASK:> Python Code: import json import urllib.parse import numpy as np import pandas as pd import requests %matplotlib inline # It might be overkill, but I figured it best # for legibility to separate query arguments as a dict params_dict = { "q":"projectid:30072", "per_page":"1000" } params_encode...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Inspection Reports and DocumentCloud Step2: Here I convert the relatively human-readable dict to the right format for querying DocumentCloud St...
8,578
<ASSISTANT_TASK:> Python Code: import sys import os sys.path.append(os.environ.get('NOTEBOOK_ROOT')) import numpy as np import xarray as xr import pandas as pd import matplotlib.pyplot as plt from utils.data_cube_utilities.dc_display_map import display_map from utils.data_cube_utilities.clean_mask import landsat_clean_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <span id="slip_plat_prod">Choose Platform and Product &#9652;</span> Step2: <span id="slip_define_extents">Define the Extents of the Analysis &...
8,579
<ASSISTANT_TASK:> Python Code: with open("shakespeare_data/plays_xml/othello_ps_v3.xml") as f: othello_xml = etree.fromstring(f.read().encode()) all_elements = list(othello_xml.iter()) all_elements [e.text for e in all_elements if e.tag == "speaker"] set([e.text for e in all_elements if e.tag == "speaker"]) cas...
<SYSTEM_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 we're trying to build a network we need two things Step2: That's a lot of information! Let's grab out all of the speakers. All the speaker e...
8,580
<ASSISTANT_TASK:> Python Code: # @title Install C++ deps %%shell sudo apt-get -qq install exuberant-ctags libopenblas-dev software-properties-common build-essential # @title Install python deps %%shell pip install -q contextlib2 pint simplejson ctypesgen==1.0.2 # @title Build and Install Bifrost %%shell cd "${HOME}" 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: Now, let's create and test a pipeline Step2: Let's first create a simple CUDA kernel within Bifrost. Step6: Now, let's generate a full pipelin...
8,581
<ASSISTANT_TASK:> Python Code: # Import pandas under the name pd import pandas as pd import numpy as np import matplotlib %matplotlib inline matplotlib.style.use('fivethirtyeight') # Create a dataframe from a CSV file df = pd.read_csv('data/cfpb_complaints_with_fictitious_data.csv') # Any dataframe at end of cell gets ...
<SYSTEM_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 dataframe can be thought of like a relationtional database table or an Excel sheet. It has rows and columns. The rows correspond with an indiv...
8,582
<ASSISTANT_TASK:> Python Code: def x2_list(xs): L = [] for x in xs: L.append(x**2) return L x2_list([0, 0.5, 1, 1.5, 2, 2.5]) def x3_list(xs): L = [] for x in xs: L.append(x**3) return L def x4_list(xs): L = [] for x in xs: L.append(x**4) return L def xn_lis...
<SYSTEM_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: 이런 식으로 5승, 6승, 7승값으로 이루어진 리스트를 린터하는 함수들을 작성하려면 매번 전체코드를 복사해서 특정...
8,583
<ASSISTANT_TASK:> Python Code: import kfp from kfp import dsl def gpu_smoking_check_op(): return dsl.ContainerOp( name='check', image='tensorflow/tensorflow:latest-gpu', command=['sh', '-c'], arguments=['nvidia-smi'] ).set_gpu_limit(1) @dsl.pipeline( name='GPU smoke check', ...
<SYSTEM_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 may see a warning message from Kubeflow Pipeline logs saying "Insufficient nvidia.com/gpu". If so, this probably means that your GPU-enabled...
8,584
<ASSISTANT_TASK:> Python Code: # Import data path = "../data/petdata_binary_1000_100.csv" raw_data = pd.read_csv(path, index_col="doc_uri") assert raw_data.shape == (1000,100), "Import error, df has false shape" # Convert df data = raw_data.unstack().to_frame().reset_index() data.columns = ["user", "doc_uri", "rating"...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Conversion and cleaning Step2: Descriptive statistics of ratings Step3: Recommendation Engines Step4: Memory-based CF Step5: Item-based CF S...
8,585
<ASSISTANT_TASK:> Python Code: import warnings warnings.filterwarnings("ignore") import pandas as pd names = ["component", "RA", "Dec", "Spectral Type", "Teff", "AJ", "Lbol", "R-I","I", "J-H","H-Ks", "Ks", "Mass"] tbl1 = pd.read_csv("http://iopscience.iop.org/0004-637X/614/1/398/fulltext/60660.tb1.txt", sep='\t', 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: Table 1- Composite photometry
8,586
<ASSISTANT_TASK:> Python Code: import pandas as pd flows = pd.read_csv('simple_fruit_sales.csv') from floweaver import * # Set the default size to fit the documentation better. size = dict(width=570, height=300) # Same partitions as the Quickstart tutorial farms_with_other = Partition.Simple('process', [ 'farm1', ...
<SYSTEM_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 happens if we remove farm2 from the ProcessGroup? Step2: The flow is still there! But it is labelled with a little arrow to show that it i...
8,587
<ASSISTANT_TASK:> Python Code: # Dependencies import numpy as np import pandas as pd import matplotlib.pyplot as plt import json import tweepy import time import seaborn as sns %pylab notebook # Initialize Sentiment Analyzer from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer analyzer = SentimentIntens...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: trying for several targets Step2: Plots Step3: Scatterplot Step4: 3. bar plot
8,588
<ASSISTANT_TASK:> Python Code: from geomath.point import Point A = Point(0,0) B = Point(4,4) A.distance(B) A.midpoint(B) B.quadrant() from geomath.line import Line Linha = Line() Linha.create_via_equation("1x+2y+3=0") Linha.equation() Linha.create(Point(0,0),Point(4,4)) Linha.equation() from geomath.figure import Fig...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Entendendo Linhas Step2: Figuras
8,589
<ASSISTANT_TASK:> Python Code: import warnings warnings.filterwarnings('ignore') %matplotlib inline %pylab inline import pandas as pd print(pd.__version__) df = pd.read_csv('./insurance-customers-300.csv', sep=';') y=df['group'] df.drop('group', axis='columns', inplace=True) X = df.as_matrix() df.describe() # ignore ...
<SYSTEM_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 Step Step2: Second Step Step3: Look how great it is doing! Step4: But really? Step5: Cross Validation is a way to make the score more ...
8,590
<ASSISTANT_TASK:> Python Code: !pip install "thinc>=8.0.0a0" "ml_datasets>=0.2.0a0" "tqdm>=4.41" from thinc.api import prefer_gpu prefer_gpu() import ml_datasets from tqdm.notebook import tqdm from thinc.api import fix_random_seed fix_random_seed(0) def train_model(model, optimizer, n_iter, batch_size): (train_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: We start by making sure the computation is performed on GPU if available. prefer_gpu should be called right after importing Thinc, and it return...
8,591
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import tensorflow as tf import utils as utl from collections import Counter # read data from csv file data = pd.read_csv("data/StockTwits_SPY_Sentiment_2017.gz", encoding="utf-8", compression="gzip", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Processing Data Step2: Preprocess Messages Step3: Generate Vocab to Index Mapping Step4: Check Message Lengths Step5: Encode Messages and La...
8,592
<ASSISTANT_TASK:> Python Code: def toStr(FS): result = '{ ' for S in FS: result += str(set(S)) + ', ' result = result[:-2] result += ' }' return result def arb(S): for x in S: return x def union_find(M, R): print(f'R = {R}') P = { frozenset({x}) for x in M } # the triv...
<SYSTEM_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 $\texttt{arb}(S)$ returns an arbitrary element from the set $S$, Step2: Given a set $M$ and a binary relation $R \subseteq M \time...
8,593
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt fig = plt.figure() plt.show() ax = plt.axes() x = np.linspace(0, 5, 10) y = x ** 2 ax = plt.plot(x, y, '-') from matplotlib import ticker x = np.linspace(0, 5, 10) y = x ** 10 fig, ax = plt.subplots() ax.plot(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: - dry stuff - The matplotlib Figure, Axes and Axis Step2: On its own, drawing the figure artist is uninteresting and will result in an empty pi...
8,594
<ASSISTANT_TASK:> Python Code: # If you'd like to download it through the command line... !curl -O http://www.cs.cornell.edu/home/llee/data/convote/convote_v1.1.tar.gz # And then extract it through the command line... !tar -zxf convote_v1.1.tar.gz # glob finds files matching a certain filename pattern import glob # Gi...
<SYSTEM_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 explore the files if you'd like, but we're going to get the ones from convote_v1.1/data_stage_one/development_set/. It's a bunch of text...
8,595
<ASSISTANT_TASK:> Python Code: # Load the needed packages from glob import glob import matplotlib.pyplot as plt import awot from awot.graph import RadarSweepPlot %matplotlib inline fnc = '/Users/guy/data/p3radar/HRD_test/20120828/cfradial/cfrad.20120828_120541.113_to_20120828_120547.113_N42R_v1_s00_az-19.48_AIR.nc' Ra...
<SYSTEM_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>Plot a cfradial formatted sweep file from the NOAA P-3. This should work on data from 2012 onward. Step2: Now let's plot the same data, but ...
8,596
<ASSISTANT_TASK:> Python Code: !pwd %cd /content/ !pwd !pip install neuron !pip install netpyne import matplotlib import os import json %matplotlib inline if os.path.isdir('/content/cells_netpyne2021'): !rm -r /content/cells_netpyne2021 !git clone https://github.com/ericaygriffith/cells_netpyne2021.git cd cell...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Move to (or stay in) the '/content' directory Step2: Ensure you are in the correct directory --> Expected output Step3: Install NEURON and Net...
8,597
<ASSISTANT_TASK:> Python Code: %pylab inline import numpy as np from scipy.sparse import dia_matrix import scipy as sp import scipy.sparse import scipy.sparse.linalg import matplotlib import matplotlib.pyplot as plt newparams = { 'savefig.dpi': 100, 'figure.figsize': (12/2., 5/2.) } plt.rcParams.update(newparams) para...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: WSS dependent parameters Step10: Parameters Step11: Assembling and solving the discrete system Step12: Class that performs simulation Step13:...
8,598
<ASSISTANT_TASK:> Python Code: import pandas as pd import operator import datetime import numpy as np page_id = "appledaily.tw" path = 'post/'+page_id+'_post.csv' df = pd.read_csv(path, encoding='utf8') df.head() len(df) df.apply(lambda x: sum(x.isnull())) df = df[df['status_message'].notnull()].reindex() df = df[...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Data Porcessing Step2: 看一看前五筆 Step3: 一共5234筆發文 Step4: 把status_message為空值的地方拿掉 Step5: 再把reactions等於0的去掉 Step6: 剩下5061篇發文 Step7: Feature Eng...
8,599
<ASSISTANT_TASK:> Python Code: %config InlineBackend.figure_format = 'retina' import matplotlib.pyplot as plt from sklearn.datasets import fetch_olivetti_faces from sklearn.cluster import MiniBatchKMeans from sklearn import decomposition import sklearn import sklearn.cross_decomposition import numpy as np import seabor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: PCA via PyTorch Step2: We note that the components look rotated compared to the PCs. Do they capture the same information, however? We can veri...