Skip to content

Instantly share code, notes, and snippets.

View pplonski's full-sized avatar
😄
Enjoy programming and writing

Piotr pplonski

😄
Enjoy programming and writing
View GitHub Profile
@pplonski
pplonski / churn_prediction_mljar.R
Last active September 9, 2017 20:34
Churn prediction with MLJAR and R-wrapper
# This is example, how to use MLJAR service for automatic machine learning and its R-wrapper for churn prediction.
# Example is based on data from https://github.com/WLOGSolutions/telco-customer-churn-in-r-and-h2o/tree/master/data
# Example by Dominik Krzemiński
library(mljar)
library(data.table)
# Read and clean the dataset
all_data <- fread("data/edw_cdr.csv")
all_data <- all_data[, !c("month", "year"), with = FALSE]
all_data <- all_data[complete.cases(all_data)]
@pplonski
pplonski / mljar_reading_lightgbm.py
Created October 2, 2017 15:32
Reading models from mljar and using locally
import os
import numpy as np
import lightgbm as lgb
# directory with your models
dir_with_models = './tmp'
# 100 samples of random data (with 70 columns), just for testing
X = np.random.rand(100, 70)
import openml
import pandas as pd
openml.config.apikey = "aaas8a89sd87as87d8as7d98a" # it is some fake API key, please set your key here!
dataset_id = 1590 # Adults data set, see https://www.openml.org/d/1590
# get data directly fom openml
dataset = openml.datasets.get_dataset(dataset_id)
(X, y, categorical, names) = dataset.get_data(
@pplonski
pplonski / read_only_user_in_postgres.sql
Created March 4, 2019 10:42
Read only user in postgres database
-- create a group
CREATE ROLE readaccess;
-- grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
import numpy as np
import pandas as pd
from sqlalchemy import create_engine
import psycopg2
import time
host = "host-address-here"
user = "db-user-here"
password = "db-password"
db = "db-name"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pplonski
pplonski / xgboost_memory_consumption.ipynb
Last active April 2, 2020 13:13
Xgboost memory allocation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pplonski
pplonski / docusaurus-copy-button.md
Created April 4, 2020 12:34 — forked from yangshun/docusaurus-copy-button.md
How to add the "Copy" button to code blocks in Docusaurus

Adding "Copy" (to Clipboard) Button

If you would like to add a button to your fenced code blocks so that users may copy the code, you can do so in Docusaurus. You will have to add some code to your Docusaurus project, as seen below.

Under static/js, create a file called code-block-buttons.js with the following:

// Turn off ESLint for this file because it's sent down to users as-is.
/* eslint-disable */
window.addEventListener('load', function() {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pplonski
pplonski / mljar_automl_mode.py
Last active April 1, 2021 12:49
MLJAR AutoML modes
'''
MLJAR AutoML can work in 4 modes:
- Explain
- Perform
- Compete
- Optuna
'''
# training in Explain mode, perfect for data exploration
automl = AutoML(mode="Explain")