text stringlengths 2.5k 6.39M | kind stringclasses 3
values |
|---|---|
# eICU Collaborative Research Database
# Notebook 3: Severity of illness
This notebook introduces high level admission details relating to a single patient stay, using the following tables:
- patient
- admissiondx
- apacheapsvar
- apachepredvar
- apachepatientresult
## Load libraries and connect to the database
``... | github_jupyter |
# Polychromatic Propagations
Prysm has a long heritage solving the monochromatic problem very quickly. However, it used a brute force 'propagate and interpolate' approach to solving the polychromatic problem. v0.19 offers large speedup by using matrix triple product DFTs to perform polychromatic propagations. This ... | github_jupyter |
# React
- [https://reactjs.org/](https://reactjs.org/)
- JavaScript library for building user interfaces
- `declarative` views make code more predictable and easier to debug
- `component-based` UI makes it easier to compose and manage complex UIs with their own state (data)
- since component logic is written in JS,... | github_jupyter |
# A stylized New Keynesian Model
This notebook is part of a computational appendix that accompanies the paper.
> MATLAB, Python, Julia: What to Choose in Economics?
>
> Coleman, Lyon, Maliar, and Maliar (2017)
In this notebook we summarize the key equations for the stylized New Keynesian model we solved in the pape... | github_jupyter |
# Dataset Distribution
```
import numpy as np
import math
from torch.utils.data import random_split
```
## Calculating Mean & Std
Calculates mean and std of dataset.
```
def get_norm(dataset):
mean = dataset.data.mean(axis=(0, 1, 2)) / 255.
std = dataset.data.std(axis=(0, 1, 2)) / 255.
return mean, std... | github_jupyter |
# `nnetsauce` Examples
Examples of:
- Multitask, AdaBoost, Deep, Random Bag, Ridge2, Ridge2 Multitask, Nonlinear GLM __classifiers__
- Nonlinear GLM model for __regression__
```
!pip install git+https://github.com/techtonique/nnetsauce.git@cythonize --upgrade
```
Multitask Classifier
```
import nnetsauce as ns
imp... | github_jupyter |
## Model Components
The 5 main components of a `WideDeep` model are:
1. `wide`
2. `deeptabular`
3. `deeptext`
4. `deepimage`
5. `deephead`
The first 4 of them will be collected and combined by `WideDeep`, while the 5th one can be optionally added to the `WideDeep` model through its corresponding parameters: `deephea... | github_jupyter |
```
import math, json, os, sys
import keras
from keras.callbacks import EarlyStopping, ModelCheckpoint
from keras.layers import Dense
from keras.models import Model
from keras.optimizers import Adam
from keras.preprocessing import image
DATA_DIR = 'data'
TRAIN_DIR = os.path.join(DATA_DIR, 'train')
VALID_DIR = os.pat... | github_jupyter |
```
%load_ext autoreload
%autoreload 2
import os
from hydra.experimental import initialize, initialize_config_module, initialize_config_dir, compose
from omegaconf import OmegaConf
```
# Initializing Hydra
There are several ways to initialize. See the [API docs](https://hydra.cc/docs/next/experimental/compose_api/#api... | github_jupyter |
# ResNet50 for Species without detritus
```
# License: BSD
# Author: Sasank Chilamkurthy
from __future__ import print_function, division
import torch
import torch.nn as nn
import torch.optim as optim
from torch.optim import lr_scheduler
import numpy as np
import torchvision
from torchvision import datasets, models, ... | github_jupyter |
reduce
```
from functools import reduce
a = [1,2,3,4]
b = [5,6,7,8]
c = [9,10,11,12]
reduce(lambda x,y:x+y,a+b)
reduce(lambda x,y:x+y,a+c)
reduce(lambda x,y:x+y,c+b)
reduce(lambda x,y:x+y,a)
reduce(lambda x,y:x+y,b)
reduce(lambda x,y:x+y,c)
reduce(lambda x,y:x+y,a+b+c)
max_find = lambda a,b: a if (a>b) else b
max_find... | github_jupyter |
# MNIST - Lightning ⚡️ Syft Duet - Data Scientist 🥁
## PART 1: Connect to a Remote Duet Server
As the Data Scientist, you want to perform data science on data that is sitting in the Data Owner's Duet server in their Notebook.
In order to do this, we must run the code that the Data Owner sends us, which importantly ... | github_jupyter |
# 8 Benefis of Unit Testing
[8 benefits of unit testing](https://dzone.com/articles/top-8-benefits-of-unit-testing)
The goal of unit testing is to segregate each part of the program and test that the individual parts are working correctly.
1. It isolates the smallest piece of testable software from the remainder of t... | github_jupyter |
##### Copyright 2018 The TensorFlow Authors.
```
#@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 ... | github_jupyter |
# Mapping subtypes to clusters using drivers (Figure 4)
```
from __future__ import division
import sys
import random
import copy
import math
import json
import numpy as np
import pandas as pd
import scipy
%matplotlib inline
from matplotlib import pyplot as plt
import matplotlib as mpl
import seaborn as sns
sys.pat... | github_jupyter |
```
import numpy as np
from astropy import units
import pyccl as ccl
import sacc
import sys
sys.path.append('../../')
from matplotlib import pyplot as plt
```
# Set up cosmology
```
cosmo = ccl.Cosmology(Omega_c=0.25,
Omega_b=0.05,
h=0.7,
n_s=0.965,
... | github_jupyter |
```
import os
import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
import matplotlib.pyplot as plt
%matplotlib inline
import dianna
from dianna.methods import DeepLift
from dianna import visualization
data = np.load('./binary-mnist.npz')
X_test = data['X_test'].astype(np.float32).reshap... | github_jupyter |
# Assignment 1
## Experiments
Seems like you've already implemented all the building blocks of the neural networks. Now we will conduct several experiments.
Note: These experiments will not be evaluated.
## Table of contents
* [0. Circles Classification Task](#0.-Circles-Classification-Task)
* [1. Digits Classifica... | github_jupyter |
# Logistic Regression
---
- Author: Diego Inácio
- GitHub: [github.com/diegoinacio](https://github.com/diegoinacio)
- Notebook: [regression_logistic.ipynb](https://github.com/diegoinacio/machine-learning-notebooks/blob/master/Machine-Learning-Fundamentals/regression_logistic.ipynb)
---
Overview and implementation of *L... | github_jupyter |
```
pip install numpy
pip install sklearn
pip install pandas
import numpy as np
import pandas as pd
import os
movies = pd.read_csv('tmdb_5000_movies.csv')
credits = pd.read_csv('tmdb_5000_credits.csv')
movies.head()
credits.head(1)
movies = movies.merge(credits, on='title')
movies.head(1)
#genres
#id
#keywords
#title
... | github_jupyter |
# XE Candidate Datastore Demo
This sample **doesn't attempt to lock or unlock datastores**, and thus assumes singular access.
```
HOST = '127.0.0.1'
PORT_NC = 2223
USER = 'vagrant'
PASS = 'vagrant'
```
## Connect ncclient
```
from ncclient import manager
from lxml import etree
def pretty_print(retval):
print(... | github_jupyter |
Deep neural networks have produced large accuracy gains in applications such as computer vision, speech recognition and natural language processing. Rapid advancements in this area have been supported by excellent libraries for developing neural networks. These libraries allow users to express neural networks in terms ... | github_jupyter |
```
import warnings
warnings.filterwarnings("ignore")
import os
import jieba
import torch
import pickle
import torch.nn as nn
import torch.optim as optim
import pandas as pd
from ark_nlp.model.tc.bert import Bert
from ark_nlp.model.tc.bert import BertConfig
from ark_nlp.model.tc.bert import Dataset
from ark_nlp.model... | github_jupyter |
```
#hide
from neos.models import *
from neos.makers import *
from neos.transforms import *
from neos.fit import *
from neos.infer import *
from neos.smooth import *
```
# neos
> ~neural~ nice end-to-end optimized statistics
[](https://zenodo.org/badge/latestdoi/23577668... | github_jupyter |
```
from sklearn.ensemble import GradientBoostingRegressor, RandomForestRegressor
from sklearn import cross_validation
from sklearn.preprocessing import LabelBinarizer, StandardScaler
from sklearn.linear_model import LassoLarsCV
import sklearn
import pandas as pd
import numpy as np
import pandas as pd
from sklearn.ense... | github_jupyter |
# Torch Core
This module contains all the basic functions we need in other modules of the fastai library (split with [`core`](/core.html#core) that contains the ones not requiring pytorch). Its documentation can easily be skipped at a first read, unless you want to know what a given fuction does.
```
from fastai.impo... | github_jupyter |
```
import os
path = '/home/yash/Desktop/tensorflow-adversarial/tf_example'
os.chdir(path)
# supress tensorflow logging other than errors
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import numpy as np
import tensorflow as tf
from tensorflow.contrib.learn import ModeKeys, Estimator
import matplotlib
matplotlib.use('Agg')
... | github_jupyter |
```
%load_ext autoreload
%autoreload 2
from IPython.display import Image
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
import os
import time
import json
import jax.numpy as np
import numpy as onp
import jax
import pickle
import matplotlib.pyplot a... | github_jupyter |
```
from jeremy import spGrids
import numpy as np
from lat_type import lat_type
```
Let's first check if we can get bcc or fcc from a simple cubic parent.
```
A = np.transpose([[1,0,0],[0,1,0],[0,0,1]])
temp = spGrids(A,2)
g = temp[0]['grid_vecs']
g
lat_type(np.transpose(g))
temp = spGrids(A,4)
g = temp[0]['grid_vecs... | github_jupyter |
```
import os, sys
import jieba, codecs, math
import jieba.posseg as pseg
from pyecharts import options as opts
from pyecharts.charts import Graph
class RelationExtractor:
def __init__(self, fpStopWords, fpNameDicts, fpAliasNames):
# 人名词典
self.name_dicts = [line.strip().split(' ')[0] for line in op... | github_jupyter |
# Auto Insurance Fraud Detection
## Data preparation and Modeling
Here we will prepare the data for the machine learning algorithms and asses the performance of multiple ML models
The Jupyter Notebook performing exploratory data analysis can be obtained [here](Insurance Fraud Detection-EDA.ipynb)
### Approach
1. C... | github_jupyter |
```
# default_exp data.metadatasets
```
# Metadatasets: a dataset of datasets
> This functionality will allow you to create a dataset from data stores in multiple, smaller datasets.
* I'd like to thank both Thomas Capelle (https://github.com/tcapelle) and Xander Dunn (https://github.com/xanderdunn) for their contri... | github_jupyter |
```
import tensorflow as tf
```
## 참고 자료
- [이찬우님 유튜브](https://www.youtube.com/watch?v=4vJ_2NtsTVg&list=PL1H8jIvbSo1piZJRnp9bIww8Fp2ddIpeR&index=2)
### (1) 보편적 Case
- Generator를 사용
- python api를 의존하기 때문에 병목이 있을 수 있음
```
def gen():
for i in range(10):
yield i
dataset = tf.data.Dataset.from_generator(ge... | github_jupyter |
# Dealing with spectrum data
This tutorial demonstrates how to use Spectrum class to do various arithmetic operations of Spectrum. This demo uses the Jsc calculation as an example, namely
\begin{equation}
J_{sc}=\int \phi(E)QE(E) dE
\end{equation}
where $\phi$ is the illumination spectrum in photon flux, $E$ is the ph... | github_jupyter |
```
import requests
from IPython.display import Markdown
from tqdm import tqdm, tqdm_notebook
import pandas as pd
from matplotlib import pyplot as plt
import numpy as np
import altair as alt
from requests.utils import quote
import os
from datetime import timedelta
from mod import alt_theme
fmt = "{:%Y-%m-%d}"
# Can op... | github_jupyter |
# Machine learning methods for sequential data
There are some very robust methods for learning sequential data such as for time-series or language processing tasks. We'll look at recurrent neural networks which leverage the autocorrelated nature of the training data sets.
# Sequential learning
We will utilize two popu... | github_jupyter |
<table width="100%"> <tr>
<td style="background-color:#ffffff;">
<a href="http://qworld.lu.lv" target="_blank"><img src="..\images\qworld.jpg" width="35%" align="left"> </a></td>
<td style="background-color:#ffffff;vertical-align:bottom;text-align:right;">
prepared by Abuzer Yak... | github_jupyter |
# 8.3 PCA
PCA首先识别最靠近数据的超平面,然后将数据投影到该平面上。
## 8.3.1 保留差异性
将训练集投影到低维超平面之前需要选择正确的超平面。
## 8.3.2 主要成分
**主成分分析可以在训练集中识别出哪条轴对差异性的贡献度最高。** 轴的数量与数据集维度数量相同。
第i个轴称为数据的第i个主要成分(PC)
对于每个主要成分,PCA都找到一个指向PC方向的零中心单位向量。由于两个相对的单位向量位于同一轴上,因此PCA返回的单位向量的方向不稳定:如果稍微扰动训练集并再次运行PCA,则单位向量可能会指向原始向量的相反方向。但是,它们通常仍位于相同的轴上。在某些情况下,一对单位向量甚至可以旋转或交换(... | github_jupyter |
## Topic Modeling: Latent Semantic Analysis/Indexing
### Imports
```
import warnings
from collections import OrderedDict
from pathlib import Path
from random import randint
import numpy as np
import pandas as pd
# Visualization
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
import seabor... | github_jupyter |
# Social Network Analysis
## Introduction to graph theory
```
%matplotlib inline
import matplotlib.pyplot as mpl
mpl.style.use('_classic_test')
mpl.rcParams['figure.figsize'] = [6.5, 4.5]
mpl.rcParams['figure.dpi'] = 80
mpl.rcParams['savefig.dpi'] = 100
mpl.rcParams['font.size'] = 10
mpl.rcParams['legend.fontsize'] ... | github_jupyter |
<a href="https://colab.research.google.com/github/mohameddhameem/TensorflowCertification/blob/main/TensorflowCertification/Course_1_Part_6_Lesson_2_CNN.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
##### Copyright 2019 The TensorFlow Authors.
```... | github_jupyter |
# Create a Local Docker Image
In this section, we will create an IoT Edge module, a Docker container image with an HTTP web server that has a scoring REST endpoint.
## Get Global Variables
```
import sys
sys.path.append('../common')
from env_variables import *
```
## Create Web Application & Inference Server for Our... | github_jupyter |
### This notebook provides a template for connecting to the KEGG API, as well as a first look at the list of enzymes in the database
#### References:
https://biopython.readthedocs.io/en/latest/Tutorial/chapter_kegg.html
http://biopython.org/DIST/docs/api/Bio.KEGG.REST-module.html
https://exploringlifedata.blogspot... | github_jupyter |
```
#IMPORT SEMUA LIBRARY DISINI
#IMPORT LIBRARY PANDAS
import pandas as pd
#IMPORT LIBRARY POSTGRESQL
import psycopg2
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
#IMPORT LIBRARY CHART
from matplotlib import pyplot as plt
from matplotlib import style
#IMPORT LIBRARY PDF
from fpdf import FPDF
#IMPORT LIBR... | github_jupyter |
# 使用序列到序列模型完成数字加法
**作者:** [jm12138](https://github.com/jm12138) <br>
**日期:** 2021.05 <br>
**摘要:** 本示例介绍如何使用飞桨完成一个数字加法任务,将会使用飞桨提供的`LSTM`,组建一个序列到序列模型,并在随机生成的数据集上完成数字加法任务的模型训练与预测。
## 一、环境配置
本教程基于Paddle 2.1 编写,如果你的环境不是本版本,请先参考官网[安装](https://www.paddlepaddle.org.cn/install/quick) Paddle 2.1 。
```
# 导入项目运行所需的包
import pa... | github_jupyter |
# This file contains code of the paper 'Rejecting Novel Motions in High-Density Myoelectric Pattern Recognition using Hybrid Neural Networks'
```
import scipy.io as sio
import numpy as np
from keras.layers import Conv2D, MaxPool2D, Flatten, Dense,Dropout, Input, BatchNormalization
from keras.models import Model
from k... | github_jupyter |
<a href="https://colab.research.google.com/github/JSJeong-me/KOSA-Big-Data_Vision/blob/main/Model/0_rf-PCA_All_to_csv.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
```
#!pip install -U pandas-profiling
import pandas as pd
#import pandas_profiling
... | github_jupyter |
<h1><font size=12>
Weather Derivatites </h1>
<h1> Rainfall Simulator <br></h1>
Developed by [Jesus Solano](mailto:ja.solano588@uniandes.edu.co) <br>
16 September 2018
```
# Import needed libraries.
import numpy as np
import pandas as pd
import random as rand
import matplotlib.pyplot as plt
from scipy.stats import ... | github_jupyter |
# Data exploration and cleaning
Using Pandas for data exploration and data cleaning.
**Overview of the final goal**
In the following two lectures our goal is to analyze a pool of loans and assess their risk. The central question is whether the loans in question are good or bad in terms of their risk. To assess whethe... | github_jupyter |
```
from keras import backend as K
from keras.models import load_model
from keras.preprocessing import image
from keras.optimizers import Adam
from imageio import imread
import numpy as np
from matplotlib import pyplot as plt
from models.keras_ssd300 import ssd_300
from keras_loss_function.keras_ssd_loss import SSDLos... | github_jupyter |
```
"""This area sets up the Jupyter environment.
Please do not modify anything in this cell.
"""
import os
import sys
# Add project to PYTHONPATH for future use
sys.path.insert(1, os.path.join(sys.path[0], '..'))
# Import miscellaneous modules
from IPython.core.display import display, HTML
# Set CSS styling
with op... | github_jupyter |
# Transposes, Permutations, and Spaces (18.06_L5)
> Linear Algebra - Row Exchanges, spaces and subspaces, oh my!
- toc: true
- badges: true
- comments: true
- author: Isaac Flath
- categories: [Linear Algebra]
# Background
In previous posts, we have gone over elimination to solve systems of equations. However, eve... | github_jupyter |
```
from copy import copy
import glob
import hashlib
import json
import os
from pathlib import Path
import shutil
import cv2
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from PIL import Image, ImageChops, ImageFile, ImageFilter
from tqdm import tqdm_notebook as tqdm
ImageFile.LOAD_TRUNCATED_... | github_jupyter |
# Preparing the dataset for hippocampus segmentation
In this notebook you will use the skills and methods that we have talked about during our EDA Lesson to prepare the hippocampus dataset using Python. Follow the Notebook, writing snippets of code where directed so using Task comments, similar to the one below, which... | github_jupyter |
##### Copyright 2020 The TensorFlow Authors.
```
#@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 ... | github_jupyter |
##### Copyright 2019 The TensorFlow Authors.
```
#@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 ... | github_jupyter |
# Using R to read data and plot
__email__: anne.deslattesmays@nih.gov
(Questions? Feel free to create a new issue in the workshop's github repo [here](https://github.com/NIH-NICHD/Elements-of-Style-Workflow-Creation-Maintenance/issues))
from the command line please do the following
```bash
cd classes/1-intro-to-c... | github_jupyter |
#Importing and Unzipping the dataset
```
!unzip "/content/gdrive/My Drive/P14-Convolutional-Neural-Networks.zip"
!ls
```
#Building the neural network
Importing the libraries
```
from tensorflow.python.keras.models import Sequential
from tensorflow.python.keras.layers import Convolution2D
from tensorflow.python.kera... | github_jupyter |
# Spatial diagnostics
This notebook is used to create the checkerboard test shown in Fig3 C
## Settings
Here are the settings you can adjust when running this notebook:
- ``num_threads``: If running on a multi-core machine, change this from ``None`` to an ``int`` in order to set the max number of threads to use
- ``... | github_jupyter |
> This is one of the 100 recipes of the [IPython Cookbook](http://ipython-books.github.io/), the definitive guide to high-performance scientific computing and data science in Python.
# 10.1. Analyzing the frequency components of a signal with a Fast Fourier Transform
Download the *Weather* dataset on the book's websi... | github_jupyter |
```
# This is the sincere effort of Subhodeep, kindly don't copy.
# Data analysis
import pandas as pd
import numpy as np
# Visualisation
import matplotlib.pyplot as plt
# ML tools
from sklearn.ensemble import RandomForestClassifier
#using pandas
#training data
train_ds = pd.read_csv('train.csv')
#testing data
test_d... | github_jupyter |
```
# Importing required libraries
import numpy as np
import matplotlib.pyplot as plt
from sklearn import preprocessing, cross_validation, svm
from sklearn.linear_model import LinearRegression
from sklearn.svm import SVR
import datetime as dt1
from datetime import datetime as dt
import quandl
import datetime
import sc... | github_jupyter |
```
%load_ext autoreload
%autoreload 2
%matplotlib inline
#export
from exp.nb_02_callbacks import *
```
# Initial Setup
```
x_train, y_train, x_valid, y_valid = get_data(url=MNIST_URL)
train_ds = Dataset(x=x_train, y=y_train)
valid_ds = Dataset(x=x_valid, y=y_valid)
nh = 50
bs = 16
c = y_train.max().item() + 1
loss_... | github_jupyter |
# 📝 Exercise M5.02
The aim of this exercise is to find out whether a decision tree
model is able to extrapolate.
By extrapolation, we refer to values predicted by a model outside of the
range of feature values seen during the training.
We will first load the regression data.
```
import pandas as pd
penguins = pd.... | github_jupyter |
# Non-Gaussian Likelihoods
## Introduction
This example is the simplest form of using an RBF kernel in an `ApproximateGP` module for classification. This basic model is usable when there is not much training data and no advanced techniques are required.
In this example, we’re modeling a unit wave with period 1/2 cen... | github_jupyter |
# Dimension Reduce Cancer
```
import pandas as pd
import numpy as np
import time
import matplotlib.pyplot as plt
import csv
from sklearn.model_selection import train_test_split
from sklearn.decomposition import PCA
from sklearn.mixture import GaussianMixture
from sklearn import metrics
from sklearn import preprocessin... | github_jupyter |
# High-level CNN Keras (TF) Example
*Modified by Jordan A Caraballo Vega (jordancaraballo)*
```
import os
import sys
import numpy as np
os.environ['KERAS_BACKEND'] = "tensorflow"
MULTI_GPU = True
import warnings # make notebook more readable and nice
warnings.filterwarnings('ignore', category=FutureWarning)
warnings... | github_jupyter |
```
import re
import csv
import random
import numpy as np
import pandas as pd
import scipy
import scipy.stats as stats
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="whitegrid")
import matplotlib.font_manager as font_manager
import matplotlib.patches as mpatches
from matplotlib.lines import Line2D... | github_jupyter |
# Transfer Learning on a network, where roads are clustered into classes
```
import time
import math
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import ipdb
import os
import tensorflow as tf
from tensorflow.keras.models import load_model, Model
from tensorflow.keras imp... | github_jupyter |
# Figure S1: Global optimization over parameters
This notebook contains the analysis of a direct global opimization over all four parameters ($p, q, c_{\rm constitutive}, p_{\rm uptake}$) of the model as a function of the pathogen statistics. It can be thought of as a supplement to Figure 1, motivating the choice of i... | github_jupyter |
# 3 - Faster Sentiment Analysis
In the previous notebook we managed to achieve a decent test accuracy of ~85% using all of the common techniques used for sentiment analysis. In this notebook, we'll implement a model that gets comparable results whilst training significantly faster. More specifically, we'll be implemen... | github_jupyter |
# 第2章: UNIXコマンド
popular-names.txtは,アメリカで生まれた赤ちゃんの「名前」「性別」「人数」「年」をタブ区切り形式で格納したファイルである.以下の処理を行うプログラムを作成し,popular-names.txtを入力ファイルとして実行せよ.さらに,同様の処理をUNIXコマンドでも実行し,プログラムの実行結果を確認せよ
## 10. 行数のカウント
行数をカウントせよ.確認にはwcコマンドを用いよ.
```
with open('popular-names.txt', 'r', encoding='utf8') as f:
print(len([1 for line in f]))
!wc ... | github_jupyter |
# Automatic differentiation with JAX
## Main features
- Numpy wrapper
- Auto-vectorization
- Auto-parallelization (SPMD paradigm)
- Auto-differentiation
- XLA backend and JIT support
## How to compute gradient of your objective?
- Define it as a standard Python function
- Call ```jax.grad``` and voila!
- Do not for... | github_jupyter |
# cuDF Cheat Sheets sample code
(c) 2020 NVIDIA, Blazing SQL
Distributed under Apache License 2.0
### Imports
```
import cudf
import numpy as np
```
### Sample DataFrame
```
df = cudf.DataFrame(
[
(39, 6.88, np.datetime64('2020-10-08T12:12:01'), np.timedelta64(14378,'s'), 'C', 'D', 'data'
... | github_jupyter |
# The biharmonic equation on the Torus
The biharmonic equation is given as
$$
\nabla^4 u = f,
$$
where $u$ is the solution and $f$ is a function. In this notebook we will solve this equation inside a torus with homogeneous boundary conditions $u(r=1)=u'(r=1)=0$ on the outer surface. We solve the equation with the s... | github_jupyter |
<h1 style="padding-top: 25px;padding-bottom: 25px;text-align: left; padding-left: 10px; background-color: #DDDDDD;
color: black;"> <img style="float: left; padding-right: 10px; width: 45px" src="https://raw.githubusercontent.com/Harvard-IACS/2018-CS109A/master/content/styles/iacs.png"> AC295: Advanced Practical D... | github_jupyter |
# Changepoint Detection
Think Bayes, Second Edition
Copyright 2020 Allen B. Downey
License: [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](https://creativecommons.org/licenses/by-nc-sa/4.0/)
```
# If we're running on Colab, install empiricaldist
# https://pypi.org/project/empiricaldist/
... | github_jupyter |
#### New to Plotly?
Plotly's Python library is free and open source! [Get started](https://plotly.com/python/getting-started/) by downloading the client and [reading the primer](https://plotly.com/python/getting-started/).
<br>You can set up Plotly to work in [online](https://plotly.com/python/getting-started/#initiali... | github_jupyter |
```
# Use the Azure Machine Learning data collector to log various metrics
from azureml.logging import get_azureml_logger
logger = get_azureml_logger()
# Use Azure Machine Learning history magic to control history collection
# History is off by default, options are "on", "off", or "show"
# %azureml history on
# The pur... | github_jupyter |
```
import numpy as np
import pandas as pd
import seaborn as sns
import scipy as sns
import pandas_profiling
import random
import math
import time
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error,mean_absolute_error
import datetime
import os
import sys
path=('/home/manik... | github_jupyter |
# PRMT-2116 Generate High level table with new transfer categorisation
We’ve completed work for recategorising transfers, so now we want to regenerate the top level table of GP2GP transfers with these categorisations, so we can prioritise next things to look at. We also want to update the table with more recent data, ... | github_jupyter |
Видосы, которые которые гораздо подробнее этого ноутбука
- [Что такое Python и почему мы выбрали именно его](https://www.coursera.org/learn/mathematics-and-python/lecture/VXRfy/chto-takoie-python-i-pochiemu-my-vybrali-imienno-iegho)
- [Что такое ноутбуки и как ими пользоваться](https://www.coursera.org/learn/mathematic... | github_jupyter |
# the Monte Carlo experiment
```
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
```
A handy routines to store and recover python objects, in particular, the experiment resutls dictionaires.
```
import time, gzip
import os, pickle
def save(obj, path, prefix=None):
prefix_ = "" if prefix i... | github_jupyter |
# CarND Object Detection Lab
Let's get started!
```
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from PIL import ImageDraw
from PIL import ImageColor
import time
from scipy.stats import norm
%matplotlib inline
plt.style.use('ggplot')
```
## MobileNets
[*MobileNet... | github_jupyter |

<font size=3 color="midnightblue" face="arial">
<h1 align="center">Escuela de Ciencias Básicas, Tecnología e Ingeniería</h1>
</font>
<font size=3 color="navy" face="arial">
<h1 align="center">ECBTI</h1>
</font>
<font size=2 color="darkor... | github_jupyter |
# Exercise 3 - Quantum error correction
## Historical background
Shor's algorithm gave quantum computers a worthwhile use case—but the inherent noisiness of quantum mechanics meant that building hardware capable of running such an algorithm would be a huge struggle. In 1995, Shor released another landmark paper: a sc... | github_jupyter |
For this problem set, we'll be using the Jupyter notebook:

---
## Part A (2 points)
Write a function that returns a list of numbers, such that $x_i=i^2$, for $1\leq i \leq n$. Make sure it handles the case where $n<1$ by raising a `ValueError`.
```
def squares(n):
"""Compute the squares of numb... | github_jupyter |
# SHAP Interaction
Using the SHAP python package to identify interactions in data
<br>
<b>Dataset:<b> https://www.kaggle.com/conorsully1/interaction-dataset
```
#imports
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import xgboost as xgb
import shap
shap.initjs()
path ... | github_jupyter |
(pymc3_schema)=
# Example of `InferenceData` schema in PyMC3
The description of the `InferenceData` structure can be found {ref}`here <schema>`.
```
import arviz as az
import pymc3 as pm
import pandas as pd
import numpy as np
import xarray
xarray.set_options(display_style="html");
#read data
data = pd.read_csv("linea... | github_jupyter |
```
# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O... | github_jupyter |
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.

# Using Azure Machine Lea... | github_jupyter |
```
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator
from scipy import stats
from compton import setup_rc_params
setup_rc_params()
```
In GMP 2016 they use
\begin{align}
\xi^{(s)} & = c_0^{(s)} + c_2^{(s)} \delta^2 + \Delta_2^{(s)} \\
\xi^{(... | github_jupyter |
```
from IPython.core.display import HTML
HTML('''<style>
.container { width:100% !important; }
</style>
''')
```
# Refutational Completeness of the Cut Rule
This notebook implements a number of procedures that are needed in our proof of the <em style="color:blue">refutational completeness</em> o... | github_jupyter |
```
import torch
from torch.autograd import Variable
import warnings
from torch import nn
from collections import OrderedDict
import os
import numpy as np
import pandas as pd
import seaborn as sns
from sklearn.linear_model import LogisticRegression
import matplotlib.pyplot as plt
import data as data
from data.Behaviora... | github_jupyter |
## Subsurface scattering
This example shows how to:
- setup a glass-like material for subsurface scattering
- enable light emmision in the volume

Glass-like material shader in PlotOptiX can simulate light p... | github_jupyter |
# Lab: TfTransform #
**Learning Objectives**
1. Preprocess data and engineer new features using TfTransform
1. Create and deploy Apache Beam pipeline
1. Use processed data to train taxifare model locally then serve a prediction
## Introduction
While Pandas is fine for experimenting, for operationalization of y... | github_jupyter |
<font size="+5">#02 | Master the Python Syntax</font>
<div class="alert alert-warning">
<ul>
<li>
Follow the Author on Twitter: <a href="https://twitter.com/jsulopz"><b>@jsulopz</b></a>
</li>
<li>
<b>Python</b> + <b>Data Science</b> Tutorials in ↓
<ul>
<li>
<a href=... | github_jupyter |
# Parameters in QCoDeS
```
import qcodes as qc
import numpy as np
```
QCoDeS provides 3 classes of parameter built in:
- `Parameter` represents a single value at a time
- Example: voltage
- `ArrayParameter` represents an array of values of all the same type that are returned all at once
- Example: voltage vs time... | github_jupyter |
Some notes on downsampling data for display
=======================
The smaller the time step of a simulation, the more accurate it is. Empirically, for the Euler method, it looks like 0.001 JD per step (or about a minute) is decent for our purposes. This means that we now have 365.25 / 0.001 = {{365.25 / 0.001}} poin... | github_jupyter |
## Importing necessary libraries
```
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn import metrics
from sklearn.neighbors import KNeighborsClassifier as KNN
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
f... | github_jupyter |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.