This file contains hidden or 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
/** | |
I have an object like: | |
[ | |
{ | |
"id": "447c4dc3-0119-4836-afb0790ec9", | |
"name": "Food Pantry", | |
"organization_id": "0aeec5af-2490-40ca-acdab1d27", | |
"status": "Open" | |
}, | |
{ |
This file contains hidden or 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
async function load_process_data() { | |
let df = await dfd.read_csv("https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv") | |
df.head().print() | |
} |
This file contains hidden or 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
//A feature engineering: Extract all titles from names columns | |
let title = df['Name'].apply((x) => { return x.split(".")[0] }).values | |
//replace in df | |
df.addColumn({ column: "Name", value: title }) |
This file contains hidden or 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
//label Encode Name feature | |
let encoder = new dfd.LabelEncoder() | |
let cols = ["Sex", "Name"] | |
cols.forEach(col => { | |
encoder.fit(df[col]) | |
enc_val = encoder.transform(df[col]) | |
df.addColumn({ column: col, value: enc_val }) | |
}) | |
df.head().print() |
This file contains hidden or 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
// Standardize the data with MinMaxScaler | |
let scaler = new dfd.MinMaxScaler() | |
scaler.fit(Xtrain) | |
Xtrain = scaler.transform(Xtrain) | |
return [Xtrain.tensor, ytrain.tensor] |
This file contains hidden or 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
const dfd = require("danfojs-node") | |
const tf = require("@tensorflow/tfjs-node") | |
async function load_process_data() { | |
let df = await dfd.read_csv("https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv") | |
//A feature engineering: Extract all titles from names columns | |
let title = df['Name'].apply((x) => { return x.split(".")[0] }).values | |
//replace in df | |
df.addColumn({ column: "Name", value: title }) |
This file contains hidden or 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
function get_model() { | |
const model = tf.sequential(); | |
model.add(tf.layers.dense({ inputShape: [7], units: 124, activation: 'relu', kernelInitializer: 'leCunNormal' })); | |
model.add(tf.layers.dense({ units: 64, activation: 'relu' })); | |
model.add(tf.layers.dense({ units: 32, activation: 'relu' })); | |
model.add(tf.layers.dense({ units: 1, activation: "sigmoid" })) | |
model.summary(); | |
return model | |
} |
This file contains hidden or 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
async function train() { | |
const model = get_model() | |
const data = await load_process_data() | |
const Xtrain = data[0] | |
const ytrain = data[1] | |
model.compile({ | |
optimizer: "rmsprop", | |
loss: 'binaryCrossentropy', |
This file contains hidden or 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
const dfd = require("danfojs-node") | |
const tf = require("@tensorflow/tfjs-node") | |
async function load_process_data() { | |
let df = await dfd.read_csv("https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv") | |
//A feature engineering: Extract all titles from names columns | |
let title = df['Name'].apply((x) => { return x.split(".")[0] }).values | |
//replace in df | |
df.addColumn({ column: "Name", value: title }) |
This file contains hidden or 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
"""Setup for the mathist package.""" | |
import setuptools | |
with open('README.md') as f: | |
README = f.read() | |
setuptools.setup( | |
author="", |
NewerOlder