This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pygmsh.built_in.geometry import Geometry | |
from pygmsh import generate_mesh | |
import meshio | |
import dolfin | |
geom = Geometry() | |
lc = .1 | |
p0 = geom.add_point([0, 0, 0], lcar=lc) | |
p1 = geom.add_point([1, 0, 0], lcar=lc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import abc | |
import asyncio | |
class MessageBox: | |
""" A class that can | |
- send messages of a certain type with some context (== put a message into | |
an internal queue), | |
- receive messages from the internal queue | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import time | |
import random | |
from collections import defaultdict | |
NOF_AGENTS = 20 | |
NOF_RECIPIENTS = 3 | |
class Message: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dolfin as dolf | |
import numpy as np | |
LOG_LEVEL = 30 | |
dolf.set_log_level(LOG_LEVEL) | |
mesh = dolf.UnitIntervalMesh(100) | |
n = dolf.FacetNormal(mesh) | |
wall_left = "near(x[0], 0)" | |
wall_right = "near(x[0], 1.)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.base import BaseEstimator | |
from sklearn.model_selection import cross_val_score | |
from sklearn.metrics import roc_auc_score | |
class RandomForestClassifierCustom(BaseEstimator): | |
def __init__(self, n_estimators=10, max_depth=10, max_features=10, | |
random_state=SEED): | |
self.n_estimators = n_estimators | |
self.max_depth = max_depth | |
self.max_features = max_features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
train_df['year_month'] = train_df['time1'].apply(lambda t: 100 * t.year + t.month).values.reshape(-1, 1) | |
test_df['year_month'] = test_df['time1'].apply(lambda t: 100 * t.year + t.month).values.reshape(-1, 1) | |
print(train_df['year_month'].loc[y_train == 1].describe()) | |
train_df = train_df[(train_df['year_month'] >= 201401)]#201309 | |
print(train_df['year_month'].loc[y_train == 1].describe()) | |
### Output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
train_times, test_times = train_df[times], test_df[times] | |
train_session_start_hour = train_times['time1'].apply(lambda ts: ts.hour).values | |
test_session_start_hour = test_times['time1'].apply(lambda ts: ts.hour).values | |
def add_day_features(df): | |
session_start_hour = df['time1'].apply(lambda ts: ts.hour) | |
morning = ((session_start_hour >= 7) & (session_start_hour <= 11)).astype('int').values.reshape(-1, 1) | |
day = ((session_start_hour >= 12) & (session_start_hour <= 18)).astype('int').values.reshape(-1, 1) | |
evening = ((session_start_hour >= 19) & (session_start_hour <= 23)).astype('int').values.reshape(-1, 1) | |
df['morning'] = morning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
petrkungurtsev@:~$ sudo pip install ROL | |
Password: | |
The directory '/Users/petrkungurtsev/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. | |
The directory '/Users/petrkungurtsev/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. | |
Collecting ROL | |
Downloading ROL-0.0.9.tar.gz (7.9MB) | |
100% |████████████████████████████████| 7.9MB 167kB/s | |
Installing collected packages: ROL | |
Running setup.py install for ROL ... error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import math | |
def add_subplot_axes(ax,rect,axisbg='w'): | |
fig = plt.gcf() | |
box = ax.get_position() | |
width = box.width | |
height = box.height | |
inax_position = ax.transAxes.transform(rect[0:2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dolfin import * | |
import numpy as np | |
import math | |
from petsc4py import PETSc | |
#BCSType = 'Dirichlet' | |
#BCSType = 'Neumann' | |
BCSType = 'Mixed' | |
print BCSType |
NewerOlder