Skip to content

Instantly share code, notes, and snippets.

View mattiasostmar's full-sized avatar

Mattias Östmar mattiasostmar

View GitHub Profile
import pywikibot
from pywikibot import pagegenerators as pg
site = pywikibot.Site(fam="commons")
cat = pywikibot.Category(site, 'Category:Media_from_the_National_Museums_of_World_Culture')
gen = pg.CategorizedPageGenerator(cat)
for page in gen:
filePage = pywikibot.FilePage(page)
try:
@mattiasostmar
mattiasostmar / Classify_Jung_cogntitive_functions_from_blog_texts.ipynb
Last active March 5, 2018 13:47
Using uClassify.com to do experiment with classification of Jungs cognitive functions based on blog texts. Get the dataset at https://www.kaggle.com/mattiasostmar/blog-texts-and-dominant-jungian-cognitive-function.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mattiasostmar
mattiasostmar / train_and_evaluate_perceiving_and_judging_classifiers_n2100_trained_n900_evaluated.ipynb
Last active March 18, 2018 20:56
Script used to produce results in blog post about experiment classifying Jungian cognitive functions with one classifier for percieving functions sensing vs intuition and one classifier for judging functions thinking vs feeling at www.mattiasostmar.se. The raw data (pickled Pandas DataFame) is available on https://osf.io/gyrc7/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mattiasostmar
mattiasostmar / Verify_Jungian_cognitive_functions_classification_results_with_uClassify_n2100_trained.ipynb
Last active March 22, 2018 11:03
New cleaner code to verify script of [previous classification results](https://gist.github.com/mattiasostmar/05a3e6b4411acd0bb0f003b0ef49f4cc) of Jungian cognitive functions from blog texts.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mattiasostmar
mattiasostmar / fasttext_jungian_cognitive_functions
Last active March 14, 2019 21:40
Using Facebooks deep-learning framwork fasttext to try to predict the Jungian cognitive functions based on blog authors writing style.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Author: **Mattias Östmar**\n",
"\n",
"Date: **2019-03-14**\n",
"\n",
@mattiasostmar
mattiasostmar / fasttext_jung_sensing_intuition_functions_in_blogs
Created March 15, 2019 15:02
Using fasttext library to predict Jungian cognitive functions sensing (s) vs intuition (n) from annotated blog texts
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Author: **Mattias Östmar**\n",
"\n",
"Date: **2019-03-15**\n",
"\n",
@mattiasostmar
mattiasostmar / fasttext_jung_thinking_feeling_functions_in_blogs
Created March 15, 2019 15:12
Using fasttext library to predict Jungian cognitive functions thinking vs feeling from annotated blog texts
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Author: **Mattias Östmar**\n",
"\n",
"Date: **2019-03-15**\n",
"\n",
@mattiasostmar
mattiasostmar / gist:42b0d846a2e3db6d8afa92e6f90d445b
Created August 5, 2019 20:59
Python code to compute accuracy and Cohens Kappa
[in:]
tot_accuracy = sum(test['func'] == test['predicted']) / len(test)
print("Accuracy all 8 classes together: {}".format(tot_accuracy))
# Total Cohens Kappa
tot_kappa = (fe_accuracy - 0.125) / 0.125
print("Cohens Kappa all 8 classes together: {}".format(tot_kappa))
[out:]
Accuracy all 8 classes together: 0.8285714285714286