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 | |
from sklearn.linear_model import LinearRegression | |
def f(x): | |
return 1 + 0.87*x[0] + 0.34*x[1] + 0.5*x[2] | |
X = np.random.random((2000, 3)) * 100 | |
y = [f(x) for x in X] | |
lm = LinearRegression() |
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
extern crate rand; | |
use ::std::path::PathBuf; | |
fn random(low: u64, high: u64) -> u64 { | |
low + rand::random::<u64>() % (high-low) | |
} | |
fn get_images_list(dir: &PathBuf) -> Vec<PathBuf> { | |
let paths: Vec<_> = std::fs::read_dir(dir).unwrap() |
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
def rgb2lab (RGB): | |
for value in RGB: | |
value = value / 255 | |
if value > 0.04045: | |
value = ((value + 0.055) / 1.055) ** 2.4 | |
else: | |
value = value / 12.92 | |
XYZ = [0, 0, 0] | |
XYZ[0] = (RGB[0] * 0.4124 + RGB[1] * 0.3576 + RGB[2] * 0.1805) / 95.047 | |
XYZ[1] = (RGB[0] * 0.2126 + RGB[1] * 0.7152 + RGB[2] * 0.0722) / 100 |
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
/* | |
The MIT License (MIT) | |
Copyright (c) 2017 Do Duy | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
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
/* | |
The MIT License (MIT) | |
Copyright (c) 2017 Do Duy | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
NewerOlder