Skip to content

Instantly share code, notes, and snippets.

View rtkilian's full-sized avatar

Rhys Kilian rtkilian

View GitHub Profile
# Example of the Paired Student's t-test
from scipy.stats import wilcoxon
# Randomly generate the data
x1 = rng.normal(loc=0.00, scale=1, size=100)
x2 = x1 + rng.normal(loc=0.25, scale=1, size=100)
# Calculate test statistic and p-value
stat, p = wilcoxon(x1, x2)
from scipy.stats import ttest_rel
# Randomly generate the data
x1 = rng.normal(loc=0.00, scale=1, size=100)
x2 = x1 + rng.normal(loc=0.25, scale=1, size=100)
# Calculate test statistic and p-value
stat, p = ttest_rel(x1, x2)
# Interpreation
from scipy.stats import mannwhitneyu
# Randomly generate the data
x1 = rng.normal(loc=0.25, scale=1, size=100)
x2 = rng.normal(loc=0.00, scale=1, size=100)
# Calculate test statistic and p-value
stat, p = mannwhitneyu(x1, x2)
# Interpreatation
from scipy.stats import ttest_ind
# Randomly generate data
x1 = rng.normal(loc=0.25, scale=1, size=100)
x2 = rng.normal(loc=0.00, scale=1, size=100)
# Calculate test statistic and p-value
stat, p = ttest_ind(x1, x2)
# Interpreation
@rtkilian
rtkilian / reviews.js
Created October 26, 2021 20:22
Classify the sentiment of user reviews using an API
const Campground = require('../models/campground');
const Review = require('../models/review');
const axios = require('axios').default; // axios.<method> will now provide autocomplete and parameter typings
module.exports.createReview = async (req, res) => {
// Retrieve the review and add the user ID
const review = new Review(req.body.review);
review.author = req.user._id; // store the user id from req which is provided by Passport
@rtkilian
rtkilian / app.py
Created October 23, 2021 04:10
A Flask API to classify the sentiment of a review using spaCyTextBlob
from flask import Flask, request
from flask_restful import Resource, Api, reqparse
import spacy
from spacytextblob.spacytextblob import SpacyTextBlob
nlp = spacy.load('en_core_web_sm')
nlp.add_pipe('spacytextblob')
app = Flask(__name__)
@rtkilian
rtkilian / app.py
Last active October 19, 2021 20:33
A simple 'hello world' application in Flask
from flask import Flask
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class HelloWorld(Resource):
def get(self):
return {'hello': 'world'}