Sunday, December 17, 2023

Boethius defined chance in terms of epistemic uncertainty

Reading Boethius's "The Consolation of Philosophy", I've been repeatedly struck by Boethius showing knowledge of ideas that I'd wrongly assumed only had a later origin. This reminds me that we should not underestimate the "ancients", although he is far closer to us than the true ancients, two hundred thousand years or more before.

Here he is defining "chance" in terms of epistemic uncertainty, after nodding to arguments from the ancients that there are not chance occurrences:
We can define chance, then, as the unexpected result of causes that come together of things that were done for some other purpose.
(Emphasis added by me.) He credits Aristotle's Physics as the source of this idea.

Another example that surprised me was him mentioning the problem of evil -- how can an omnipotent God allow there to be evil in the world? His answer, at least in the translation I'm looking at from David Slavin, is that "evil is nothing".

This other translation captures the same thing:
‘Nobody would care to doubt that God is all-powerful?’
‘At any rate, no sane man would doubt it.’
‘Being, then, all-powerful, nothing is beyond His power?’ ‘Nothing.’
‘Can, then, God do evil?’
‘No.’
‘Then evil is nothing, since it is beyond His power, and nothing is beyond His power?’
He also makes many arguments that at least have the flavor of an ontological argument. Again from that other translation:
‘Now consider,’ she continued, ‘where it lies. The universally accepted notion of men proves that God, the fountain-head of all things, is good. For nothing can be thought of better than God, and surely He, than whom there is nothing better, must without doubt be good. Now reason shews us that God is so good, that we are convinced that in Him lies also the perfect good. For if it is not so, He cannot be the fountain-head; for there must then be something more excellent, possessing that perfect good, which appears to be of older origin than God: for it has been proved that all perfections are of earlier origin than the imperfect specimens of the same: wherefore, unless we are to prolong the series to infinity, we must allow that the highest Deity must be full of the highest, the perfect good. But as we have laid down that true happiness is perfect good, it must be that true happiness is situated in His Divinity.’

The reasoning in these sections bothers me because it seems to trade on different meanings of the terms involved: "existence", "nothingness", etc. I don't recall Boethius addressing this possibility, but he does recognize the counterintuitivenss of some of his conclusions; he notes that if you cannot question either the premises or the reasoning from them, then you should accept the conclusion, which is something I heard one of my intro philosophy professors say around 1500 years later.

Do we need to define evil away to "remain Stoic"? I think there are good practical reasons to remain calm in the face of adversity, as in the Serenity Prayer:
God, grant me the serenity to accept the things I cannot change,
the courage to change the things I can,
and the wisdom to know the difference.
Before reading Boethius, I had a vague idea Stoicism was about this, maintaining calm despite the circumstances, a practical philosophy. But Boethius ultimately seems to be arguing that there is no such thing as adversity? To me, that weakens the appeal a bit.

Wednesday, October 11, 2023

Meow

"Meow", said the old cat. Her yellow green eyes were dulled with age, but still they glowed as the setting sun caught them. Steadfast, the eyes of a warrior, of a leader. The wind rustled the tufts of hair at the tops of her ears and her whiskers but the rest of her short gray fur moved only as her steely muscles rippled beneath. She turned to the younger at her side, a tabby. "Meow meow, meow meow meow," he said, his head bowing slightly. "Meow!" she said. "Meow?" he replied. "Meow, meow, meow, meow. Meow meow", she said. The tabby nodded and walked off into the forest. "Meow", the old warrior cat said to herself. Meow indeed.

Sunday, July 16, 2023

Boston Housing dataset ethical/data quality problems

I'm not sure if I've worked with the Boston Housing dataset previously -- maybe? -- but I've at least heard of it, I'm pretty sure. I was surprised to see this message when attempting to import it today as part of working through "TensorFlow 2.0: Quick Start Guide":
ImportError: 
`load_boston` has been removed from scikit-learn since version 1.2.

The Boston housing prices dataset has an ethical problem: as
investigated in [1], the authors of this dataset engineered a
non-invertible variable "B" assuming that racial self-segregation had a
positive impact on house prices [2]. Furthermore the goal of the
research that led to the creation of this dataset was to study the
impact of air quality but it did not give adequate demonstration of the
validity of this assumption.

The scikit-learn maintainers therefore strongly discourage the use of
this dataset unless the purpose of the code is to study and educate
about ethical issues in data science and machine learning.

In this special case, you can fetch the dataset from the original
source::

    import pandas as pd
    import numpy as np

    data_url = "http://lib.stat.cmu.edu/datasets/boston"
    raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None)
    data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])
    target = raw_df.values[1::2, 2]

Alternative datasets include the California housing dataset and the
Ames housing dataset. You can load the datasets as follows::

    from sklearn.datasets import fetch_california_housing
    housing = fetch_california_housing()

for the California housing dataset and::

    from sklearn.datasets import fetch_openml
    housing = fetch_openml(name="house_prices", as_frame=True)

for the Ames housing dataset.

[1] M Carlisle.
"Racist data destruction?"


[2] Harrison Jr, David, and Daniel L. Rubinfeld.
"Hedonic housing prices and the demand for clean air."
Journal of environmental economics and management 5.1 (1978): 81-102.

It was interesting reading M Carlisle's investigation and the scikit-learn discussion around it. I also found Fairlearn's discussion enlightening. (I One other surprise for me in this is the existence of an Ames, Iowa, housing dataset. Article describing it: Ames, Iowa: Alternative to the Boston Housing Data as an End of Semester Regression Project [PDF] (2011) by the original creator of the dataset, Dean DeCock.

Saturday, June 3, 2023

Drawing with all the fonts available in Colab

import os
import unicodedata

from PIL import Image, ImageDraw, ImageFont

def get_fonts(default_size=20):
  fonts = []
  for root, dirs, files in os.walk('/usr/share/fonts/truetype/'):
    for file in files:
      if file.endswith('.ttf'):
        fonts.append(ImageFont.truetype(os.path.join(root, file), default_size))
  return fonts

TARGET_ALPHABET = [c for c in map(chr, range(128))
  if not unicodedata.category(c).startswith('C')]
FONTS = get_fonts()
WIDTH = 500

out = Image.new("RGB", (WIDTH, 2000), (255, 255, 255))

d = ImageDraw.Draw(out)

x = 0
y = 0
for c in TARGET_ALPHABET:
  for font in FONTS:
    d.text((x, y), c, font=font, fill=(0, 0, 0))
    left, top, right, bottom = d.textbbox((x, y), c, font=font)
    if right < WIDTH - 20:
      x = right + 5
    else:
      x = 0
      y = bottom + 5
out.show()
UNICODE CHARACTER DATABASE: General_Category Values ImageDraw.textbbox

Monday, May 29, 2023

Handwriting recognition links

One project I'm curious: handwriting recognition. Dumping a list of resources I've come across: I guess there must be some more recent stuff that I'm missing? Recent articles citing the Graves and Schmidhuber article.

Wednesday, May 3, 2023

Jokes from Sidney Morgenbesser

I'm enjoying reading David Edmonds's Parfit: A Philosopher and His Mission to Save Morality. Recounting Parfit's time in New York with a Harkness Fellowship, the author squeezes in some jokes from the philosopher Sidney Morgenbesser, new to me, who was teaching at Columbia. The jokes:
  • On pragmatism: "It's all very well in theory, but it doesn't work in practice."
  • J.L. Austin is saying that while there are double negatives to express a positive -- "she is not uninteresting" -- there are no double positives to express a negative. Morgenbesser interrupts: "Yeah, yeah".
  • Eating dinner at a restaurant, the waitress says there are two choices for pie: apple or blueberry. Morgenbesser says he'll have the apple. The waitress comes back a minute later to say there's actually a third choice, cherry. Morgenbesser: "In that case, I'll have the blueberry pie."

Saturday, February 11, 2023

Impressed with sympy

I know this doesn't even come close to scratching the surface of what's possible with it, but I was impressed with this little interaction with sympy already:
import sympy
from sympy import Rational

a = sympy.symbols('a')
e = Rational(13, 4) * (5 - 6 * a) - Rational(1, 4) * (Rational(1, 3) * a - 3)
print(sympy.latex(e))
$$22 - \frac{307 a}{12}$$