Open lin9178618872 opened 1 year ago
It is an import error. You should install somehow that scratch module. There are different ways of doing so. In this case, follow what is written in the readme in order to export python path. Otherwise you can use sys library inside python.
Hi bro.
I will make the necessary change!
Thank's.
Em dom., 12 de fev. de 2023 17:18, Giacomo Matrone @.***> escreveu:
It is an import error. You should install somehow that scratch module. There are different ways of doing so. In this case, follow what is written in the readme in order to export python path. Otherwise you can use sys library inside python.
— Reply to this email directly, view it on GitHub https://github.com/joelgrus/data-science-from-scratch/issues/117#issuecomment-1427122997, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARR5MF4CR75NVDSSQFL7FO3WXFAQ5ANCNFSM6AAAAAAUXLVGZY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
It is an import error. You should install somehow that scratch module. There are different ways of doing so. In this case, follow what is written in the readme in order to export python path. Otherwise you can use sys library inside python.
hi, I follow ur reply and do it in pycharm, but it gives me a new error:
C:\Users\96057\PycharmProjects\pythonProject\venv\Scripts\python.exe C:\Users\96057\PycharmProjects\pythonProject\main.py
Traceback (most recent call last):
File "C:\Users\96057\PycharmProjects\pythonProject\main.py", line 162, in
Process finished with exit code 1
Hi bro. I will make the necessary change! Thank's. Em dom., 12 de fev. de 2023 17:18, Giacomo Matrone @.> escreveu: … It is an import error. You should install somehow that scratch module. There are different ways of doing so. In this case, follow what is written in the readme in order to export python path. Otherwise you can use sys library inside python. — Reply to this email directly, view it on GitHub <#117 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARR5MF4CR75NVDSSQFL7FO3WXFAQ5ANCNFSM6AAAAAAUXLVGZY . You are receiving this because you are subscribed to this thread.Message ID: @.>
hi, I follow ur reply and do it in pycharm, but it gives me a new error:
C:\Users\96057\PycharmProjects\pythonProject\venv\Scripts\python.exe C:\Users\96057\PycharmProjects\pythonProject\main.py
Traceback (most recent call last):
File "C:\Users\96057\PycharmProjects\pythonProject\main.py", line 162, in
Process finished with exit code 1
the code I cannot run is from typing import List from collections import Counter
def raw_majorityvote(labels: List[str]) -> str: votes = Counter(labels) winner, = votes.most_common(1)[0] return winner
assert raw_majority_vote(['a', 'b', 'c', 'b']) == 'b'
def majority_vote(labels: List[str]) -> str: """Assumes that labels are ordered from nearest to farthest.""" vote_counts = Counter(labels) winner, winner_count = vote_counts.most_common(1)[0] num_winners = len([count for count in vote_counts.values() if count == winner_count])
Tie, so look at first 4, then 'b'
assert majority_vote(['a', 'b', 'c', 'b', 'a']) == 'b'
from typing import NamedTuple from scratch.linear_algebra import Vector, distance
class LabeledPoint(NamedTuple): point: Vector label: str
def knn_classify(k: int, labeled_points: List[LabeledPoint], new_point: Vector) -> str:
import random
def randompoint(dim: int) -> Vector: return [random.random() for in range(dim)]
def random_distances(dim: int, num_pairs: int) -> List[float]: return [distance(random_point(dim), randompoint(dim)) for in range(num_pairs)]
def main(): from typing import Dict import csv from collections import defaultdict
if name == "main": main()
and it give me error
ModuleNotFoundError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_23996\3035052844.py in
26
27 from typing import NamedTuple
---> 28 from scratch.linear_algebra import Vector, distance
29
30 class LabeledPoint(NamedTuple):
ModuleNotFoundError: No module named 'scratch.linear_algebra'