# Chapter 46: Econometrics and Machine Learning: Different Questions, Shared Tools
# Fundamentals of Python for Financial Econometrics - Econometrics and Machine Learning: Different Questions, Shared Tools
# Dataset: Ceteris Lab teaching sample

# Econometrics and Machine Learning: Different Questions, Shared Tools
#
# **Opening question:** Which tasks deserve the label AI, and which claims collapse when we ask what data, objective, and evaluation produced the result?

# %% Cell 2
def rule_based_income(income):
    return "high" if income >= 70_000 else "not high"

for value in [55_000, 72_000]:
    print(value, rule_based_income(value))

# **Interpretation check:** Interpretation. The threshold is fully specified by a person. A learned classifier would estimate a boundary from labelled examples.

# %% Cell 4
import numpy as np
from sklearn.linear_model import LogisticRegression

X = np.array([[20], [30], [45], [60], [75], [90]])
y = np.array([0, 0, 0, 1, 1, 1])
model = LogisticRegression().fit(X, y)
print(np.round(model.predict_proba([[50], [80]]), 3))

# **Interpretation check:** Interpretation. The probabilities arise from the fitted data and model, not from a hand-coded threshold, although the training labels still reflect human choices.

# Verified source output
#
# ```text
# 55000 not high 72000 high
# ```
#
# ```text
# [[0.76 0.24] [0. 1. ]]
# ```
#
# ```text
# 55000 not high
# 72000 high
# ```
#
# ```text
# [[0.76 0.24]
#  [0.   1.  ]]
# ```
