Skip to content

Instantly share code, notes, and snippets.

View benthecoder's full-sized avatar
🚀
shipping

Benedict Neo 梁耀恩 benthecoder

🚀
shipping
View GitHub Profile
function sumAll(arr) {
const max = Math.max(...arr);
const min = Math.min(...arr);
return((min+max)*(max - min +1)/2);
}
console.log(sumAll([1,4]));
function sumAll(arr) {
var max = Math.max(...arr);
var min = Math.min(...arr);
var temp = 0;
for(var i=min; i<=max; i++){
temp += i;
}
return (temp);
}
function sumAll(arr) {
return (arr[0]+arr[1])*(Math.abs(arr[0]-arr[1])+1)/2;
}
function sumAll(arr) {
var result = 0;
for (let i=Math.min(...arr); i<=Math.max(...arr); i++){
result+=i;
}
return result;
}
sumAll([1, 4]);
class Net(nn.Module):
''' Models a simple Convolutional Neural Network'''
def __init__(self):
''' initialize the network '''
super(Net, self).__init__()
# 3 input image channel, 6 output channels,
# 5x5 square convolution kernel
self.conv1 = nn.Conv2d(3, 6, 5)
# Max pooling over a (2, 2) window
@benthecoder
benthecoder / nlp-text-processing.py
Last active December 25, 2021 14:07
NLP text processing methods
# NLP text processing functions in Python
# -----------------------
# remove punctuation
import string
# print(string.punctuation) -> '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
def remove_punc(s):
'''
date avg.temp max.temp min.temp precipitation avg.wind.speed max.wind.speed max.wind.speed.dir max.inst.wind.speed max.inst.wind.speed.dir min.atmos.pressure
229b70a3 3.3 10.2 -2.4 0 2.9 9.3 W 14.3 W 1015.1
3134f4ff 5.7 13.7 -2.9 0 3.6 10.7 W 15.8 W 1011.3
dbfaf910 13.8 20 9 0 5.3 9.4 SW 15.2 W 1004.2
3aea0cf0 11.4 19.3 5.8 0 4.2 10.1 SW 20.6 SW 1001.7
f0227f56 2.4 7.7 0.3 43.5 0.9 3.7 SW 5.7 SW 1003.5
date label
a8c6911b N
eebdce12 N
6fb420a6 L
3bf8b132 N
@benthecoder
benthecoder / elon-musk-r2.py
Last active April 7, 2022 19:33
symbl output of lex fridmen round 2 interview with elon musk
[
{
"Topic Name": "neural link",
"Topic Confidence": 0.948,
"Topic Sentiment": "positive",
},
{
"Topic Name": "treat neurobiological diseases",
"Topic Confidence": 0.721,
"Topic Sentiment": "positive",
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 10 columns, instead of 1. in line 6.
LABEL-1,LABEL-2,LABEL-3,LABEL-4,LABEL-5,LABEL-6,LABEL-7,LABEL-8,LABEL-9,LABEL-10
Predicting Rain with Machine Learning,Will it rain tomorrow? Let’s build an AI model to answer that.,Published on Mar 27,on Mar 27,·,8 min read,·,In Towards Data Science,,
10 Tips to Improve Your Regression Modeling,"From the book ""Regression and Other Stories""",Published on Mar 3,on Mar 3,·,11 min read,·,In bitgrit Data Science Publication,,
Data Analysis in 10 Easy Steps,The key steps in the process of turning data into insights,Published on Feb 21,on Feb 21,·,7 min read,·,In bitgrit Data Science Publication,,
The Missing Library in your Machine Learning Workflow,A quick guide to using Optuna for hyperparameter optimization,Published on Jan 27,on Jan 27,·,7 min read,·,In bitgrit Data Science Publication,·,Unpublished changes
Top Machine Learning Frameworks used by Data Scientists,Here are the Top ML frameworks used by data scientists in 2021.,Published on Jan 4,on Jan 4,·,8 min read,·,In bitgrit Data Science Publication,,
Top