第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

蟒蛇錯(cuò)誤。ImportError:沒有名為 feature_format 的模塊

蟒蛇錯(cuò)誤。ImportError:沒有名為 feature_format 的模塊

一只斗牛犬 2022-06-14 16:22:37
我正在從 Udacity 課程中學(xué)習(xí)回歸,"Intro to Machine Learning"并且正在完成其中的迷你項(xiàng)目。我復(fù)制了項(xiàng)目的代碼,編寫了回歸部分,作為代碼的一部分,并嘗試在 Python 2 中的 Jupyter Notebook 上運(yùn)行它。不幸的是,我收到了以下錯(cuò)誤。    ImportError                               Traceback (most recent call last)    <ipython-input-8-433cee6c5e25> in <module>()         15 import pickle         16 sys.path.append("../tools/")    ---> 17 from feature_format import featureFormat, targetFeatureSplit         18 dictionary = pickle.load( open("../final_project/final_project_dataset_modified.pkl", "r") )         19     ImportError: No module named feature_format我正在處理的代碼如下:加載/格式化數(shù)據(jù)集的修改版本(為什么要修改?我們已經(jīng)刪除了一些麻煩點(diǎn),你會(huì)發(fā)現(xiàn)自己在異常值迷你項(xiàng)目中)。繪制一個(gè)小散點(diǎn)圖訓(xùn)練/測(cè)試數(shù)據(jù)n您在指示處填寫回歸代碼:    #!/usr/bin/python    import sys    import pickle    sys.path.append("../tools/")    from feature_format import featureFormat, targetFeatureSplit    dictionary = pickle.load( open("../final_project/final_project_dataset_modified.pkl", "r") )    ### list the features you want to look at--first item in the     ### list will be the "target" feature    features_list = ["bonus", "salary"]    data = featureFormat( dictionary, features_list, remove_any_zeroes=True)    target, features = targetFeatureSplit( data )    ### training-testing split needed in regression, just like classification    from sklearn.cross_validation import train_test_split    feature_train, feature_test, target_train, target_test = train_test_split(features, target, test_size=0.5, random_state=42)    train_color = "b"    test_color = "r"    ### Your regression goes here!    ### Please name it reg, so that the plotting code below picks it up and     ### plots it correctly. Don't forget to change the test_color above from "b" to    ### "r" to differentiate training points from test points.    from sklearn import linear_model    reg = linear_model.LinearRegression()    reg.fit(feature_train,target_train)
查看完整描述

2 回答

?
交互式愛情

TA貢獻(xiàn)1712條經(jīng)驗(yàn) 獲得超3個(gè)贊

原因

ImportError: No module named feature_format表示沒有名為 的模塊feature_format。

該模塊已在您正在使用的存儲(chǔ)庫(kù)中定義ud120-projects/tools/feature_format.py。

解決方案 1

模塊的路徑feature_format在第 3 行中聲明k_means_cluster.py。作為傳遞給的參數(shù)sys.path.append

將路徑從相對(duì)路徑更改為絕對(duì)路徑,例如sys.path.append("ud120-projects/tools/")。

解決方案 2

一切都好做這個(gè)簡(jiǎn)單的把戲。
克隆 GitHub 存儲(chǔ)庫(kù)

git clone https://github.com/udacity/ud120-projects.git

轉(zhuǎn)到ud120-projects/k_means/目錄

cd ud120-projects/k_means/

然后是 python2 的 python 腳本

python k_means_cluster.py


查看完整回答
反對(duì) 回復(fù) 2022-06-14
?
POPMUISE

TA貢獻(xiàn)1765條經(jīng)驗(yàn) 獲得超5個(gè)贊

嘗試添加:


import sys

!{sys.executable} -m pip install feature_format

在導(dǎo)入 feature_format 之前。這個(gè)“應(yīng)該”安裝它。


查看完整回答
反對(duì) 回復(fù) 2022-06-14
  • 2 回答
  • 0 關(guān)注
  • 122 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)