Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Syntax Error; #171

Open
rishbobby opened this issue Nov 24, 2024 · 0 comments
Open

[BUG] Syntax Error; #171

rishbobby opened this issue Nov 24, 2024 · 0 comments

Comments

@rishbobby
Copy link

rishbobby commented Nov 24, 2024

There was a syntax error in Example 1-1, Line 20; Accidental capitalization of "x" to "X"

To Reproduce

import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression

# Download and prepare the data
data_root = "https://github.com/ageron/data/raw/main/"
lifesat = pd.read_csv(data_root + "lifesat/lifesat.csv")
x = lifesat[["GDP per capita (USD)"]].values
y = lifesat[["Life satisfaction"]].values

# Visualize the data
lifesat.plot(kind= "scatter", grid = True,
             x = "GDP per capita (USD)", y = "Life satisfaction")
plt.axis([23_500, 62_500, 4, 9])
plt.show()

# Select a linear model
model = LinearRegression()

# Train the model
model.fit(X, y)

X_new = [[37_655]] # Cyprus' GDP per capita in 2020
print(model.predict(X_new)) # output: [[6.30165767]]


Exception:

Traceback (most recent call last):
  File "/Users/##############/Library/Mobile Documents/com~apple~CloudDocs/Programs/python/###.py", line 22, in <module>
    model.fit(X, y)
              ^
NameError: name 'X' is not defined. Did you mean: 'x'?

Not the biggest issue, just thought to let you guys know 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant