Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
10,800
<ASSISTANT_TASK:> Python Code: # import the required libraries import numpy as np import time import random import cPickle import codecs import collections import os import math import json import tensorflow as tf from six.moves import xrange # libraries required for visualisation: from IPython.display import SVG, disp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Encode and Decode Sample Drawings Step2: Temperature Interpolation Step3: Latent Space Interpolation Stepping through latent space between two...
10,801
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.read_csv('data/mlb.csv') # use head to check it out df.head() df.count() df.SALARY.sum() df.TEAM.unique() df[['TEAM', 'SALARY']].groupby('TEAM') \ .sum() \ .reset_index() \ .set_index('TEAM'...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Read in the data into a data frame Step2: How many players? Step3: Total MLB payroll Step4: Get a list of teams Step5: Total payroll by team...
10,802
<ASSISTANT_TASK:> Python Code: %%bash sudo pip freeze | grep google-cloud-bigquery==1.6.1 || \ sudo pip install google-cloud-bigquery==1.6.1 from google.cloud import bigquery query = SELECT weight_pounds, is_male, mother_age, plurality, gestation_weeks, FARM_FINGERPRINT( CONCAT( ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: The source dataset Step3: Let's create a BigQuery client that we can use throughout the notebook. Step4: Let's now examine the result of a Biq...
10,803
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np def is_int(value): try: int(value) return True except ValueError: return False def is_float(value): try: float(value) return True except ValueError: return ...
<SYSTEM_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 and clean SPINE data Step3: Read and clean census data Step4: Read and clean workforce data Step5: Read and cl...
10,804
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline plt.style.use('ggplot') plt.rcParams['figure.figsize'] = (12, 8) # Load the train dataset train = pd.read_csv("../Data/train.csv") # Load the test dataset test = pd.read_csv(".....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Attribute Information Step2: Find basic summary metrics for the train dataframe Step3: *Where did the remaining columns go? * Step4: Bi-varia...
10,805
<ASSISTANT_TASK:> Python Code: import pandas as pd from sklearn.datasets import load_boston boston = load_boston() dataset = pd.DataFrame(boston.data, columns=boston.feature_names) dataset['target'] = boston.target observations = len(dataset) variables = dataset.columns[:-1] X = dataset.ix[:,:-1] y = dataset['target']...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Cross validation Step3: Valid options are ['accuracy', 'adjusted_rand_score', 'average_precision', 'f1', 'f1_macro', 'f1_micro', 'f1_samples', ...
10,806
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper import problem_unittests as tests source_path = 'data/small_vocab_en' target_path = 'data/small_vocab_fr' source_text = helper.load_data(source_path) target_text = helper.load_data(target_path) view_sentence_range = (0, 10) DON'T MODIFY AN...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Language Translation Step3: Explore the Data Step6: Implement Preprocessing Function Step8: Preprocess all the data and save it Step10: Chec...
10,807
<ASSISTANT_TASK:> Python Code: %reset # Import the required modules import pandas as pd import numpy as np import scipy as sp # simple function to read in the user data file. # the argument parse_dates takes in a list of colums, which are to be parsed as date format user_data_raw_csv = pd.read_csv("/home/eyebell/local_...
<SYSTEM_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 Clean up Step2: As is visible from the last column (age_on_platform) data type, Pandas is not recognising it as date type format. Step3: ...
10,808
<ASSISTANT_TASK:> Python Code: import os GCP_PROJECT = 'dp-workspace' GCS_BUCKET = 'gs://cluster19-bkt' GCS_REGION = 'us-central1' os.putenv("REGION", GCS_REGION) TF_RECORD_SEQEX = GCS_BUCKET+'/synthea/serv/seqex*' os.putenv("SEQEX_IN_GCS", TF_RECORD_SEQEX) MODEL_PATH = GCS_BUCKET+'/synthea/model/' os.putenv("MODEL_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: <b>Import dependencies. </b> Step2: <b>Optionally, enable logging for debugging.</b> Step3: <b> Previous step saved Sequence Examples into GCS...
10,809
<ASSISTANT_TASK:> Python Code: from k2datascience import movies from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity = "all" %matplotlib inline mov = movies.BoxOffice() print(f'Data Types:\n{mov.data.dtypes}\n\n') print(f'Data Shape:\n{mov.data.shape}\n\n') print(f'Missing...
<SYSTEM_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 Prep Step2: Exercise 1 Step3: Y-Axis Labels Step4: Benefits and Liabilities Step5: Findings Step6: Findings Step7: Exercise 6
10,810
<ASSISTANT_TASK:> Python Code: %matplotlib inline import os, sys, time import pickle as pkl import numpy as np import pandas as pd import sklearn as sk import cython import itertools from scipy.io import arff from scipy.optimize import minimize from scipy.optimize import check_grad from sklearn.linear_model import Logi...
<SYSTEM_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 loading Step2: Features Step3: Labels Step4: Data analysis Step5: Histogram of #positive labels. Step8: Dataset creation Step9: Evalu...
10,811
<ASSISTANT_TASK:> Python Code: # install Pint if necessary try: import pint except ImportError: !pip install pint # download modsim.py if necessary from os.path import exists filename = 'modsim.py' if not exists(filename): from urllib.request import urlretrieve url = 'https://raw.githubusercontent.com/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: Case studies Step2: Select tables[1], which is the second table on the page. Step3: Not all researchers provide estimates for the same dates. ...
10,812
<ASSISTANT_TASK:> Python Code: from __future__ import print_function %matplotlib inline import matplotlib.pyplot as plt import numpy as np from contact_map import ContactTrajectory, RollingContactFrequency import mdtraj as md traj = md.load("data/gsk3b_example.h5") print(traj) # to see number of frames; size of system...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: First, we'll use MDTraj's atom selection language to split out the protein and the ligand, which has residue name YYG in the input files. We're ...
10,813
<ASSISTANT_TASK:> Python Code: import numpy as np x = np.array([0, 1, 1, 1, 3, 1, 5, 5, 5]) y = np.array([0, 2, 3, 4, 2, 4, 3, 4, 5]) a = 1 b = 4 idx_list = ((x == a) & (y == b)) result = idx_list.nonzero()[0] <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
10,814
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import pickle import statsmodels.api as sm from sklearn import cluster import matplotlib.pyplot as plt %matplotlib inline from bs4 import BeautifulSoup as bs import requests import time # from ggplot import * base_url = "http://www.mywebsite.com/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: Other Useful Packages (not used today) Step2: Prepare another URL on your own Step3: Where did the ? go? Step4: View Returned Data Step5: Et...
10,815
<ASSISTANT_TASK:> Python Code: dataset = Dataset(config=dict(dataset_name='MNIST', data_dir='~/nta/datasets', batch_size_train=256, batch_size_test=1024)) # torch cross_entropy is log softmax activation + negative log likelihood loss_func = F.cross_entropy # a custom Lambda module class Lam...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Extend for the k-Winners simulation Step2: Model accuracy with 1% of active neurons, with and without boosting Step3: Extend to CNNs Step4: E...
10,816
<ASSISTANT_TASK:> Python Code: import numpy as np a = np.arange(5) a a.size a.shape a[0] a[-1] a[2:4] a[2:] a[:4] a[:] a[1::2] a.max() a.min() a.sum() a + 3 a * 5 a + 3 * 5 a + 15 (a + 3) * 5 a * 5 + 3 a * (5 + 3) %matplotlib inline import matplotlib.pyplot as plt a = np.linspace(-np.pi, np.pi, 100) plt.plot(a) plt.p...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Indexing Step2: Play Step3: Dimensions Step4: Indexing Step5: Play Step6: ... have a look at y and predict what the next expression will ou...
10,817
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt # RBP PWM's from concise.data import attract dfa = attract.get_metadata() dfa # TF PWM's from concise.data import encode dfe = encode.get_metadata() dfe # TF PWM's from concise.data import hocomoco dfh = hocomoco.get_metadata() dfh dfa_p...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let's choose PUM2 PWM (RBP in Human) Step2: Visualization - PWM class Step3: We can select the PWM with id 129. Step4: Initialize the conv fi...
10,818
<ASSISTANT_TASK:> Python Code: import matplotlib import warnings warnings.filterwarnings("ignore", category=matplotlib.cbook.MatplotlibDeprecationWarning) %matplotlib inline # The archive of data on S3 URL did not work for me, despite .edu domain #url = 'http://thredds-aws.unidata.ucar.edu/thredds/radarServer/nexrad/l...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: First we'll create an instance of RadarServer to point to the appropriate radar server access URL. Step2: Next, we'll create a new query object...
10,819
<ASSISTANT_TASK:> Python Code: f = open('filespython.txt', 'r') for line in f: print(line) f.close() f = open('filespython.txt', 'w') f.write('This is another line\n') f.close() f = open('filespython.txt', 'r') print(f.read()) f.close() f = open('filespython.txt', 'a') f.write('This is another line\n') f.clo...
<SYSTEM_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 output of each iteration of the for-loop is a string which contains the entire line of the file. Step2: Notice that all of the file content...
10,820
<ASSISTANT_TASK:> Python Code: data_in_shape = (6, 6, 3) L = AveragePooling2D(pool_size=(2, 2), strides=None, padding='valid', data_format='channels_last') layer_0 = Input(shape=data_in_shape) layer_1 = L(layer_0) model = Model(inputs=layer_0, outputs=layer_1) # set weights to random (use seed for reproducibility) np.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: [pooling.AveragePooling2D.1] input 6x6x3, pool_size=(2, 2), strides=(1, 1), padding='valid', data_format='channels_last' Step2: [pooling.Averag...
10,821
<ASSISTANT_TASK:> Python Code: import pandas as pd import nltk from nltk.corpus import stopwords from nltk.stem import SnowballStemmer from collections import Counter bloboftext = This little piggy went to market, This little piggy stayed home, This little piggy had roast beef, This little piggy had none, And this li...
<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: Input Step3: Workflow Step4: About stemmers and lemmatisation Step5: Count & POS tag of each stemmed/non-stop word Step6: Proportion of POS ...
10,822
<ASSISTANT_TASK:> Python Code: !ffmpeg -i LlamaDrama.mp4 -movflags faststart -b:v 256000 -maxrate 256000 -x264opts "fps=24:keyint=48:min-keyint=48:no-scenecut" -hls_list_size 0 -hls_time 4 -hls_base_url http://192.168.3.14:8000/low/ low/LlamaDrama.m3u8 !ffmpeg -i LlamaDrama.mp4 -movflags faststart -b:v 512000 -maxrate...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Llama Drama Low (1920x1080) Step2: Llama Drama Medium (1920x1080) Step3: Llama Drama High (1920x1080) Step4: Playlist Step5: StreamEngine St...
10,823
<ASSISTANT_TASK:> Python Code: 'eggs' < 'spam' 8 in (1,8,7,3,9,'spam') assert(8>5) assert(8<5) assert(8<5), 'wicked helpful assertion string' def K2C(tK): Convert degrees K to C. Argument: tK is a temperature in degrees K. Precondition: (tK > 0) assert tK > 0, 'tK is negative' return ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: $...$ or a membership test and the like. Step2: Assertions, preconditions, postconditions Step3: If an assertion is true, nothing happens. All...
10,824
<ASSISTANT_TASK:> Python Code: # If we're running on Colab, install empiricaldist # https://pypi.org/project/empiricaldist/ import sys IN_COLAB = 'google.colab' in sys.modules if IN_COLAB: !pip install empiricaldist # Get utils.py from os.path import basename, exists def download(url): filename = basename(url) ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In the previous chapter we used Bayes's Theorem to solve a cookie problem; then we solved it again using a Bayes table. Step2: If that doesn't ...
10,825
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() l = [ 4, 3, 0, 2, 1 ] i = 0 while l[i] != 0 : i = l[i] print (i) # que vaut l[i] à la fin ? from IPython.display import Image Image("td2_1.png") l = [ 3, 6, 2 , 7, 9 ] x = 7 for i,v in enumerate(l) : ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Partie 3 Step2: Cet exercice montre une façon curieuse de se déplacer dans un tableau puisqu'on commence à la première position puis on va la ...
10,826
<ASSISTANT_TASK:> Python Code: # Change these to try this notebook out BUCKET = "cloud-training-demos-ml" PROJECT = "cloud-training-demos" REGION = "us-central1" SEQ_LEN = 50 import os os.environ['BUCKET'] = BUCKET os.environ['PROJECT'] = PROJECT os.environ['REGION'] = REGION os.environ['SEQ_LEN'] = str(SEQ_LEN) os.env...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <h3> Simulate some time-series data </h3> Step2: <h3> Train model locally </h3> Step3: <h3> Cloud ML Engine </h3> Step4: Monitor training wit...
10,827
<ASSISTANT_TASK:> Python Code: # This will plot a simple scatter graph of points. # The points will have all different sizes just for visual appearance, as well as varied colours %matplotlib inline # Import the required libraries import numpy as np import matplotlib.pyplot as plt # Lets say we want to plot 50 points 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: Source Step2: 2. numpy.genfromtxt() Step3: Note Step4: Formatting Step5: Try looking at the data from the 1960's to the present day. You can...
10,828
<ASSISTANT_TASK:> Python Code: %matplotlib inline # Needed to include the figures in this notebook, you can remove it # to work with a normal script import numpy as np import csv import matplotlib.pyplot as plt from sklearn.neighbors import KNeighborsRegressor from sklearn.preprocessing import StandardScaler 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: 1. NUMPY Step2: Define a new 3x2 array named my_array2 with [1, 2, 3] in the first row and [4,5,6] in the second. Step3: There are a number o...
10,829
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import scipy.optimize as opt a_true = 0.5 b_true = 2.0 c_true = -4.0 # YOUR CODE HERE x = np.linspace(-5, 5, 30) y = a_true*(x**2) + b_true*(x) + [c_true]*30 + 2*np.random.randn(30) plt.scatter(x, y) assert True # lea...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Fitting a quadratic curve Step2: First, generate a dataset using this model using these parameters and the following characteristics Step3: No...
10,830
<ASSISTANT_TASK:> Python Code: from learntools.core import binder binder.bind(globals()) from learntools.data_cleaning.ex1 import * print("Setup Complete") # modules we'll use import pandas as pd import numpy as np # read in all our data sf_permits = pd.read_csv("../input/building-permit-applications-data/Building_Per...
<SYSTEM_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) Take a first look at the data Step2: Use the code cell below to print the first five rows of the sf_permits DataFrame. Step3: Does the data...
10,831
<ASSISTANT_TASK:> Python Code: # Author: Denis A. Engemann <denis.engemann@gmail.com> # Alexandre Gramfort <alexandre.gramfort@inria.fr> # Jean-Remi King <jeanremi.king@gmail.com> # Eric Larson <larson.eric.d@gmail.com> # # License: BSD-3-Clause import numpy as np import matplotlib.pyplot as plt...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set parameters Step2: Compute inverse solution Step3: Decoding in sensor space using a logistic regression Step4: To investigate weights, we ...
10,832
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pandas as pd from classifiers import read_spam_data, transform_log, transform_binary #from sklearn.linear_model import LogisticRegression # reference sklearn implementation from classifiers import LogisticRegression train_data, test_data = read...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In logistic regression, we let Step2: The default settings work pretty well and give us a 7% misclassification rate. Let us try various transf...
10,833
<ASSISTANT_TASK:> Python Code: from imdb import IMDb from datetime import datetime from elasticsearch import Elasticsearch es = Elasticsearch() ia = IMDb() listaPelis = ia.get_top250_movies() listaPelis for i in range(10,250): peli = listaPelis[i] peli2 = ia.get_movie(peli.movieID) string = peli2.summary()...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Sacar toda la info de una peli para poder meterla en un diccionario y usarla en ElasticSearch, indexandola (metodo todo en 1) Step2: Pruebas St...
10,834
<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: Graph regularization for image classification using synthesized graphs Step2: Dependencies and imports Step3: Flowers dataset Step4: After do...
10,835
<ASSISTANT_TASK:> Python Code: from IPython.core.display import Image, display display(Image(url='images/taller-sept-27/fig-4-1-9.png')) from IPython.core.display import Image, display display(Image(url='images/taller-sept-27/fig-4-1-12.png')) from IPython.core.display import Image, display display(Image(url='images/t...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Bogotá 20 de Noviembre de 2015 Step2: SIMULACION CON NIVEL=1 Step3: SIMULACION CON NIVEL=3 Step4: Simulacion del ejercicio 4.1.13 Step5: SIM...
10,836
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper import problem_unittests as tests source_path = 'data/small_vocab_en' target_path = 'data/small_vocab_fr' source_text = helper.load_data(source_path) target_text = helper.load_data(target_path) view_sentence_range = (0, 10) DON'T MODIFY AN...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Language Translation Step3: Explore the Data Step6: Implement Preprocessing Function Step8: Preprocess all the data and save it Step10: Chec...
10,837
<ASSISTANT_TASK:> Python Code: # Perform standard imports import spacy nlp = spacy.load('en_core_web_sm') # Import the displaCy library from spacy import displacy # Create a simple Doc object doc = nlp(u"The quick brown fox jumped over the lazy dog's back.") # Render the dependency parse immediately inside Jupyter: dis...
<SYSTEM_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 dependency parse shows the coarse POS tag for each token, as well as the dependency tag if given Step2: Creating Visualizations Outside of ...
10,838
<ASSISTANT_TASK:> Python Code: def sumOfDigit(K ) : sod = 0 while(K ) : sod = sod + K % 10 K = K // 10  return sod  def totalNumbersWithSpecificDifference(N , diff ) : low = 1 high = N while(low <= high ) : mid =(low + high ) // 2 if(mid - sumOfDigit(mid ) < diff ) : low = mid + 1  els...
<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,839
<ASSISTANT_TASK:> Python Code: from database import Database database = Database( '<host name>', '<database name>', '<user name>', '<password>', 'utf8mb4' ) connection = database.connect_with_pymysql() from preprocessor import Decoder, Cleaner # decoder instance decoder = Decoder() if connecti...
<SYSTEM_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 will import the questions from the database and clean those data. The cleaning includes the following steps
10,840
<ASSISTANT_TASK:> Python Code: z = np.random.normal(0, 1, 500) def r_scatter(xs, r): Generate y-values for a scatter plot with correlation approximately r return r*xs + (np.sqrt(1-r**2))*z corr_opts = { 'aspect_ratio': 1, 'xlim': (-3.5, 3.5), 'ylim': (-3.5, 3.5), } nbi.scatter(np.random.no...
<SYSTEM_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 Step2: Calculating $r$ Step3: Based on the scatter diagram, we expect that $r$ will be positive but not equal to 1. Step4: Step 1...
10,841
<ASSISTANT_TASK:> Python Code: import pixiedust pixiedust.enableJobMonitor() # @hidden_cell # Enter your DashDB JDBC URL (e.g. 'jdbc:db2://dashdb-entry-yp-dal00-00.services.dal.bluemix.net:50000/BLUDB') jdbcurl = 'jdbc:db2://...' # Enter your DashDB user name (e.g. 'dash0815') user = '...' # Enter your DashDB password...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Configure database connectivity Step2: Load data from table Step3: Explore the loaded data using PixieDust
10,842
<ASSISTANT_TASK:> Python Code: message = "Hello world" print ("My message is:", message) message = "Hello world" print ("My 1st message is:", message) print ("My 2nd message is: %s" % message) message = "Hello world" print ("My 1st message is:", message, end=(". ")) print ("My 2nd message is: %s " % message) 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: Vanilla use of print Step2: The second print uses a “formatter” (%s, %r and %d) Step3: Python adds a newline character (\n) after every print...
10,843
<ASSISTANT_TASK:> Python Code: def compute_cost_MSE(y, tx, beta): compute the loss by mse. e = y - tx.dot(beta) mse = e.dot(e) / (2 * len(e)) return mse def compute_cost_MAE(y, tx, w): y = np.array(y) return np.sum(abs(y - np.dot(tx, w))) / y.shape[0] def least_squares(y, tx): calculate 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: Step2: Least squares and linear basis functions models Step3: Load the data Step6: Least squares with a linear basis function model Step8: Let us pl...
10,844
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cas', 'sandbox-1', 'landice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "ema...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
10,845
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt from matplotlib.sankey import Sankey Sankey(flows=[0.25, 0.15, 0.60, -0.20, -0.15, -0.05, -0.50, -0.10], labels=['', '', '', 'First', 'Second', 'Third', 'Fourth', 'Fifth'], orientations=[-1, 1, 0, 1, 1, 1...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Example 1 -- Mostly defaults Step2: Example 2 Step3: Example 3
10,846
<ASSISTANT_TASK:> Python Code: tah_cloveka = 'kámen' tah_pocitace = 'papír' if tah_cloveka == 'kámen' and tah_pocitace == 'kámen'or tah_cloveka == 'nůžky' and tah_pocitace == 'nůžky' or tah_cloveka == 'papír' and tah_pocitace == 'papír': print('Plichta.') elif tah_cloveka == 'kámen' and tah_pocitace == 'nůžky' or t...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Ano, je Step2: Najdi chyby 1 Step3: Správné řešení Step4: Najdu chybu 2 Step5: Šťastná - bohatá Step6: Řešení 2 Step7: Řešení 3
10,847
<ASSISTANT_TASK:> Python Code: # Authors: Mainak Jas <mainak.jas@telecom-paristech.fr> # Eric Larson <larson.eric.d@gmail.com> # Jaakko Leppakangas <jaeilepp@student.jyu.fi> # # License: BSD (3-clause) import os.path as op import pandas as pd import numpy as np import mne from mne import combine_evoke...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: To reduce memory consumption and running time, some of the steps are Step2: The data was collected with a CTF 275 system at 2400 Hz and low-pas...
10,848
<ASSISTANT_TASK:> Python Code: # imports import os from pypit import traceslits print(os.getenv('PYPIT_DEV')) mstrace_root = os.getenv('PYPIT_DEV')+'Cooked/Trace/MasterTrace_KeckLRISr_150420_402' Tslits = traceslits.TraceSlits.from_master_files(mstrace_root) Tslits.show('edges') # left edge, right edge, row on 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: To run this Notebook, you must have an environmental variable pointed at the PYPIT Development suite Step2: Checking edges Step3: PYPYIT Scrip...
10,849
<ASSISTANT_TASK:> Python Code: if 1: used_tab = True if used_tab: used_spaces = True print("Something Something") a = 10 if a == 11: a += "abc" # a (an int) + "abc" should be a type error! 10/0 # dividing by zero should raise a zero division error! dave + ha...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <img src= attachment Step2: In the above code snippet we have three lines of error prone code; we cant add ints to strings and we cant divide b...
10,850
<ASSISTANT_TASK:> Python Code: # As usual, a bit of setup import time import numpy as np import matplotlib.pyplot as plt from cs231n.classifiers.fc_net import * from cs231n.data_utils import get_CIFAR10_data from cs231n.gradient_check import eval_numerical_gradient, eval_numerical_gradient_array from cs231n.solver 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: Fully-Connected Neural Nets Step4: Affine layer Step5: Affine layer Step6: ReLU layer Step7: ReLU layer Step8: "Sandwich" layers Step9: Lo...
10,851
<ASSISTANT_TASK:> Python Code: # use the `empty_init` flag to create an empty object hp = houseprint.Houseprint(empty_init=True) hp site1 = houseprint.Site(key="Your house name") # consult the docs to see what fields are available! # houseprint.Site?? # houseprint.Fluksometer?? # houseprint.Fluksosensor?? device1 = ho...
<SYSTEM_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 sites, devices and sensors Step2: Add everything together Step3: Save Houseprint to file Step4: Share this file with your friends!
10,852
<ASSISTANT_TASK:> Python Code: # Read data and results from the Excel macro in_xlsx = (r'C:\Data\James_Work\Staff\Heleen_d_W\ICP_Waters\TOC_Trends_Analysis_2015' r'\Data\mk_sen_test_data.xlsx') raw_df = pd.read_excel(in_xlsx, sheetname='input') res_df = pd.read_excel(in_xlsx, sheetname='results') raw_df 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: Step3: 2. Statistical functions Step4: 3. Perform comparison Step5: And below is the output from the Excel macro for comparison. Step6: My code give...
10,853
<ASSISTANT_TASK:> Python Code: referencia_inicial = 440.0 # Hz frequencias = [] # Esta lista recebera todas as frequencias de uma escala f = referencia_inicial while len(frequencias) < 12: if f > (referencia_inicial * 2): f /= 2. frequencias.append(f) f *= (3/2.) frequencias.sort() print frequencias...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Veja que há um fenômeno interessante que acontece. A nota que deveria ter frequência de 880.0 Hz (um intervalo de oitava em relação à referência...
10,854
<ASSISTANT_TASK:> Python Code: def isDivisible(n ) : while n // 100 : d = n % 10 n //= 10 n = abs(n -(d * 14 ) )  return(n % 47 == 0 )  if __name__== "__main __": n = 59173 if(isDivisible(n ) ) : print("Yes ")  else : print("No ")   <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,855
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 1 %matplotlib inline from pystyl.corpus import Corpus corpus = Corpus(language='en') corpus.add_directory(directory='data/dummy') ls data/dummy print(corpus) corpus.preprocess(alpha_only=True, lowercase=True) print(corpus) corpus.tokenize() print(cor...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Specifying a language such as 'en' (English) is optional. Adding texts from a directory to the corpus is easy Step2: By default, this function ...
10,856
<ASSISTANT_TASK:> Python Code: from astropy.time import Time import matplotlib.pyplot as plt from poliastro.plotting import StaticOrbitPlotter from poliastro.frames import Planes from poliastro.bodies import Earth, Mars, Jupiter, Sun from poliastro.twobody import Orbit epoch = Time("2018-08-17 12:05:50", scale="tdb") p...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Here we get hold of the lines list from the OrbitPlotter.plot method this is a list of lines. The first is the orbit line. The second is the cur...
10,857
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import simtk.openmm as mm import simtk.openmm.app as app import simtk.unit as unit sys11 = mm.openmm.System() sys12 = mm.openmm.System() sys22 = mm.openmm.System() sys00 = mm.openmm.System() for sys in [sys11, sys12, sy...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Running a trajectory using just a single surface Step2: Running a trajectory using MMST with no coupling Step3: Running a trajectory with the ...
10,858
<ASSISTANT_TASK:> Python Code: train_data_files = ['data/train-data.csv'] test_data_files = ['data/test-data.csv'] model_name = 'clust-model-02' resume = False train = True preprocess_features = False extend_feature_colums = False HEADER = ['key', 'x1', 'x2', 'x3', 'cluster'] HEADER_DEFAULTS = [[0], [0.0], [0.0], [0...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1. Define Dataset Metadata Step2: 2. Define Data Input Function Step3: b. data pipeline input function Step4: 3. Create Estimator Step5: 4. ...
10,859
<ASSISTANT_TASK:> Python Code: # change these to try this notebook out BUCKET = 'cloud-training-demos-ml' PROJECT = 'cloud-training-demos' REGION = 'us-central1' import os os.environ['BUCKET'] = BUCKET os.environ['PROJECT'] = PROJECT os.environ['REGION'] = REGION %%bash if ! gsutil ls | grep -q gs://${BUCKET}/; then ...
<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: <h2> Create ML dataset by sampling using BigQuery </h2> Step3: Lab Task #1
10,860
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import scipy.optimize as opt f = np.load('decay_osc.npz') tdata = np.array(f['tdata']) ydata = np.array(f['ydata']) dy = np.array(f['dy']) plt.figure(figsize=(8,6)) plt.errorbar(tdata, ydata, dy, fmt='.k', ecolor='ligh...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Fitting a decaying oscillation Step2: Now, using curve_fit to fit this model and determine the estimates and uncertainties for the parameters
10,861
<ASSISTANT_TASK:> Python Code: import sys import os sys.path.insert(0,'..') sys.path.insert(0,'../layeredneuralnetwork/') from layered_neural_network import LayeredNeuralNetwork input_dimension = 2 lnn = LayeredNeuralNetwork(input_dimension=input_dimension) from school.binary import Binary Binary.teach_and(lnn) Binar...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let us create an LNN with 2 dimension input. Step2: Schooling Step3: Looks like our LNN was a good student scoring perfect F1 score of 1.0 in ...
10,862
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import matplotlib.cm as cmap cm = cmap.inferno import numpy as np import scipy as sp import theano import theano.tensor as tt import theano.tensor.nlinalg import sys sys.path.insert(0, "../../..") import pymc3 as pm np.random.seed(20090...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Example 1 Step2: Since there isn't much data, there will likely be a lot of uncertainty in the hyperparameter values. Step3: The results show ...
10,863
<ASSISTANT_TASK:> Python Code: # Preparations import math import pandas as pd import matplotlib.pyplot as plt import matplotlib.patches as mpatches import numpy as np from scipy import stats from scipy.optimize import curve_fit import seaborn as sns from IPython.display import Latex import warnings from PrettyTable 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: Durchführung Step2: Verwendete Messgeräte Step3: Auswertung Step4: Resonanzmethode Step5: Gasgemische Step6: Fehlerrechnung Step7: Gasgemi...
10,864
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 模型平均 Step2: 构建模型 Step3: 准备数据集 Step4: 我们在这里比较三个优化器: Step5: MovingAverage 和 StocasticAverage 优化器均使用 ModelAverageCheckpoint。 Step6: 训练模型 Step7...
10,865
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-lmec', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 2...
10,866
<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: 训练后 float16 量化 Step2: 训练并导出模型 Step3: 在此示例中,您只对模型进行了一个周期的训练,因此只训练到约 96% 的准确率。 Step4: 将其写入 .tflite 文件: Step5: 要改为在导出时将模型量化为 float16,首先将 optimi...
10,867
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd pd.read_csv("../dataset/google_trends_datascience.csv", index_col=0).plot(); log = pd.read_csv("../dataset/git_log_intellij.csv.gz") log.head() log.info() log['timestamp'] = pd.to_datetime(log['timestamp']) log.head() # use log['timestamp'].max(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Einführung in<br/> Software Analytics Step2: "100" == max. Beliebtheit! Step3: Wir sehen uns Basisinfos über den Datensatz an. Step4: <b>1</b...
10,868
<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...
10,869
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" } # 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 l...
<SYSTEM_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 to TensorFlow Part 2 - Debugging and Control Flow Step2: What this notebook covers Step3: tf.print Step4: If you're using eager ...
10,870
<ASSISTANT_TASK:> Python Code: import os # Google Cloud Notebook if os.path.exists("/opt/deeplearning/metadata/env_version"): USER_FLAG = "--user" else: USER_FLAG = "" ! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG ! pip3 install -U google-cloud-storage $USER_FLAG if os.environ["IS_TESTING"]: ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Install the latest GA version of google-cloud-storage library as well. Step2: Restart the kernel Step3: Before you begin Step4: Region Step5:...
10,871
<ASSISTANT_TASK:> Python Code: # Importation des librairies. import numpy as np import pandas as pd import random as rd import matplotlib.pyplot as plt %matplotlib inline from sklearn.model_selection import train_test_split from sklearn.model_selection import GridSearchCV # Lecture d'un data frame vispremv = pd.read_ta...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Vérifier ci-dessous que la plupart des variables ont deux versions, l'une quantitative et l'autre qualitative. La version en R de ce calepin com...
10,872
<ASSISTANT_TASK:> Python Code: # Demonstração algébrica, sem código. # Desenho da parábola. # import math import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt from mpl_toolkits.axes_grid.axislines import SubplotZero def prep_axis(): Preparação dos eixos do gráfico fig = plt.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: Lista de Exercícios #2 de Computação Gráfica Step2: Questão #2 Step3: Questão #3
10,873
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 %matplotlib inline from nn_src.imports import * from nn_src.utils import get_datasets #DATA_DIR = '/Users/stephanrasp/data/' # DATA_DIR = '/scratch/srasp/ppnn_data/' DATA_DIR = '/Volumes/SanDisk/data/ppnn_data/' aux_train_set, aux_test_set = get_datasets...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Feature importance from from linear model Step2: Get random permutation scores and compute feature importance Step3: With embeddings Step4: G...
10,874
<ASSISTANT_TASK:> Python Code: import bruges as bg m, top, base, ref = bg.models.wedge(width=120) import matplotlib.pyplot as plt plt.imshow(m) plt.plot(top, 'r', lw=4) plt.plot(base, 'r', lw=4) plt.axvline(ref, c='k', ls='--') plt.show() import numpy as np vps = np.array([2320, 2350, 2350]) vss = np.array([1150, 125...
<SYSTEM_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 wedge function returns a tuple containing the model m, as well as the a top, base and ref denoting some key boundaries in the model. Let's p...
10,875
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import scipy.stats as stas %matplotlib inline x = np.arange(0.01, 1, 0.01) values = [(0.5, 0.5),(5, 1),(1, 3),(2, 2),(2, 5)] for i, j in values: y = stas.beta.pdf(x,i,j) plt.plot(x,y) plt.show() md = [] mn = [] mo = [] kur = [] 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: Ejercicio 2
10,876
<ASSISTANT_TASK:> Python Code: gmms = [GMM(i).fit(X) for i in range(1,10)] aics = [g.aic(X) for g in gmms] bics = [g.bic(X) for g in gmms] plt.plot(aics) plt.plot(bics) # Data x_i x = np.linspace(-6,6,1000) pdf = gmms[2].score_samples(x.reshape(-1,1)) plt.plot(np.linspace(-6,6,1000),np.exp(pdf[0])) plt.hist(X,bins=...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Calculate the AIC and BIC for each of these 10 models, and find the best model. Step2: Plot the AIC and BIC Step3: Define your PDF by evenly d...
10,877
<ASSISTANT_TASK:> Python Code: # import libraries import pandas as pd import numpy as np # data paths xwalkPath = '' blsPath = '' # import list of 'technology intensive' occupations from Hecker (2005), Table 3 stemOcc = pd.read_csv(xwalkPath+'hecker2005_table3.txt') stemOcc = stemOcc[['occupationcode']] stemOcc.column...
<SYSTEM_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 list of 2000 SOC occupations identified in Hecker (2005) as technology intensive. These occupations are then concorded to 2010 SOC codes ...
10,878
<ASSISTANT_TASK:> Python Code: # Importing GemPy import gempy as gp # Importing aux libraries from ipywidgets import interact import numpy as np import matplotlib.pyplot as plt import matplotlib.image as mpimg # Embedding matplotlib figures in the notebooks %matplotlib qt5 geo_model = gp.create_model('Model1') geo_mod...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Initializing the model Step2: GemPy core code is written in Python. However for efficiency (and other reasons) most of heavy computations happe...
10,879
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from scipy.signal import medfilt import math import gitInformation from neo.io import NeuralynxIO import sklearn from scipy.interpolate import Rbf import fastdtw import time %matplotlib inline gitInformation.printInformation() # Session ...
<SYSTEM_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, save and filter all the data Step2: Plot data and the thresholds
10,880
<ASSISTANT_TASK:> Python Code: from keras.datasets import imdb from keras.preprocessing import sequence max_features = 10000 # number of words to consider as features max_len = 500 # cut texts after this number of words (among top max_features most common words) print('Loading data...') (x_train, y_train), (x_test, 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: 1D convnets are structured in the same way as their 2D counter-parts that you have used in Chapter 5 Step2: Here are our training and validatio...
10,881
<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,882
<ASSISTANT_TASK:> Python Code: import pandas as pd import os dirPath = os.path.realpath('.') fileName = 'assets/coolingExample.xlsx' filePath = os.path.join(dirPath, fileName) df = pd.read_excel(filePath,header=0) df.head() df[df.columns[0]] try: df[1] except KeyError: print("KeyError: 1 - not a valid key")...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Step 2 Step2: Step 3 Step3: Our data is now accessible by a key value. The keys are the column headers in the dataframe. In this example case,...
10,883
<ASSISTANT_TASK:> Python Code: import pygem as pg params = pg.params.FFDParameters() params.read_parameters(filename='../tests/test_datasets/parameters_test_ffd_iges.prm') iges_handler = pg.igeshandler.IgesHandler() mesh_points = iges_handler.parse('../tests/test_datasets/test_pipe.iges') free_form = pg.freeform.FFD(...
<SYSTEM_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 have to load the iges file on which we will perform the FFD. Since it is an iges we use the IgesHandler() class. The parse method extract...
10,884
<ASSISTANT_TASK:> Python Code: import os, lzma #basedir = os.path.join("/media/disk", "OSM_Data") basedir = os.path.join("e:\\", "OSM_Data") filename = "isle-of-wight-latest.osm.xz" with lzma.open(os.path.join(basedir, filename), mode="rt", encoding="utf-8") as f: print(next(f), end="") print(next(f), end="") ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Look at the generated data Step2: Parse the data in a reduced way Step3: Use xml.etree instead Step4: Via a callback Step5: Convert the call...
10,885
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelBinarizer, StandardScaler from keras.models import Sequential from keras.layers import Dense, Activation, Dropout stats = ...
<SYSTEM_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 preparation Step2: The file Seasons_Stats.csv contains the statics of all players since 1950. First, we drop a couple of blank columns, an...
10,886
<ASSISTANT_TASK:> Python Code: from sklearn.feature_extraction.text import CountVectorizer vectorizer = CountVectorizer(min_df=1) vectorizer.fit([ "The cat sat on the mat.", ]) vectorizer.vocabulary_ X = vectorizer.transform([ "The cat sat on the mat.", "This cat is a nice cat.", ]).toarray() print(len(vec...
<SYSTEM_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 vocabulary is used at transform time to build the occurrence matrix Step2: Let's refit with a slightly larger corpus Step3: The vocabulary...
10,887
<ASSISTANT_TASK:> Python Code: from bsym import SymmetryOperation SymmetryOperation([[ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ]]) SymmetryOperation([[ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ]], label='E' ) e = SymmetryOperation([[ 1, 0, 0 ], ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Each SymmetryOperation has an optional label attribute. This can be set at records the matrix representation of the symmetry operation and an op...
10,888
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import print_function import tellurium as te # to get the tellurium version use print('te.__version__') print(te.__version__) # or print('te.getTelluriumVersion()') print(te.getTelluriumVersion()) # to print the full version info use print('-' * 80) te.p...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Repeat simulation without notification Step3: File helpers for reading and writing
10,889
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from skimage import data, io, segmentation, color from skimage.future import graph %matplotlib inline import requests from PIL import Image from io import StringIO url = 'https://mycarta.files.wordpress.com/2015/04/jet_tight.png' r = 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: Import test image. The colormap is Matlab's Jet Step2: Reduce number of colours Step3: Convert from RGB to HSL, get unique values of H, S, an...
10,890
<ASSISTANT_TASK:> Python Code: from datasets import * from qiskit_aqua.utils import split_dataset_to_data_and_labels from qiskit_aqua.input import get_input_instance from qiskit_aqua import run_algorithm import numpy as np n = 2 # dimension of each data point sample_Total, training_input, test_input, class_labels = 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: Step1: Here we choose the Wine dataset which has 3 classes. Step2: Now we setup an Aqua configuration dictionary to use the classical SVM algorithm an...
10,891
<ASSISTANT_TASK:> Python Code: import rebound sim = rebound.Simulation() sim.add(m=1.) # Star sim.add(m=1e-3, a=1) # Jupiter mass planet sim.move_to_com() sim.integrator = "whfast" sim.dt = sim.particles[1].P/34.5678 # About 30 steps per orbit import reboundx rebx = reboundx.Extras(sim) sto = rebx.load_force("stocha...
<SYSTEM_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 will be using the WHFast integrator with a fixed timestep. It's important to point out that the default IAS15 integrator is not well suited f...
10,892
<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: <table class="tfo-notebook-buttons" align="left"> Step2: Some normal imports we've seen before. Step3: Part 1 Step4: The images in the Dogs v...
10,893
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sn %matplotlib inline nfl_data = pd.read_csv('/home/max/nfl_stats/data/pbp_2009_2015.csv', low_memory=False) #Print (Rows, Columns) of Data print(nfl_data.shape) #Print Variable-Names and First Two Va...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: How cool is this?! Almost any question I can think of regarding NFL play outcomes is suddenly queryable. Although first, we'll clarify exactly w...
10,894
<ASSISTANT_TASK:> Python Code: import os from mpl_toolkits.basemap import Basemap import numpy as np import matplotlib.pyplot as plt %matplotlib inline data_folder = os.path.join('data') file_names = [] for f in os.listdir(data_folder): file_names.append(os.path.join(data_folder,f)) del file_names[file_names.index(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: II- Predictive Analysis Step2: Now, let's find the most popular male and female names of all times Step3: And the winner for most popular male...
10,895
<ASSISTANT_TASK:> Python Code: class Solution: # @param {int} n an integer # @param {int[][]} edges a list of undirected edges # @return {boolean} true if it's a valid tree, or false def validTree(self, n, edges): # Write your code here dic = {i: [] for i in range(n)} for i, j 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: Clone Graph Step2: Search Graph Nodes Step4: Topological Sorting Step6: BFS in Matrix Step7: Zombie in Matrix Step8: Knight Shortest Path
10,896
<ASSISTANT_TASK:> Python Code: # Load library import numpy as np # Create matrix matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) # Create a function that adds 100 to something add_100 = lambda i: i + 100 # Create a vectorized function vectorized_add_100 = np.vectorize(add_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: Create Matrix Step2: Create Vectorized Function Step3: Apply Function To Elements
10,897
<ASSISTANT_TASK:> Python Code: !pip install -r requirements.txt --quiet import os import datetime import numpy as np import pandas as pd import pickle import zipfile import matplotlib.pyplot as plt import seaborn as sns from sklearn.model_selection import train_test_split from sklearn.metrics import confusion_matrix 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: Imports Step2: Set random seed for reproducibility and ignore warning messages. Step3: Download data Step4: Load and preprocess data Step5: ...
10,898
<ASSISTANT_TASK:> Python Code: # install Pint if necessary try: import pint except ImportError: !pip install pint # download modsim.py if necessary from os.path import exists filename = 'modsim.py' if not exists(filename): from urllib.request import urlretrieve url = 'https://raw.githubusercontent.com/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: Yo-yo Step2: The results are Step3: Rmin is the radius of the axle. Rmax is the radius of the axle plus rolled string. Step4: Based on these...
10,899
<ASSISTANT_TASK:> Python Code: def gaussian_model(xaxis, amplitude, offset, width): amplitude = u.Quantity(amplitude, u.K) offset = u.Quantity(offset, u.km/u.s) width = u.Quantity(width, u.km/u.s) return amplitude*np.exp(-(xaxis-offset)**2/(2.*width**2)) from specutils.io import fits spec = fits.rea...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Fitting Tools Step2: astropy.modeling