Skip to content

Instantly share code, notes, and snippets.

View llSourcell's full-sized avatar

Siraj Raval llSourcell

View GitHub Profile
<html>
<head>
<!-- Load TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.9.0"> </script>
<!-- Place your code in the script tag below. You can also use an external .js file -->
<script>
// Notice there is no 'import' statement. 'tf' is available on the index-page
// because of the script tag above.
// Define function
function predict(input) {
// y = a * x ^ 2 + b * x + c
// More on tf.tidy in the next section
return tf.tidy(() => {
const x = tf.scalar(input);
const ax2 = a.mul(x.square());
const bx = b.mul(x);
const y = ax2.add(bx).add(c);
const model = tf.sequential();
model.add(
tf.layers.simpleRNN({
units: 20,
recurrentInitializer: 'GlorotNormal',
inputShape: [80, 4]
})
);
const optimizer = tf.train.sgd(LEARNING_RATE);
## Rule based approach
## pseudocode
def traditional_fraud_detection(user_purchase_transaction):
purchase = user_purchase_transaction
if (purchase.location == Zucks_office) & (purchase.amount > 1000)
return false
else
return true
import pandas
from sklearn.tree import DecisionTreeClassifier
#Read transaction data
data=pd.read_csv('../input/creditcard.csv')
x_train, x_test, y_train, y_test = train_test_split(data, target, train_size = 0.50)
#train model
model = DecisionTreeClassifier.fit(x_train,y_train)
score = model.score(x_test, y_test)
import pandas
from sklearn.tree import LogisticRegressionClassifier
#Read transaction data
data=pd.read_csv('../input/creditcard.csv')
x_train, x_test, y_train, y_test = train_test_split(data, target, train_size = 0.50)
#train model
model = LogisticRegressionClassifier.fit(x_train,y_train)
score = model.score(x_test, y_test)
Hello Stack Overflow,
I’ve used Stack Overflow for as long as I’ve been a developer,
and I recently came across a post about the architecture of your
products on Nick Craver’s blog. It made me think,
“I really want to work with these people who care so much about what they do.”
I’m super excited to hear about all the tools you have built to make developer
processes more streamlined; that’s right up my alley.
At my current job I started out as a web dev, b
//Our linear regression model is y = mx + b
//Our parameters are thus m and b. What are the optimal values...
//Lets use gradient descent to find out!
def linear_regression(X, y, m_current=0, b_current=0, epochs=1000, learning_rate=0.0001):
N = float(len(y))
for i in range(epochs):
y_current = (m_current * X) + b_current
from keras.applications import vgg19
from keras import backend as K
from scipy.optimize import fmin_l_bfgs_b
# Define the base image and style image
base_image_path = base_image_path
style_reference_image_path = style_reference_image_path
# these are the weights of the different loss components
total_variation_weight = 1.0