小编Avi*_*vic的帖子

在不同的文件夹中运行另一个 Python 脚本

如何在不同的文件夹中运行另一个 python 脚本?

我有主程序: calculation_control.py

在文件夹中calculation_folder,有calculation.py

我如何calculation_folder/calculation.py从内部运行calculation_control.py

到目前为止,我已经尝试了以下代码:

calculation_file = folder_path + "calculation.py"
if not os.path.isfile(parser_file) :

    continue


subprocess.Popen([sys.executable, parser_file])
Run Code Online (Sandbox Code Playgroud)

python

5
推荐指数
1
解决办法
2万
查看次数

Sklearn 或 Pandas,用简单的线性回归估算缺失值

我有数据、时间序列数据,我想估算缺失的数据。我不能使用列的平均值,因为我认为它不适合时间序列数据。所以我想要简单的线性回归来估算它

Day, Price
 1 , NaN
 2, NaN
 3, 1800
 4, 1900
 5, NaN
 6, NaN
 7, 2000
 8, 2200
Run Code Online (Sandbox Code Playgroud)

这该怎么做 ?

我更喜欢使用 Pandas 来做到这一点,但如果没有其他方法,我可以使用 sklearn 来做到这一点:)

python data-mining pandas scikit-learn

2
推荐指数
1
解决办法
4347
查看次数

sklearn 中字母的 N-gram

我想做 n-grams 方法但是一个字母一个字母

正常的 N-gram:

sentence : He want to watch football match

result:
he, he want, want, want to , to , to watch , watch , watch football , football, football match, match
Run Code Online (Sandbox Code Playgroud)

我想这样做,但要逐字逐句:

word : Angela 

result:
a, an, n , ng , g , ge, e ,el, l , la ,a
Run Code Online (Sandbox Code Playgroud)

这是我使用 的代码Sklearn,但它仍然是逐字而不是逐字:

from sklearn.feature_extraction.text import CountVectorizer

vectorizer = CountVectorizer(ngram_range=(1, 100),token_pattern = r"(?u)\b\w+\b")

corpus = ['Angel','Angelica','John','Johnson']

X = vectorizer.fit_transform(corpus)
analyze = vectorizer.build_analyzer()
print(vectorizer.get_feature_names())
print(vectorizer.transform(['Angela']).toarray())
Run Code Online (Sandbox Code Playgroud)

python nlp scikit-learn

1
推荐指数
1
解决办法
1522
查看次数

标签 统计

python ×3

scikit-learn ×2

data-mining ×1

nlp ×1

pandas ×1