Skip to content

Instantly share code, notes, and snippets.

View mohcinemadkour's full-sized avatar

Mohcine Madkour mohcinemadkour

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mohcinemadkour
mohcinemadkour / python_tests_dir_structure.md
Created January 17, 2019 21:35 — forked from tasdikrahman/python_tests_dir_structure.md
Typical Directory structure for python tests

A Typical directory structure for running tests using unittest

Ref : stackoverflow

The best solution in my opinion is to use the unittest [command line interface][1] which will add the directory to the sys.path so you don't have to (done in the TestLoader class).

For example for a directory structure like this:

new_project

├── antigravity.py

@mohcinemadkour
mohcinemadkour / python_tests_dir_structure.md
Created January 17, 2019 21:35 — forked from tasdikrahman/python_tests_dir_structure.md
Typical Directory structure for python tests

A Typical directory structure for running tests using unittest

Ref : stackoverflow

The best solution in my opinion is to use the unittest [command line interface][1] which will add the directory to the sys.path so you don't have to (done in the TestLoader class).

For example for a directory structure like this:

new_project

├── antigravity.py

for i in range(len(imfs1)):
fig, ax = plt.subplots(figsize=(25,1))
fig = plt.plot(imfs1[i], label = "IMF{}".format(i))
plt.legend()
plt.show()
@mohcinemadkour
mohcinemadkour / app-insights-key.txt
Last active April 19, 2019 13:00
The Azure Kubernetes Workshop
App Insights: 8de2bc6e-8885-43c4-892d-ba8440bb6026
'''
Author : Mohcine Madkour
Email : [email protected]
Date : 10-Sep-2014
Description: Simulations of Schelling's seggregation model
http://www.binpress.com/tutorial/introduction-to-agentbased-models-an-implementation-of-schelling-model-in-python/144
'''
import matplotlib.pyplot as plt
import itertools
@mohcinemadkour
mohcinemadkour / schelling.py
Last active May 25, 2019 06:11
Blog page : An Introduction to Agent-based Models: Simulating Segregation with Python at https://mmadkour.xyz
'''
Author : Mohcine Madkour
Email : [email protected]
Date : 10-Sep-2014
Description: Simulations of Schelling's seggregation model
http://www.binpress.com/tutorial/introduction-to-agentbased-models-an-implementation-of-schelling-model-in-python/144
'''
import matplotlib.pyplot as plt
import itertools
# prepare for modeling
X_train = train.drop(['id', 'target'], axis=1)
y_train = train['target']
X_test = test.drop(['id'], axis=1)
# scaling data
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)
penalty = ['l1', 'l2']
C = [0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000]
class_weight = [{1:0.5, 0:0.5}, {1:0.4, 0:0.6}, {1:0.6, 0:0.4}, {1:0.7, 0:0.3}]
solver = ['liblinear', 'saga']
param_grid = dict(penalty=penalty,
C=C,
class_weight=class_weight,
solver=solver)
loss = ['hinge', 'log', 'modified_huber', 'squared_hinge', 'perceptron']
penalty = ['l1', 'l2', 'elasticnet']
alpha = [0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000]
learning_rate = ['constant', 'optimal', 'invscaling', 'adaptive']
class_weight = [{1:0.5, 0:0.5}, {1:0.4, 0:0.6}, {1:0.6, 0:0.4}, {1:0.7, 0:0.3}]
eta0 = [1, 10, 100]
param_distributions = dict(loss=loss,
penalty=penalty,
alpha=alpha,