Unnamed: 0
int64
0
16k
text_prompt
stringlengths
110
62.1k
code_prompt
stringlengths
37
152k
10,500
Given the following text description, write Python code to implement the functionality described below step by step Description: PathMovers This notebook is an introduction to handling PathMover and MoveChange instances. It mostly covers the questions on 1. how to check if a certain mover was part of a change. 2. Wh...
Python Code: import openpathsampling as p Explanation: PathMovers This notebook is an introduction to handling PathMover and MoveChange instances. It mostly covers the questions on 1. how to check if a certain mover was part of a change. 2. What are the possible changes a mover can generate. 3. ... Load OPENPATHSAMPL...
10,501
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright © 2019 The TensorFlow Authors. Step1: TensorFlow Data Validation An Example of a Key TFX Library This example colab notebook illustrates how TensorFlow Data Validation (TFDV)...
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 writing, software # dist...
10,502
Given the following text description, write Python code to implement the functionality described below step by step Description: 2-Dimensional Frame Analysis - Version 04 This program performs an elastic analysis of 2-dimensional structural frames. It has the following features Step1: Test Frame Nodes Step2: Suppor...
Python Code: from __future__ import print_function import salib as sl sl.import_notebooks() from Tables import Table from Nodes import Node from Members import Member from LoadSets import LoadSet, LoadCombination from NodeLoads import makeNodeLoad from MemberLoads import makeMemberLoad from collections import OrderedDi...
10,503
Given the following text description, write Python code to implement the functionality described below step by step Description: .. gps-receivers Step1: Here, we used Step2: As you can see, Step3: Alternatively, we might use the record id field to key our code off a specific type of NMEA message Step4: Another a...
Python Code: # nbconvert: hide from __future__ import absolute_import, division, print_function import sys sys.path.append("../features/steps") import test socket = test.mock_module("socket") path = "../data/gps" client = "172.10.0.20" socket.socket().recvfrom.side_effect = test.recvfrom_file(path=path, client=client, ...
10,504
Given the following text description, write Python code to implement the functionality described below step by step Description: CNTK 103 Part A Step1: Data download We will download the data into local machine. The MNIST database is a standard handwritten digits that has been widely used for training and testing of ...
Python Code: # Import the relevant modules to be used later from __future__ import print_function import gzip import matplotlib.image as mpimg import matplotlib.pyplot as plt import numpy as np import os import shutil import struct import sys try: from urllib.request import urlretrieve except ImportError: fr...
10,505
Given the following text description, write Python code to implement the functionality described below step by step Description: License Copyright (C) 2017 J. Patrick Hall, jphall@gwu.edu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (t...
Python Code: import pandas as pd # pandas for handling mixed data sets import numpy as np # numpy for basic math and matrix operations Explanation: License Copyright (C) 2017 J. Patrick Hall, jphall@gwu.edu Permission is hereby granted, free of charge, to any person obtaining a copy of this ...
10,506
Given the following text description, write Python code to implement the functionality described below step by step Description: Sample weight adjustment The objective of this tutorial is to familiarize ourselves with SampleWeight the samplics class for adjusting sample weights. In practice, it is necessary to adjust ...
Python Code: import numpy as np import pandas as pd import samplics from samplics.datasets import PSUSample, SSUSample from samplics.weighting import SampleWeight Explanation: Sample weight adjustment The objective of this tutorial is to familiarize ourselves with SampleWeight the samplics class for adjusting sample we...
10,507
Given the following text description, write Python code to implement the functionality described below step by step Description: Support Vector Machine SVMs are a set of supervised learning method used for classification, regression and outliers detection 1 Classification SVC, NuSVC and LinearSVC are classes capable o...
Python Code: from sklearn import svm X = [[0,0], [1,1]] y = [0, 1] clf = svm.SVC() clf.fit(X, y) clf.predict([[2,2]]) Explanation: Support Vector Machine SVMs are a set of supervised learning method used for classification, regression and outliers detection 1 Classification SVC, NuSVC and LinearSVC are classes capable ...
10,508
Given the following text description, write Python code to implement the functionality described below step by step Description: JSON examples and exercise get familiar with packages for dealing with JSON study examples with JSON strings and files work on exercise to be completed and submitted reference Step1: impo...
Python Code: import pandas as pd import numpy as np Explanation: JSON examples and exercise get familiar with packages for dealing with JSON study examples with JSON strings and files work on exercise to be completed and submitted reference: http://pandas.pydata.org/pandas-docs/stable/io.html#io-json-reader data sour...
10,509
Given the following text description, write Python code to implement the functionality described below step by step Description: TF-DNNRegressor - SeLU - Spitzer Calibration Data This script show a simple example of using tf.contrib.learn library to create our model. The code is divided in following steps Step1: Load...
Python Code: import pandas as pd import numpy as np import tensorflow as tf tf.logging.set_verbosity(tf.logging.ERROR) import warnings warnings.filterwarnings("ignore") %matplotlib inline from matplotlib import pyplot as plt from sklearn.cross_validation import train_test_split from sklearn.preprocessing import Standar...
10,510
Given the following text description, write Python code to implement the functionality described below step by step Description: $$ \LaTeX \text{ command declarations here.} \newcommand{\R}{\mathbb{R}} \renewcommand{\vec}[1]{\mathbf{#1}} \newcommand{\X}{\mathcal{X}} \newcommand{\D}{\mathcal{D}} \newcommand{\G}{\mathca...
Python Code: import numpy as np parts_of_speech = DETERMINER, NOUN, VERB, END = 0, 1, 2, 3 words = THE, DOG, WALKED, IN, PARK, END = 0, 1, 2, 3, 4, 5 # transition probabilities A = np.array([ # D N V E [0.1, 0.8, 0.1, 0.0], # D: determiner most likely to go to noun [0.1, 0.1, 0.6, 0.2],...
10,511
Given the following text description, write Python code to implement the functionality described below step by step Description: Group Significant GO terms by Frequently Seen Words We use data from a 2014 Nature paper Step1: 2. Count all words in the significant GO term names. 2a. Get list of significant GO term name...
Python Code: %run goea_nbt3102_fncs.ipynb goeaobj = get_goeaobj_nbt3102('fdr_bh') # Read Nature data from Excel file (~400 study genes) studygeneid2symbol = read_data_nbt3102() # Run Gene Ontology Enrichment Analysis using Benjamini/Hochberg FDR correction geneids_study = studygeneid2symbol.keys() goea_results_all = go...
10,512
Given the following text problem statement, write Python code to implement the functionality described below in problem statement Problem: I have a Pandas DataFrame that looks something like:
Problem: import pandas as pd df = pd.DataFrame({'col1': {0: 'a', 1: 'b', 2: 'c'}, 'col2': {0: 1, 1: 3, 2: 5}, 'col3': {0: 2, 1: 4, 2: 6}, 'col4': {0: 3, 1: 6, 2: 2}, 'col5': {0: 7, 1: 2, 2: 3}, 'col6': {0: 2, 1: 9, 2: 5}, ...
10,513
Given the following text description, write Python code to implement the functionality described below step by step Description: ES-DOC CMIP6 Model Properties - Ocnbgchem MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributors Step3: Document Publication Speci...
Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'csir-csiro', 'sandbox-3', 'ocnbgchem') Explanation: ES-DOC CMIP6 Model Properties - Ocnbgchem MIP Era: CMIP6 Institute: CSIR-CSIRO Source ID: SANDBOX-3 Topic: Ocnbgchem Sub-Topics: Tr...
10,514
Given the following text description, write Python code to implement the functionality described below step by step Description: ICPW annual time series At the Task Force meeting in May 2017, it was decided that the TOC trends analysis should include rolling regressions based on the annually aggregated data (rather th...
Python Code: # Data paths clim_xls = (r'C:\Data\James_Work\Staff\Heleen_d_W\ICP_Waters\TOC_Trends_Analysis_2015' r'\CRU_Climate_Data\cru_climate_summaries.xlsx') stn_xls = (r'C:\Data\James_Work\Staff\Heleen_d_W\ICP_Waters\TOC_Trends_Analysis_2015' r'\CRU_Climate_Data\cru_stn_elevs.csv') chem_fold...
10,515
Given the following text description, write Python code to implement the functionality described below step by step Description: ← Back to Index Longest Common Subsequence To motivate dynamic time warping, let's look at a classic dynamic programming problem Step1: Test Step2: The time complexity of the above re...
Python Code: def lcs(x, y): if x == "" or y == "": return "" if x[0] == y[0]: return x[0] + lcs(x[1:], y[1:]) else: z1 = lcs(x[1:], y) z2 = lcs(x, y[1:]) return z1 if len(z1) > len(z2) else z2 Explanation: ← Back to Index Longest Common Subsequence To motivate dy...
10,516
Given the following text description, write Python code to implement the functionality described below step by step Description: QuTiP example Step1: Hamoltonian Step2: Dispersive cQED Model Implementation Step3: The results obtained from the physical implementation agree with the ideal result. Step4: The gates ar...
Python Code: %matplotlib inline import numpy as np from qutip import * from qutip.qip.models.circuitprocessor import * from qutip.qip.models.cqed import * Explanation: QuTiP example: Physical implementation of Cavity-Qubit model Author: Anubhav Vardhan (anubhavvardhan@gmail.com) For more information about QuTiP see htt...
10,517
Given the following text description, write Python code to implement the functionality described below step by step Description: numpynet from sklearn mnist data set works numpynet/classy from digits data set doesn't work trying numpynet with digits data set here works what is the numpynet/classy difference? Step1: c...
Python Code: ''' Little example on how to use the Network class to create a model and perform a basic classification of the MNIST dataset ''' #from NumPyNet.layers.input_layer import Input_layer from NumPyNet.layers.connected_layer import Connected_layer from NumPyNet.layers.convolutional_layer import Convolutional_lay...
10,518
Given the following text problem statement, write Python code to implement the functionality described below in problem statement Problem: I'm using tensorflow 2.10.0.
Problem: import tensorflow as tf x=[b'\xd8\xa8\xd9\x85\xd8\xb3\xd8\xa3\xd9\x84\xd8\xa9', b'\xd8\xa5\xd9\x86\xd8\xb4\xd8\xa7\xd8\xa1', b'\xd9\x82\xd8\xb6\xd8\xa7\xd8\xa1', b'\xd8\xac\xd9\x86\xd8\xa7\xd8\xa6\xd9\x8a', b'\xd8\xaf\xd9\x88\xd9\x84\xd9\x8a'] def g(x): return [tf.compat.as_str_any(a) for a...
10,519
Given the following text description, write Python code to implement the functionality described below step by step Description: <h1 align="center">TensorFlow Neural Network Lab</h1> <img src="image/notmnist.png"> In this lab, you'll use all the tools you learned from Introduction to TensorFlow to label images of Engl...
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 zipfile import ZipFile p...
10,520
Given the following text description, write Python code to implement the functionality described below step by step Description: Examples of many applications with Notebook Launcher This notebook is a quick(ish) test of most of the main applications people use, taken from fastbook, and ran with Accelerate across mult...
Python Code: #|all_slow #|all_multicuda from fastai.vision.all import * from fastai.text.all import * from fastai.tabular.all import * from fastai.collab import * from accelerate import notebook_launcher from fastai.distributed import * Explanation: Examples of many applications with Notebook Launcher This notebook is...
10,521
Given the following text description, write Python code to implement the functionality described below step by step Description: Write your Own Perceptron In our examples, we have seen different algorithms and we could use scikit learn functions to get the paramters. However, do you know how is it implemented? To unde...
Python Code: # import our packages import numpy as np from matplotlib import pyplot as plt %matplotlib inline Explanation: Write your Own Perceptron In our examples, we have seen different algorithms and we could use scikit learn functions to get the paramters. However, do you know how is it implemented? To understand ...
10,522
Given the following text description, write Python code to implement the functionality described below step by step Description: Using Cytoscape.js in Jupyter Notebook by Keiichiro Ono Introduction If you use Jupyetr Notebook with cyREST, you can script your workflow. And in some cases, you may want to embed the resu...
Python Code: # Package to render networks in Cytoscape.js from py2cytoscape import cytoscapejs as cyjs # And standard JSON utility import json Explanation: Using Cytoscape.js in Jupyter Notebook by Keiichiro Ono Introduction If you use Jupyetr Notebook with cyREST, you can script your workflow. And in some cases, you ...
10,523
Given the following text description, write Python code to implement the functionality described below step by step Description: Release of hammer-cli gem Requirements push access to https Step1: Update the following notebook settings Step2: Ensure the repo is up to date Step3: Run tests localy Step4: Update relea...
Python Code: %cd .. Explanation: Release of hammer-cli gem Requirements push access to https://github.com/theforeman/hammer-cli push access to rubygems.org for hammer-cli sudo yum install transifex-client python-slugify asciidoc ensure neither the git push or gem push don't require interractive auth. If you can't use a...
10,524
Given the following text description, write Python code to implement the functionality described below step by step Description: Playback Using the Notebook Audio Widget This interface is used often when developing algorithms that involve processing signal samples that result in audible sounds. You will see this in th...
Python Code: Audio('c_major.wav') Explanation: Playback Using the Notebook Audio Widget This interface is used often when developing algorithms that involve processing signal samples that result in audible sounds. You will see this in the tutorial. Processing is done before hand as an analysis task, then the samples ar...
10,525
Given the following text description, write Python code to implement the functionality described below step by step Description: Introduction One of the comments by our manuscript reviewers was on our claim of the 2009 H1N1 and 2013 H7N9 viruses. In order to substantiate our claim of recapitulating their lineages, I w...
Python Code: import networkx as nx import matplotlib.pyplot as plt import numpy as np import pandas as pd import json from collections import defaultdict from datetime import datetime, date from random import randint from networkx.readwrite.json_graph import node_link_data %matplotlib inline G = nx.read_gpickle('201509...
10,526
Given the following text description, write Python code to implement the functionality described below step by step Description: The python-awips package provides access to the entire AWIPS Maps Database for use in Python GIS applications. Map objects are returned as <a href="http Step1: Request County Boundaries fo...
Python Code: from __future__ import print_function from awips.dataaccess import DataAccessLayer import matplotlib.pyplot as plt import cartopy.crs as ccrs import numpy as np from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER from cartopy.feature import ShapelyFeature,NaturalEarthFeature from shap...
10,527
Given the following text description, write Python code to implement the functionality described below step by step Description: Multi-Layer Perceptron Inpainting with MNIST In the MLP demo, we saw how to use the multi-layer VAMP (ML-VAMP) method for denoising with a prior based on a multi-layer perceptron. We illust...
Python Code: # Add the vampyre path to the system path import os import sys vp_path = os.path.abspath('../../') if not vp_path in sys.path: sys.path.append(vp_path) import vampyre as vp # Load the other packages import numpy as np import matplotlib import matplotlib.pyplot as plt %matplotlib inline Explanation: Mul...
10,528
Given the following text description, write Python code to implement the functionality described below step by step Description: BigQuery Pipeline Google Cloud Datalab, with the pipeline subcommand, enables productionizing (i.e. scheduling and orchestrating) notebooks that accomplish ETL with BigQuery and GCS. It uses...
Python Code: import datetime import google.datalab.bigquery as bq import google.datalab.contrib.bigquery.commands import google.datalab.contrib.pipeline.airflow import google.datalab.contrib.pipeline.composer import google.datalab.kernel import google.datalab.storage as storage from google.datalab import Context projec...
10,529
Given the following text description, write Python code to implement the functionality described below step by step Description: Analysis of U.S. Incomes by Occupation and Gender Notebook by Harish Kesava Rao Use of this dataset should cite the Bureau of Labor Statistics as per their copyright information Step1: We a...
Python Code: import pandas as pd from pandas import DataFrame, Series Explanation: Analysis of U.S. Incomes by Occupation and Gender Notebook by Harish Kesava Rao Use of this dataset should cite the Bureau of Labor Statistics as per their copyright information: The Bureau of Labor Statistics (BLS) is a Federal governme...
10,530
Given the following text description, write Python code to implement the functionality described below step by step Description: Exploratory Data Analysis Author Step1: The first three lines of code import libraries we are using and renames to shorter names. Matplotlib is a python 2D plotting library which produces p...
Python Code: import matplotlib.pyplot as plt import numpy as np import pandas as pd %matplotlib inline anscombe_i = pd.read_csv('../datasets/anscombe_i.csv') anscombe_ii = pd.read_csv('../datasets/anscombe_ii.csv') anscombe_iii = pd.read_csv('../datasets/anscombe_iii.csv') anscombe_iv = pd.read_csv('../datasets/anscomb...
10,531
Given the following text description, write Python code to implement the functionality described below step by step Description: New Term Topics Methods and Document Coloring Step1: We're setting up our corpus now. We want to show off the new get_term_topics and get_document_topics functionalities, and a good way to ...
Python Code: from gensim.corpora import Dictionary from gensim.models import ldamodel import numpy %matplotlib inline Explanation: New Term Topics Methods and Document Coloring End of explanation texts = [['bank','river','shore','water'], ['river','water','flow','fast','tree'], ['bank','water','fall','f...
10,532
Given the following text description, write Python code to implement the functionality described below step by step Description: Using SGD on MNIST Background ... about machine learning (a reminder from lesson 1) The good news is that modern machine learning can be distilled down to a couple of key techniques that are...
Python Code: %load_ext autoreload %autoreload 2 %matplotlib inline from fastai.imports import * from fastai.torch_imports import * from fastai.io import * path = 'data/mnist/' Explanation: Using SGD on MNIST Background ... about machine learning (a reminder from lesson 1) The good news is that modern machine learning c...
10,533
Given the following text description, write Python code to implement the functionality described below step by step Description: Advanced Logistic Regression in TensorFlow 2.0 Learning Objectives Load a CSV file using Pandas Create train, validation, and test sets Define and train a model using Keras (including settin...
Python Code: # You can use any Python source file as a module by executing an import statement in some other Python source file. # The import statement combines two operations; it searches for the named module, then it binds the # results of that search to a name in the local scope. import tensorflow as tf from tensorf...
10,534
Given the following text description, write Python code to implement the functionality described below step by step Description: Considering Outliers and Novelty Detection Step1: Finding more things that can go wrong with your data Understanding the difference between anomalies and novel data Examining a Fast and Sim...
Python Code: import numpy as np from scipy.stats.stats import pearsonr np.random.seed(101) normal = np.random.normal(loc=0.0, scale= 1.0, size=1000) print 'Mean: %0.3f Median: %0.3f Variance: %0.3f' % (np.mean(normal), np.median(normal), np.var(normal)) outlying = normal.copy() outlying[0] = 50.0 print 'Mean: %0.3f Med...
10,535
Given the following text description, write Python code to implement the functionality described below step by step Description: Connect to Source and test connection Using 4 instances Step1: Enumerate the parameter combinations Step2: Specify the model changes (Much like we do when setting up a PEST job) Step3: Sp...
Python Code: ## Veneer started elsewhere (probably from a command line using veneer.manager.start) ports = list(range(15004,15008)) ports bv = BulkVeneer(ports) v = bv.veneers[1] network = v.network() network.as_dataframe().plot() network.outlet_nodes() outlet_node = network.outlet_nodes()[0]['properties']['name'] + '$...
10,536
Given the following text description, write Python code to implement the functionality described below step by step Description: t-SNE Tutorial Step1: Zklastrowane punkty w 2D Działanie t-SNE na dwóch oddalonych od siebie klastrach punktów w 2D Zadanie 1 Napisz funkcję, która pokaże punkty ze zbioru przed oraz po tra...
Python Code: import numpy as np import scipy import sklearn import matplotlib.pyplot as plt from functions import * from sklearn import manifold, datasets from sklearn.manifold import TSNE Explanation: t-SNE Tutorial End of explanation def plot_2D_cluster(cluster_size, perplexity): pass Explanation: Zklastrowane pu...
10,537
Given the following text description, write Python code to implement the functionality described below step by step Description: Finding Lane Lines on the Road In this project, I will use the OpenCV & Python to identify lane lines on the road. Firstly, I can develop the pipeline on a series of individual images, and l...
Python Code: #importing some useful packages import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np import cv2 %matplotlib inline import math Explanation: Finding Lane Lines on the Road In this project, I will use the OpenCV & Python to identify lane lines on the road. Firstly, I can develo...
10,538
Given the following text description, write Python code to implement the functionality described below step by step Description: Multivariate Regression Let's grab a small little data set of Blue Book car values Step1: We can use pandas to split up this matrix into the feature vectors we're interested in, and the val...
Python Code: import pandas as pd df = pd.read_excel('http://cdn.sundog-soft.com/Udemy/DataScience/cars.xls') df.head() Explanation: Multivariate Regression Let's grab a small little data set of Blue Book car values: End of explanation import statsmodels.api as sm df['Model_ord'] = pd.Categorical(df.Model).codes X = df[...
10,539
Given the following text description, write Python code to implement the functionality described below step by step Description: Step1: Modular neural nets In the previous HW, we computed the loss and gradient for a two-layer neural network in a single monolithic function. This isn't very difficult for a small two-lay...
Python Code: # As usual, a bit of setup import numpy as np import matplotlib.pyplot as plt from cs231n.gradient_check import eval_numerical_gradient_array, eval_numerical_gradient from cs231n.layers import * %matplotlib inline plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots plt.rcParams['image....
10,540
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright 2020 The TensorFlow Authors. Step1: TF Lattice Aggregate Function Models <table class="tfo-notebook-buttons" align="left"> <td> <a target="_blank" href="https Step2: Import...
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 writing, software # dist...
10,541
Given the following text description, write Python code to implement the functionality described below step by step Description: Built-In Data Structures Python also has several built-in compound types, which act as containers for other types. | Type Name | Example |Description ...
Python Code: a = [2, 3, 5, 7] Explanation: Built-In Data Structures Python also has several built-in compound types, which act as containers for other types. | Type Name | Example |Description | |-----------|---------------------------|---------------------------------------...
10,542
Given the following text description, write Python code to implement the functionality described below step by step Description: AMICI documentation example of the steady state solver logic This is an example to document the internal logic of the steady state solver, which is used in preequilibration and postequilibra...
Python Code: from IPython.display import Image fig = Image(filename=('../../../documentation/gfx/steadystate_solver_workflow.png')) fig Explanation: AMICI documentation example of the steady state solver logic This is an example to document the internal logic of the steady state solver, which is used in preequilibratio...
10,543
Given the following text description, write Python code to implement the functionality described below step by step Description: Training a better model Step1: Are we underfitting? Our validation accuracy so far has generally been higher than our training accuracy. That leads to two obvious questions Step2: ...and l...
Python Code: from theano.sandbox import cuda %matplotlib inline from imp import reload import utils; reload(utils) from utils import * from __future__ import division, print_function #path = "data/dogscats/sample/" path = "data/dogscats/" model_path = path + 'models/' if not os.path.exists(model_path): os.mkdir(model_...
10,544
Given the following text description, write Python code to implement the functionality described below step by step Description: Introduction to Graph Convolutions In this tutorial we will learn more about "graph convolutions." These are one of the most powerful deep learning tools for working with molecular data. The...
Python Code: !pip install --pre deepchem Explanation: Introduction to Graph Convolutions In this tutorial we will learn more about "graph convolutions." These are one of the most powerful deep learning tools for working with molecular data. The reason for this is that molecules can be naturally viewed as graphs. Note h...
10,545
Given the following text description, write Python code to implement the functionality described below step by step Description: <h1>Training on Cloud AI Platform</h1> This notebook illustrates distributed training on Cloud AI Platform (formerly known as Cloud ML Engine). Step1: Now that we have the TensorFlow code w...
Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst # Ensure the right version of Tensorflow is installed. !pip freeze | grep tensorflow==2.1 # change these to try this notebook out BUCKET = 'cloud-training-demos-ml' PROJECT = 'cloud-training-demos' REGION = 'us-central1' import os os.enviro...
10,546
Given the following text description, write Python code to implement the functionality described below step by step Description: Self-Driving Car Engineer Nanodegree Deep Learning Project Step1: Step 1 Step2: Include an exploratory visualization of the dataset Visualize the German Traffic Signs Dataset using the pic...
Python Code: # Load pickled data import pickle # TODO: Fill this in based on where you saved the training and testing data training_file = ? validation_file=? testing_file = ? with open(training_file, mode='rb') as f: train = pickle.load(f) with open(validation_file, mode='rb') as f: valid = pickle.load(f) with...
10,547
Given the following text description, write Python code to implement the functionality described below step by step Description: Chemicals in Cosmetics - Data Bootcamp Report Manuela Lopez Giraldo May 12, 2017 Report Outline Step1: To extract exact figures for current products, it would be best to clean up the datase...
Python Code: import pandas as pd import matplotlib.pyplot as plt import numpy as np import datetime as dt %matplotlib inline import matplotlib as mpl import sys url = 'https://chhs.data.ca.gov/api/views/7kri-yb7t/rows.csv?accessType=DOWNLOAD' CosmeticsData = pd.read_csv(url) CosmeticsData.head() Explanation: Chemicals ...
10,548
Given the following text description, write Python code to implement the functionality described below step by step Description: Implementing a basic neural network By Brett Naul (UC Berkeley) In this exercise we'll implement and train a simple single-layer neural network classifier using numpy. First, let's create so...
Python Code: # Imports / plotting configuration import numpy as np %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns sns.set_context('poster') plt.rcParams['image.interpolation'] = 'nearest' # hard classification boundaries plt.rcParams['image.cmap'] = 'viridis' np.random.seed(13) # Generate spi...
10,549
Given the following text description, write Python code to implement the functionality described below step by step Description: 練習 Theano 的 Scan Function Step1: 撰寫一個 A 的 K 次計算函式 [0 1 2 3 4 5 6 7 8 9 ] >>> [ 0. 1. 4. 9. 16. 25. 36. 49. 64. 81.] k 為 integer ,代表多少次方 a 為 底 Step2: result 為用 tensor 來接 updat...
Python Code: import theano import theano.tensor as T Explanation: 練習 Theano 的 Scan Function End of explanation k = T.iscalar('K') a = T.vector('A') i = T.vector('A') result, updates = theano.scan(fn=lambda pre , k : pre*a , outputs_info = i, non_sequences=a, ...
10,550
Given the following text description, write Python code to implement the functionality described below step by step Description: Reading SETI Hackathon Data This tutorial will show you how to programmatically download the SETI code challenge data to your local file space and start to analyze it. Please see the Step_1...
Python Code: #The ibmseti package contains some useful tools to faciliate reading the data. #The `ibmseti` package version 1.0.5 works on Python 2.7. # !pip install --user ibmseti #A development version runs on Python 3.5. # !pip install --user ibmseti==2.0.0.dev5 # If running on DSX, YOU WILL NEED TO RESTART YOUR ...
10,551
Given the following text description, write Python code to implement the functionality described below step by step Description: Comparing initial sampling methods on integer space Holger Nahrstaedt 2020 Sigurd Carlsen October 2019 .. currentmodule Step1: Random sampling Step2: Sobol Step3: Classic latin hypercube ...
Python Code: print(__doc__) import numpy as np np.random.seed(1234) import matplotlib.pyplot as plt from skopt.space import Space from skopt.sampler import Sobol from skopt.sampler import Lhs from skopt.sampler import Halton from skopt.sampler import Hammersly from skopt.sampler import Grid from scipy.spatial.distance ...
10,552
Given the following text description, write Python code to implement the functionality described below step by step Description: Representing text as numerical data From the scikit-learn documentation Step1: From the scikit-learn documentation Step2: From the scikit-learn documentation Step3: In order to make a pre...
Python Code: # example text for model training (SMS messages) simple_train = ['call you tonight', 'Call me a cab', 'please call me... PLEASE!'] # import and instantiate CountVectorizer (with the default parameters) from sklearn.feature_extraction.text import CountVectorizer vect = CountVectorizer() # learn the 'vocabul...
10,553
Given the following text description, write Python code to implement the functionality described below step by step Description: CIFAR10 classification using HOG features Load CIFAR10 dataset Step1: Preprocessing Step2: Lets look how images looks like Step3: Feature extraction We use HOG descriptor from scikit-imag...
Python Code: import myutils raw_data_training, raw_data_testing = myutils.load_CIFAR_dataset(shuffle=False) # raw_data_training = raw_data_training[:5000] class_names = myutils.load_CIFAR_classnames() n_training = len( raw_data_training ) n_testing = len( raw_data_testing ) print('Loaded CIFAR10 database with {} traini...
10,554
Given the following text description, write Python code to implement the functionality described below step by step Description: Numerical Integration Preliminaries We have to import the array library numpy and the plotting library matplotlib.pyplot, note that we define shorter aliases for these. Next we import from n...
Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt from numpy import cos, exp, pi, sin, sqrt from IPython.display import Latex, display plt.style.use(['fivethirtyeight', './00_mplrc']) Explanation: Numerical Integration Preliminaries We have to import the array library numpy and the plo...
10,555
Given the following text description, write Python code to implement the functionality described below step by step Description: Ordinary Differential Equations Step1: Part 1
Python Code: # Setup %matplotlib inline import numpy as np import matplotlib.pyplot as plt from scipy.integrate import odeint # Setup f0 = 1. omega0 = 2. * np.pi * f0 a = 1. Explanation: Ordinary Differential Equations : Practical work on the harmonic oscillator In this example, you will simulate an harmonic o...
10,556
Given the following text description, write Python code to implement the functionality described below step by step Description: Modelos de Classificação Este laboratório irá cobrir os passos para tratar a base de dados de taxa de cliques (click-through rate - CTR) e criar um modelo de classificação para tentar determ...
Python Code: # Data for manual OHE # Note: the first data point does not include any value for the optional third feature #from pyspark import SparkContext #sc =SparkContext() sampleOne = [(0, 'mouse'), (1, 'black')] sampleTwo = [(0, 'cat'), (1, 'tabby'), (2, 'mouse')] sampleThree = [(0, 'bear'), (1, 'black'), (2, 'sa...
10,557
Given the following text description, write Python code to implement the functionality described below step by step Description: Random Basis Functions Test In this notebook we test our random basis functions against the kernel functions they are designed to approximate. This is a qualitative test in that we just plot...
Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as pl from revrand.basis_functions import RandomRBF, RandomLaplace, RandomCauchy, RandomMatern32, RandomMatern52, \ FastFoodRBF, OrthogonalRBF, FastFoodGM, BasisCat from revrand import Parameter, Positive # Style pl.style.use('ggplot') pl.r...
10,558
Given the following text description, write Python code to implement the functionality described below step by step Description: Equation for Neuron Paper A dendritic segment can robustly classify a pattern by subsampling a small number of cells from a larger population. Assuming a random distribution of patterns, ...
Python Code: oxp = Symbol("Omega_x'") b = Symbol("b") n = Symbol("n") theta = Symbol("theta") s = Symbol("s") a = Symbol("a") subsampledOmega = (binomial(s, b) * binomial(n - s, a - b)) / binomial(n, a) subsampledFpF = Sum(subsampledOmega, (b, theta, s)) subsampledOmegaSlow = (binomial(s, b) * binomial(n - s, a - b)) ...
10,559
Given the following text description, write Python code to implement the functionality described below step by step Description: Binary with Spots Setup Let's first make sure we have the latest version of PHOEBE 2.0 installed. (You can comment out this line if you don't use pip for your installation or don't want to u...
Python Code: !pip install -I "phoebe>=2.0,<2.1" Explanation: Binary with Spots Setup Let's first make sure we have the latest version of PHOEBE 2.0 installed. (You can comment out this line if you don't use pip for your installation or don't want to update to the latest release). End of explanation %matplotlib inline i...
10,560
Given the following text description, write Python code to implement the functionality described below step by step Description: Übungsblatt 11 Präsenzaufgaben Aufgabe 1 &nbsp;&nbsp;&nbsp; Grammatikinduktion In dieser Aufgabe soll vollautomatisch aus Daten (Syntaxbäumen) eine probabilistische, kontextfreie Grammatik e...
Python Code: test_sentences = [ "the men saw a car .", "the woman gave the man a book .", "she gave a book to the man .", "yesterday , all my trouble seemed so far away ." ] import nltk from nltk.corpus import treebank from nltk.grammar import ProbabilisticProduction, PCFG # Production count: the number...
10,561
Given the following text description, write Python code to implement the functionality described below step by step Description: A Simple Autoencoder We'll start off by building a simple autoencoder to compress the MNIST dataset. With autoencoders, we pass input data through an encoder that makes a compressed represen...
Python Code: %matplotlib inline import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', validation_size=0) Explanation: A Simple Autoencoder We'll start off by building a simple autoencoder to c...
10,562
Given the following text description, write Python code to implement the functionality described below step by step Description: Predicting Movie Review Sentiment with BERT on TF Hub If you’ve been following Natural Language Processing over the past year, you’ve probably heard of BERT Step1: In addition to the standa...
Python Code: from sklearn.model_selection import train_test_split import pandas as pd import tensorflow as tf import tensorflow_hub as hub from datetime import datetime Explanation: Predicting Movie Review Sentiment with BERT on TF Hub If you’ve been following Natural Language Processing over the past year, you’ve prob...
10,563
Given the following text description, write Python code to implement the functionality described below step by step Description: ES-DOC CMIP6 Model Properties - Toplevel MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributors Step3: Document Publication Specif...
Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'csiro-bom', 'sandbox-3', 'toplevel') Explanation: ES-DOC CMIP6 Model Properties - Toplevel MIP Era: CMIP6 Institute: CSIRO-BOM Source ID: SANDBOX-3 Sub-Topics: Radiative Forcings. Pr...
10,564
Given the following text description, write Python code to implement the functionality described below step by step Description: Review Before we start let's do some quick review from last time. Let's create a new numpy arrray. Fill it with any values you want. Let's say I want to calculate the average between the 1s...
Python Code: k = np.array([1,3,5,5,6,6,7,10,23123123,31232]) # create a new array k k[1] k[0] k[4] k[10] # even though the list has 9 items, the index actually goes from 0 to 9 k[9] Explanation: Review Before we start let's do some quick review from last time. Let's create a new numpy arrray. Fill it with any values ...
10,565
Given the following text description, write Python code to implement the functionality described below step by step Description: The Truck Fleet puzzle This tutorial includes everything you need to set up decision optimization engines, build constraint programming models. When you finish this tutorial, you'll have a f...
Python Code: from sys import stdout try: import docplex.cp except: if hasattr(sys, 'real_prefix'): #we are in a virtual env. !pip install docplex else: !pip install --user docplex Explanation: The Truck Fleet puzzle This tutorial includes everything you need to set up decision optimi...
10,566
Given the following text description, write Python code to implement the functionality described below step by step Description: Vertex AI Pipelines Step1: Install the latest GA version of google-cloud-storage library as well. Step2: Install the latest GA version of google-cloud-pipeline-components library as well. ...
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 Explanation: Vertex AI Pipelines: AutoML tabular regression pipelines using google-cloud-pipeline-comp...
10,567
Given the following text description, write Python code to implement the functionality described below step by step Description: Translate dataset The main language of the project is English Step1: New names are based on the "Nome do Dado" column of the table available at data/2016-08-08-datasets-format.html, not "El...
Python Code: import pandas as pd data = pd.read_csv('../data/2016-08-08-AnoAtual.csv') data.shape data.head() data.iloc[0] Explanation: Translate dataset The main language of the project is English: works well mixed in programming languages like Python and provides a low barrier for non-Brazilian contributors. Today, t...
10,568
Given the following text description, write Python code to implement the functionality described. Description: Finding Quadrant of a Coordinate with respect to a Circle Python3 Program to find the quadrant of a given coordinate w . rt . the centre of a circle ; Thus function returns the quadrant number ; Coincides with...
Python Code: import math def getQuadrant(X , Y , R , PX , PY ) : if(PX == X and PY == Y ) : return 0 ;  val =(math . pow(( PX - X ) , 2 ) + math . pow(( PY - Y ) , 2 ) ) ; if(val > pow(R , 2 ) ) : return - 1 ;  if(PX > X and PY >= Y ) : return 1 ;  if(PX <= X and PY > Y ) : return 2 ;  if...
10,569
Given the following text description, write Python code to implement the functionality described below step by step Description: CSCS530 Winter 2016 Complex Systems 530 - Computer Modeling of Complex Systems (Winter 2016) Course ID Step1: Initializing a network In some problems, we can define our own rules to "grow" ...
Python Code: %matplotlib inline # Imports import networkx as nx import numpy import matplotlib.pyplot as plt import pandas import seaborn; seaborn.set() seaborn.set_style("darkgrid") # Import widget methods from IPython.html.widgets import * Explanation: CSCS530 Winter 2016 Complex Systems 530 - Computer Modeling of Co...
10,570
Given the following text description, write Python code to implement the functionality described below step by step Description: Single Station Analysis - Historic Building on the API Exploration Notebook and the Filtering Observed Arrivals notebook. Let's explore a different approach for analyzing the data. Note that...
Python Code: import datetime from psycopg2 import connect import configparser import pandas as pd import pandas.io.sql as pandasql import numpy as np import matplotlib import matplotlib.pyplot as plt from matplotlib.widgets import Slider %matplotlib qt try: con.close() except: print("No existing connection... ...
10,571
Given the following text description, write Python code to implement the functionality described below step by step Description: Gauss integration of Finite Elements Step1: Predefinition The constitutive model tensor in Voigt notation (plane strain) is $$C = \frac{(1 - \nu) E}{(1 - 2\nu) (1 + \nu) } \begin{pmatrix} 1...
Python Code: from __future__ import division from sympy.utilities.codegen import codegen from sympy import * from sympy import init_printing from IPython.display import Image init_printing() r, s, t, x, y, z = symbols('r s t x y z') k, m, n = symbols('k m n', integer=True) rho, nu, E = symbols('rho, nu, E') Explanatio...
10,572
Given the following text description, write Python code to implement the functionality described below step by step Description: <table align="left"> <td> <a href="https Step1: Restart the kernel After you install the additional packages, you need to restart the notebook kernel so it can find the packages. Step...
Python Code: import sys if "google.colab" in sys.modules: USER_FLAG = "" else: USER_FLAG = "--user" ! pip3 install -U tensorflow==2.8 $USER_FLAG ! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG Explanation: <table align="left"> <td> <a href="https://colab.research.google.com/github/GoogleCloudP...
10,573
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright 2019 The TensorFlow Authors. Step1: Estimators <table class="tfo-notebook-buttons" align="left"> <td> <a target="_blank" href="https Step2: Advantages Similar to a tf.keras...
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 writing, software # dist...
10,574
Given the following text description, write Python code to implement the functionality described below step by step Description: BayesSearchCV skopt pip3 install scikit-optimize BayesSearchCV implements a "fit" and a "score" method. It also implements "predict", "predict_proba", "decision_function", "transform" and "i...
Python Code: import pandas as pd import numpy as np import xgboost as xgb import lightgbm as lgb from skopt import BayesSearchCV from sklearn.model_selection import StratifiedKFold, KFold %config InlineBackend.figure_format = 'retina' ITERATIONS = 10 # 1000 TRAINING_SIZE = 100000 # 20000000 TEST_SIZE = 25000 # Load dat...
10,575
Given the following text description, write Python code to implement the functionality described below step by step Description: NNabla by Examples This tutorial demonstrates how you can write a script to train a neural network by using a simple hand digits classification task. Note Step1: The tiny_digits module is l...
Python Code: !pip install nnabla-ext-cuda100 !git clone https://github.com/sony/nnabla.git %cd nnabla/tutorial import nnabla as nn import nnabla.functions as F import nnabla.parametric_functions as PF import nnabla.solvers as S from nnabla.monitor import tile_images import numpy as np import matplotlib.pyplot as plt im...
10,576
Given the following text description, write Python code to implement the functionality described below step by step Description: Using a single Table vs EArray + Table The PyTables community keep asking what can be considered a FAQ. Namely, should I use a single Table for storing my data, or should I split it in a Ta...
Python Code: import numpy as np import tables tables.print_versions() LEN_PMT = int(1.2e6) NPMTS = 12 NEVENTS = 10 !rm PMT*.h5 def gaussian(x, mu, sig): return np.exp(-np.power(x - mu, 2.) / (2 * np.power(sig, 2.))) x = np.linspace(0, 1, 1e7) rd = (gaussian(x, 1, 1.) * 1e6).astype(np.int32) def raw_data(length): ...
10,577
Given the following text description, write Python code to implement the functionality described below step by step Description: Exploratory data analysis Step1: Changes in fatal accidents following legalization? One interesting source of exogenous variation Colorado and Washington's legalization of cannabis in 2014....
Python Code: sb.factorplot(x='HOUR',y='ST_CASE',hue='WEEKDAY',data=counts_df, aspect=2,order=range(24),palette='nipy_spectral',dodge=.5) sb.factorplot(x='MONTH',y='ST_CASE',hue='WEEKDAY',data=counts_df, aspect=2,order=range(1,13),palette='nipy_spectral',dodge=.5) Explanation: Exploratory dat...
10,578
Given the following text description, write Python code to implement the functionality described below step by step Description: How to traverse to GO parents and ancestors Traverse immediate parents or all ancestors with or without user-specified optional relationships Parents and Ancestors described Code to get Pare...
Python Code: import os from goatools.obo_parser import GODag # Load a small test GO DAG and all the optional relationships, # like 'regulates' and 'part_of' godag = GODag('../tests/data/i126/viral_gene_silence.obo', optional_attrs={'relationship'}) Explanation: How to traverse to GO parents and ancestors ...
10,579
Given the following text description, write Python code to implement the functionality described below step by step Description: solarposition.py tutorial This tutorial needs your help to make it better! Table of contents Step1: SPA output Step2: Speed tests Step3: This numba test will only work properly if you hav...
Python Code: import datetime # scientific python add-ons import numpy as np import pandas as pd # plotting stuff # first line makes the plots appear in the notebook %matplotlib inline import matplotlib.pyplot as plt # seaborn makes your plots look better try: import seaborn as sns sns.set(rc={"figure.figsize":...
10,580
Given the following text description, write Python code to implement the functionality described below step by step Description: Ordinary Differential Equations Exercise 1 Imports Step2: Lorenz system The Lorenz system is one of the earliest studied examples of a system of differential equations that exhibits chaotic...
Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from scipy.integrate import odeint from IPython.html.widgets import interact, fixed Explanation: Ordinary Differential Equations Exercise 1 Imports End of explanation def lorentz_derivs(yvec, t, sigma, rho, beta): Compute the the der...
10,581
Given the following text description, write Python code to implement the functionality described below step by step Description: Statistics for Hackers An Exploration of Statistics Through Computational Simulation A talk by Jake VanDerPlas for PyCon 2016 Slides available on speakerdeck Motivation There's no shortage o...
Python Code: import numpy as np import matplotlib.pyplot as plt import pandas as pd import seaborn as sns # Suppress all warnings just to keep the notebook nice and clean. # This must happen after all imports since numpy actually adds its # RankWarning class back in. import warnings warnings.filterwarnings("ignore") #...
10,582
Given the following text description, write Python code to implement the functionality described below step by step Description: Copyright 2020 The TensorFlow Authors. Step1: TFL 레이어로 Keras 모델 만들기 <table class="tfo-notebook-buttons" align="left"> <td><a target="_blank" href="https Step2: 필수 패키지 가져오기 Step3: UCI St...
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 writing, software # dist...
10,583
Given the following text description, write Python code to implement the functionality described below step by step Description: Create Bilayer Topology with Stitch OpenPNM includes numerous tools for manipulating and altering the topology. Most of these are found in the topotools submodule. This example will illustr...
Python Code: import scipy as sp import matplotlib.pyplot as plt %matplotlib inline # Import OpenPNM and the topotools submodule and initialize the workspace manager import openpnm as op from openpnm import topotools as tt wrk = op.Workspace() wrk.clear() # Clear the existing workspace (mostly for testing purposes) wrk...
10,584
Given the following text description, write Python code to implement the functionality described below step by step Description: Create enriched movie dataset from The Movie Database API MovieLens latest data can be downloaded at http Step1: Generate random names for each unique user and save to ES Step2: Enrich mov...
Python Code: from pyspark.sql.functions import udf, col from pyspark.sql.types import * ms_ts = udf(lambda x: int(x) * 1000, LongType()) import csv from pyspark.sql.types import * with open("data/ml-latest-small/ratings.csv") as f: reader = csv.reader(f) cols = reader.next() ratings = [l for l in reader] ra...
10,585
Given the following text description, write Python code to implement the functionality described below step by step Description: SymPy Step1: <h2>Elementary operations</h2> Step2: <h2>Algebra<h2> Step3: <h2>Calculus</h2> Step5: Illustrating Taylor series We will define a function to compute the Taylor series expan...
Python Code: from IPython.display import display from sympy.interactive import printing printing.init_printing(use_latex='mathjax') from __future__ import division import sympy as sym from sympy import * x, y, z = symbols("x y z") k, m, n = symbols("k m n", integer=True) f, g, h = map(Function, 'fgh') Explanation: SymP...
10,586
Given the following text description, write Python code to implement the functionality described below step by step Description: <a href="http Step1: Now we create a 5 by 5 grid with a spacing (dx and dy) of 1. We also create an elevation field with value of 1. everywhere, except at the outlet, where the elevation is...
Python Code: from landlab import RasterModelGrid import numpy as np Explanation: <a href="http://landlab.github.io"><img style="float: left" src="../../landlab_header.png"></a> Setting watershed boundary conditions on a raster grid This tutorial ilustrates how to set watershed boundary conditions on a raster grid. Note...
10,587
Given the following text description, write Python code to implement the functionality described below step by step Description: Analysis of the input data What is typical customer/fraudster behavior? Which type of aggregated information could be useful for the simulator? Where are structural differences between fraud...
Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import matplotlib from datetime import datetime, timedelta import utils_data from os.path import join from IPython.display import display dates_2016 = [datetime(2016, 1, 1) + timedelta(days=i) for i in range(366)] Explanation: Analysis ...
10,588
Given the following text description, write Python code to implement the functionality described below step by step Description: Outline Glossary 1. Radio Science using Interferometric Arrays Previous Step1: Import section specific modules Step2: 1.10 The Limits of Single Dish Astronomy In the previous section &#1...
Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline from IPython.display import HTML HTML('../style/course.css') #apply general CSS Explanation: Outline Glossary 1. Radio Science using Interferometric Arrays Previous: 1.9 A brief introduction to interferometry Next: 1.11 Modern Interfe...
10,589
Given the following text description, write Python code to implement the functionality described below step by step Description: Some very basic python Showing some very basic python, variables, arrays, math and plotting Step1: Python versions Python2 and Python3 are still being used today. So safeguard printing betw...
Python Code: # setting a variable a = 1.23 # just writing the variable will show it's value, but this is not the recommended # way, because per cell only the last one will be printed and stored in the out[] # list that the notebook maintains a a+1 # the right way to print is using the official **print** function in...
10,590
Given the following text description, write Python code to implement the functionality described below step by step Description: Práctica 1 - Introducción a Jupyter lab y libreria robots Introducción a la libreria robots y sus simuladores Recordando los resultados obtenidos en el documento anterior, tenemos que Step1:...
Python Code: def f(x, t): # Se importan funciones matematicas necesarias from numpy import cos # Se desenvuelven las variables que componen al estado q1, q̇1 = x # Se definen constantes del sistema g = 9.81 m1, J1 = 0.3, 0.0005 l1 = 0.2 τ1 = 0 # Se calculan las variables a d...
10,591
Given the following text description, write Python code to implement the functionality described below step by step Description: Multiple Kernel Learning By Saurabh Mahindre - <a href="https Step1: Introduction <em>Multiple kernel learning</em> (MKL) is about using a combined kernel i.e. a kernel consisting of a line...
Python Code: %pylab inline %matplotlib inline import os SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data') # import all shogun classes import shogun as sg from shogun import * Explanation: Multiple Kernel Learning By Saurabh Mahindre - <a href="https://github.com/Saurabh7">github.com/Saurabh7</a> This notebo...
10,592
Given the following text description, write Python code to implement the functionality described below step by step Description: 1A.e - TD noté, 27 novembre 2012 (éléments de code pour le coloriage) Coloriage d'une image, dessin d'une spirale avec matplotlib Step1: construction de la spirale On utilise une représent...
Python Code: %matplotlib inline import matplotlib.pyplot as plt from jyquickhelper import add_notebook_menu add_notebook_menu() Explanation: 1A.e - TD noté, 27 novembre 2012 (éléments de code pour le coloriage) Coloriage d'une image, dessin d'une spirale avec matplotlib : éléments de code données avec l'énoncé. End of ...
10,593
Given the following text description, write Python code to implement the functionality described below step by step Description: <img src="images/JHI_STRAP_Web.png" style="width Step1: After executing the code cell, you should see a table of values. The table has columns named gene1 and gene2, and rows that are index...
Python Code: # Define your group, for this exercise mygroup = "A" # <- change the letter in quotes # Import Python libraries import os # This lets us interact with the operating system import pandas as pd # This allows us to use dataframes import seaborn as sns # This gives us pretty graphics optio...
10,594
Given the following text description, write Python code to implement the functionality described below step by step Description: Neural network "playground" imports Step1: Caffe computation mode CPU Step2: GPU Make sure you enabled GPU suppor, and have a compatible (ie. nvidia) GPU Step3: Network loading and tests ...
Python Code: import numpy as np from cStringIO import StringIO import matplotlib.pyplot as plt import caffe from IPython.display import clear_output, Image, display import cv2 import PIL.Image import os os.chdir("start_deep/") Explanation: Neural network "playground" imports End of explanation caffe.set_mode_cpu() Expl...
10,595
Given the following text description, write Python code to implement the functionality described below step by step Description: TfTransform # Learning Objectives 1. Preproccess data and engineer new features using TfTransform 1. Create and deploy Apache Beam pipeline 1. Use processed data to train taxifare model lo...
Python Code: !pip install --user apache-beam[gcp]==2.16.0 !pip install --user tensorflow-transform==0.15.0 Explanation: TfTransform # Learning Objectives 1. Preproccess data and engineer new features using TfTransform 1. Create and deploy Apache Beam pipeline 1. Use processed data to train taxifare model locally then...
10,596
Given the following text description, write Python code to implement the functionality described below step by step Description: Step1: Convolutional Networks So far we have worked with deep fully-connected networks, using them to explore different optimization strategies and network architectures. Fully-connected net...
Python Code: # As usual, a bit of setup import numpy as np import matplotlib.pyplot as plt from cs231n.classifiers.cnn import * from cs231n.data_utils import get_CIFAR10_data from cs231n.gradient_check import eval_numerical_gradient_array, eval_numerical_gradient from cs231n.layers import * from cs231n.fast_layers impo...
10,597
Given the following text description, write Python code to implement the functionality described below step by step Description: I will write lot about how statistical inference is done in psychological research. I think however that it will be helpfull to first point out few issues which I think are paramount to all ...
Python Code: %pylab inline d= np.loadtxt('b5.dat') t=np.arange(0,d.size)/12.+1992 plt.plot(t,d) plt.gca().set_xticks(np.arange(0,d.size/12)+1992) plt.xlabel('year') plt.ylabel('product shipments'); Explanation: I will write lot about how statistical inference is done in psychological research. I think however that it w...
10,598
Given the following text description, write Python code to implement the functionality described below step by step Description: Unpaired assembly challenge You will implement software to assemble a genome from synthetic reads. We supply Python code snippets that you might use or adapt in your solutions, but you don'...
Python Code: # Download the file containing the reads to "reads.fa" in current directory ! wget http://www.cs.jhu.edu/~langmea/resources/f2020_hw4_reads.fa # Following line is so we can see the first few lines of the reads file # from within IPython -- don't paste this into your Python code ! head f2020_hw4_reads.fa Ex...
10,599
Given the following text description, write Python code to implement the functionality described below step by step Description: Step2: Data Challenge Files are stored in an S3 bucket. The purpose here is to fully analyze the data and make some predictions. This workbook was exported to a Python script and the resulti...
Python Code: def convert_list(query_string): Parse the query string of the url into a dictionary. Handle special cases: - There is a single query "error=True" which is rewritten to 1 if True, else 0. - Parsing the query returns a dictionary of key-value pairs. The value is a list. We must get...