我认为这是一个简单的问题,但对我而言不是(df中有一个表:
Date X1 X2 Y1
07.02.2019 5 1 1
08.02.2019 6 2 1
09.02.2019 1 3 0
10.02.2019 4 4 1
11.02.2019 1 1 0
12.02.2019 4 2 1
13.02.2019 5 5 1
14.02.2019 6 5 1
15.02.2019 1 1 0
16.02.2019 4 5 1
17.02.2019 1 2 0
18.02.2019 1 1
19.02.2019 2 1
20.02.2019 3 2
21.02.2019 4 14
我需要根据参数X1和X2为Y1建立一个神经网络,然后将其应用于日期大于17.02.2019的行,并将网络预测结果保存在单独的df2中
import pandas as pd
import numpy as np
import re
from sklearn.neural_network import MLPClassifier
df = pd.read_csv("ob.csv", encoding = 'cp1251', sep = ';')
df['Date'] = pd.to_datetime(df['Date'], format='%d.%m.%Y')
startdate = pd.to_datetime('2019-02-17')
X = ['X1', 'X2'] ????
y = ['Y1'] ????
clf = MLPClassifier(solver='lbfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1)
clf.fit(x, y)
clf.predict(???????) ????? df2 = ????
在哪里? -我不知道如何正确设置条件
答案 0 :(得分:0)
#args is parsed from the command line
#file is an exogenous variable
with open(args.inPath + file, "r") as fpIn:
with open(args.outPath + file, "w") as fpOut:
for line in fpIn:
if re.match(some match): canWrite = True
if re.match(some match 2): break
if canWrite: fpOut.write(line)