0
私は、scikitをトレーニングするためのLinuxパス/ディレクトリを準備する方法について助けが必要です。現時点で これは私がSQLクエリを変更し、結果へのパスを追加したい、これまでscikit-learnのパスを変換する方法
今db = get_db()
df = pd.read_sql_query(
'SELECT Request,Used,Count FROM history where User = "john"', db)
print(df.head)
X = df[['Request','Count']]
y = df['Used']
X_train, X_test, y_train, y_test = train_test_split(X, y)
model = LinearRegression().fit(X_train, y_train)
print("LinearRegression Training set score: {:.2f}".format(model.score(X_train, y_train)))
print("LinearRegression Test set score: {:.2f}".format(model.score(X_test, y_test)))
#Output of print(df.head)
Request Used Count
0 5400 3088 20
1 6400 3500 20
に動作します。
df = pd.read_sql_query(
'SELECT Request,Used,Count,Path FROM history where User = "john"', db)
df['Path'] = df['Path'].str.split("/")
print(df.head)
X = df[['Request','Count','Path']]
y = df['Used']
X_train, X_test, y_train, y_test = train_test_split(X, y)
...
#Output of print(df.head)
#Output of print(df.head)
Request Used Count Path
0 5400 3088 20 [, home, john, testdir]
1 6400 3500 20 [, home, john, blub]
df ['PATH']をscikitに使用するにはどのように変換できますか? OneHotEnocderを使った表現のような行列でしょうか? ヘルプやヒントがあれば、私には大いに役立ちます。
ありがとうございました
'Path'カラムの最終結果をどのように見せたいのでしょうか?どのように多くのユニークなクラス(ホーム、ジョン、テストディール、クラブなど)がありますか?いくつかまたは多く? 'MultiLabelBinarizer'は私の腸の反応のようです。 – Jarad
パスはユーザー作成されているため、その一部が存在する可能性があります。ユーザーが自分のディレクトリを作成できるメインディレクトリはわずかです。/home、/ tmp、/ tmpdir。私は、いくつかのユーザーが異なるtopleveldirの下で同様の命名スキームを使用する傾向にあることに気づいた。私はそれをより良い予測のために使用したいと考えていました。 を/ tmp /ジョン/ ABC/X1 を/ tmp /ジョン/ ABC/X2 を/ tmp /ジョン/ ABC/X3 /TMPDIR /ジョン/ ABC/X1 /TMPDIR /ジョン/ ABC/X2 そしてもちろんのパスの深さは大きく変わる可能性があります。したがって、パス列エントリの長さは異なる可能性があります [、home、john、testdir] [、home、john、testdir、x1] – MSO