Skip to content

Instantly share code, notes, and snippets.

Mattias Östmar mattiasostmar

Block or report user

Report or block mattiasostmar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mattiasostmar
mattiasostmar / gist:42b0d846a2e3db6d8afa92e6f90d445b
Created Aug 5, 2019
Python code to compute accuracy and Cohens Kappa
View gist:42b0d846a2e3db6d8afa92e6f90d445b
[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
@mattiasostmar
mattiasostmar / fasttext_jung_thinking_feeling_functions_in_blogs
Created Mar 15, 2019
Using fasttext library to predict Jungian cognitive functions thinking vs feeling from annotated blog texts
View fasttext_jung_thinking_feeling_functions_in_blogs
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Author: **Mattias Östmar**\n",
"\n",
"Date: **2019-03-15**\n",
"\n",
@mattiasostmar
mattiasostmar / fasttext_jung_sensing_intuition_functions_in_blogs
Created Mar 15, 2019
Using fasttext library to predict Jungian cognitive functions sensing (s) vs intuition (n) from annotated blog texts
View fasttext_jung_sensing_intuition_functions_in_blogs
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Author: **Mattias Östmar**\n",
"\n",
"Date: **2019-03-15**\n",
"\n",
@mattiasostmar
mattiasostmar / fasttext_jungian_cognitive_functions
Last active Mar 14, 2019
Using Facebooks deep-learning framwork fasttext to try to predict the Jungian cognitive functions based on blog authors writing style.
View fasttext_jungian_cognitive_functions
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Author: **Mattias Östmar**\n",
"\n",
"Date: **2019-03-14**\n",
"\n",
View discoursebias_under_development.ipynb
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 Mar 22, 2018
New cleaner code to verify script of [previous classification results](https://gist.github.com/mattiasostmar/05a3e6b4411acd0bb0f003b0ef49f4cc) of Jungian cognitive functions from blog texts.
View Verify_Jungian_cognitive_functions_classification_results_with_uClassify_n2100_trained.ipynb
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 Mar 18, 2018
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/
View train_and_evaluate_perceiving_and_judging_classifiers_n2100_trained_n900_evaluated.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mattiasostmar
mattiasostmar / Classify_Jung_cogntitive_functions_from_blog_texts.ipynb
Last active Mar 5, 2018
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.
View Classify_Jung_cogntitive_functions_from_blog_texts.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Iterate over pages in Wikimedia Commons category
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:
You can’t perform that action at this time.