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 random | |
import gym | |
import math | |
import numpy as np | |
from collections import deque | |
from keras.models import Sequential | |
from keras.layers import Dense | |
from keras.optimizers import Adam | |
from keras.models import clone_model | |
import tensorflow as tf |
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
# This file does a bootstrapping experiment to see what the average recall is when we shuffle the element | |
# Largely take reference here to calculate precision, recall and f1: | |
# http://stats.stackexchange.com/questions/15158/precision-and-recall-for-clustering | |
remove(list=ls()) | |
library(combinat) | |
# label 1: 1779 | |
# label 2: 2979 | |
# label 3: 1975 | |
# label 4: 3260 |
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
remove(list=ls()) | |
library(LiblineaR) | |
library(glmpath) | |
set.seed(1) | |
x1 <- rnorm(100, mean = 100, sd=10) | |
x2 <- rnorm(100, sd=19) | |
x3 <- -1*(5*x1 - 75*x2) | |
x4 <- -17*x1 + 2*x2 + 17*x3 | |
x5 <- -1*(30*x1 + 13*x3 - 15*x4) |
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
package io.github.czxttkl; | |
import java.util.logging.ConsoleHandler; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
import java.util.logging.SimpleFormatter; | |
import org.apache.commons.math3.random.MersenneTwister; | |
import org.apache.commons.math3.random.RandomGenerator; | |
import org.deeplearning4j.datasets.iterator.DataSetIterator; |
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 sklearn as sklearn | |
import numpy as np | |
from sklearn.cross_validation import train_test_split | |
from sklearn import linear_model | |
# Create synthetic data | |
num_samples = 500 | |
num_unrelated_features = 1000 | |
def f(x1, x2): |
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
@SuppressWarnings("unchecked") | |
public static <T> T[] concatArrays8(T[] arr1, T[] arr2) { | |
T[] both = (T[])Array.newInstance(arr1.getClass().getComponentType(), arr1.length+arr2.length); | |
Object[] bothObj = Stream.concat(Arrays.stream(arr1), Arrays.stream(arr2)).toArray(); | |
for (int i = 0; i < both.length; i++) { | |
both[i] = (T)bothObj[i]; | |
} | |
return both; | |
} |
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
public class TestAnything { | |
public static void main(String[] args) throws Exception { | |
Object[] a = new Object[2]; | |
a[0] = (Object)"aaaa"; | |
a[1] = (Object)"bbbb"; | |
String[] b = convertLsy(a, String.class); | |
} | |
private static <T> T[] convertLsy(Object[] a, Class<T> cls) { |
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 java.util.Arrays; | |
public class TestAnything { | |
public static void main(String[] args) throws Exception { | |
int[] seqs = new int[] { 1, 2, 3, 4, 5, 6 }; | |
int[] pointers = new int[] { 0, 1, 2 }; | |
while (!isExhausted(pointers, seqs.length)) { |
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
/* | |
============================================================================ | |
Name : sh.c | |
Author : Zhengxing Chen | |
Version : | |
Copyright : czxttkl. Achieve Shell basic functions: execution, IO redirection and Pipe. | |
============================================================================ | |
*/ | |
#include <stdlib.h> | |
#include <unistd.h> |
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 java.net.UnknownHostException; | |
import com.mongodb.DB; | |
import com.mongodb.DBCollection; | |
import com.mongodb.DBCursor; | |
import com.mongodb.MongoClient; | |
/** | |
* @author Zhengxing Chen | |
* |
NewerOlder