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
/** | |
* | |
* Check Status Of License Activation | |
* More at https://docs.woocommerce.com/document/woocommerce-api-manager/ | |
* @author: huraji (https://xilab.com/u/huraji) | |
* @param: $Request (string) | |
* @param: $Endpoint (string) | |
* @return: JSON decoded formatted data | |
* | |
**/ |
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
# REQUIREMENTS | |
# - A tagged dataset is necessary to calculate the probabilities used in Bayes' Theorem. | |
# - In order to apply Bayes' Theorem, we assume that these features are independent. | |
# - Using Bayes' Theorem, we can find P(class|data point) for every possible class. The class with the highest probability will be the algorithm’s prediction. | |
# MORE Improvements for the Natural Language Processing. | |
# - Remove punctuation from the training set (great! into great) | |
# - Lowercase every word in the training set (Great into great) | |
# - Use a bigram or trigram model, makes the assumption of independence more reasonable ("this is" or "is great" instead of single words) |
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
#Import datasets and libraries | |
from sklearn.datasets import fetch_20newsgroups | |
from sklearn.naive_bayes import MultinomialNB | |
from sklearn.feature_extraction.text import CountVectorizer | |
#Category selection to compare different datasets of emails and evaluate how hard is to distinguish those. | |
the_categories = ['comp.sys.ibm.pc.hardware', 'rec.sport.hockey'] | |
train_emails = fetch_20newsgroups(categories = the_categories, subset = 'train', shuffle = True, random_state = 108) | |
test_emails = fetch_20newsgroups(categories = the_categories, subset = 'test', shuffle = True, random_state = 108) |
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
# To be reminded | |
# 1) Classifying a single point can result in a true positive (truth = 1, guess = 1), a true negative (truth = 0, guess = 0), a false positive (truth = 0, guess = 1), or a false negative (truth = 1, guess = 0). | |
# 2) Accuracy measures how many classifications your algorithm got correct out of every classification it made. | |
# 3) Recall measures the percentage of the relevant items your classifier was able to successfully find. | |
# 4) Precision measures the percentage of items your classifier found that were actually relevant. | |
# 5) Precision and recall are tied to each other. As one goes up, the other will go down. | |
# 6) F1 score is a combination of precision and recall. | |
# 7) F1 score will be low if either precision or recall is low. | |
from sklearn.metrics import accuracy_score, recall_score, precision_score, f1_score |
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
# Importing breast cancer data and features. | |
# Importing training model, classifier and matplotlib | |
import codecademylib3_seaborn | |
from sklearn.datasets import load_breast_cancer | |
from sklearn.model_selection import train_test_split | |
from sklearn.neighbors import KNeighborsClassifier | |
import matplotlib.pyplot as plt | |
# Split data |
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
from sklearn.svm import SVC | |
from graph import points, labels | |
# Create SVC classifier (linear decision boundary) | |
classifier = SVC(kernel = 'linear') | |
# Training with points and labels | |
classifier.fit(points, labels) | |
# Print the prediction |
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
import matplotlib.pyplot as plt | |
from sklearn import datasets | |
# From sklearn.cluster, import Kmeans class | |
from sklearn.cluster import KMeans | |
# Load data | |
iris = datasets.load_iris() | |
samples = iris.data |
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
from sklearn.linear_model import Perceptron | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from itertools import product | |
data = [[0, 0], [0, 1], [1, 0], [1, 1]] | |
# Set labels basing on gate type (AND, OR) | |
# Multiple perceptrons can solve XOR gates | |
labels = [0, 0, 0, 1] |
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 setUrlParam(key,value) { | |
if (history.pushState) { | |
var params = new URLSearchParams(window.location.search); | |
params.set(key, value); | |
var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?' + params.toString(); | |
window.history.pushState({path:newUrl},'',newUrl); | |
} | |
} |
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 getUserChoice = userInput => { | |
userInput = userInput.toLowerCase(); | |
return userInput === 'rock' || userInput === 'paper' || userInput === 'scissors' ? userInput : console.log('Invalid input'); | |
} | |
const getComputerChoice = () => { | |
let whole = Math.floor(Math.random() * 3); | |
switch( whole ) { | |
case 0: |