add scripts for 6
This commit is contained in:
parent
ef407c652a
commit
f29c55c0e1
37
lab5/create/Jenkinsfile
vendored
Normal file
37
lab5/create/Jenkinsfile
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
pipeline {
|
||||||
|
agent none
|
||||||
|
stages {
|
||||||
|
stage('copy files') {
|
||||||
|
agent any
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
cp ./lab5/script.sh .
|
||||||
|
cp ./lab5/create_dataset.py .
|
||||||
|
cp ./lab5/Dockerfile .
|
||||||
|
cp ./lab5/requirements.txt .
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('docker') {
|
||||||
|
agent {
|
||||||
|
dockerfile true
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('script') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
chmod +x script.sh
|
||||||
|
./script.sh'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('archive artifact') {
|
||||||
|
steps {
|
||||||
|
archiveArtifacts 'train.csv'
|
||||||
|
archiveArtifacts 'test.csv'
|
||||||
|
archiveArtifacts 'valid.csv'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -33,3 +33,4 @@ valid = pd.concat([X_valid, Y_valid], axis=1)
|
|||||||
train.to_csv('train.cs', index_col = False)
|
train.to_csv('train.cs', index_col = False)
|
||||||
test.to_csv('test.csv', index_col = False)
|
test.to_csv('test.csv', index_col = False)
|
||||||
valid.to_csv('valid.csv', index_col = False)
|
valid.to_csv('valid.csv', index_col = False)
|
||||||
|
|
||||||
|
@ -1,23 +1,17 @@
|
|||||||
|
import csv
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import numpy as np
|
|
||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
|
|
||||||
def onezero(label):
|
|
||||||
return 0 if label == 'unstable' else 1
|
|
||||||
|
|
||||||
|
|
||||||
X_test = pd.read_csv('test.csv')
|
X_test = pd.read_csv('test.csv')
|
||||||
|
|
||||||
Y_test = X_test.pop('stabf')
|
Y_test = X_test.pop('stabf')
|
||||||
|
Y_test = pd.get_dummies(Y_test)
|
||||||
|
|
||||||
Y_test_one_zero = [onezero(x) for x in Y_test]
|
model = tf.keras.models.load_model('grid-stability-dense.h5')
|
||||||
Y_test_onehot = np.eye(2)[Y_test_one_zero]
|
results = model.evaluate(X_test, Y_test, batch_size=64)
|
||||||
|
|
||||||
model = tf.keras.models.load_model('grid_stability.h5')
|
with open('eval.csv', 'a', newline='') as fp:
|
||||||
|
wr = csv.writer(fp, dialect='excel')
|
||||||
results = model.evaluate(X_test, Y_test_onehot, batch_size=64)
|
wr.writerow(results)
|
||||||
|
|
||||||
f = open('eval.csv', 'a+')
|
|
||||||
|
|
||||||
f.write(results[0], ',')
|
|
||||||
f.write(results[1], ',')
|
|
||||||
|
|
||||||
|
@ -1,36 +1,35 @@
|
|||||||
import numpy as np
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
from tensorflow.keras import layers
|
from tensorflow.keras import layers
|
||||||
|
|
||||||
def onezero(label):
|
|
||||||
return 0 if label == 'unstable' else 1
|
|
||||||
|
|
||||||
|
|
||||||
X_train = pd.read_csv('train.csv')
|
X_train = pd.read_csv('train.csv')
|
||||||
X_test = pd.read_csv('test.csv')
|
X_test = pd.read_csv('test.csv')
|
||||||
|
X_valid = pd.read_csv('valid.csv')
|
||||||
|
|
||||||
Y_train = X_train.pop('stabf')
|
Y_train = X_train.pop('stabf')
|
||||||
|
Y_train = pd.get_dummies(Y_train)
|
||||||
|
|
||||||
Y_test = X_test.pop('stabf')
|
Y_test = X_test.pop('stabf')
|
||||||
|
Y_test = pd.get_dummies(Y_test)
|
||||||
|
|
||||||
Y_train_one_zero = [onezero(x) for x in Y_train]
|
Y_valid = X_valid.pop('stabf')
|
||||||
Y_train_onehot = np.eye(2)[Y_train_one_zero]
|
Y_valid = pd.get_dummies(Y_valid)
|
||||||
|
|
||||||
Y_test_one_zero = [onezero(x) for x in Y_test]
|
|
||||||
Y_test_onehot = np.eye(2)[Y_test_one_zero]
|
|
||||||
|
|
||||||
model = tf.keras.Sequential([
|
model = tf.keras.Sequential([
|
||||||
layers.Input(shape=(12,)),
|
layers.Input(shape=(12,)),
|
||||||
layers.Dense(32),
|
layers.Dense(32),
|
||||||
layers.Dense(16),
|
layers.Dense(16),
|
||||||
layers.Dense(2, activation='softmax')])
|
layers.Dense(2, activation='softmax')
|
||||||
|
])
|
||||||
|
|
||||||
model.compile(
|
model.compile(
|
||||||
loss=tf.losses.BinaryCrossentropy(),
|
loss=tf.losses.BinaryCrossentropy(),
|
||||||
optimizer=tf.optimizers.Adam(),
|
optimizer=tf.optimizers.Adam(),
|
||||||
metrics=[tf.keras.metrics.BinaryAccuracy()])
|
metrics=[tf.keras.metrics.BinaryAccuracy()])
|
||||||
|
|
||||||
history = model.fit(tf.convert_to_tensor(X_train, np.float32),
|
|
||||||
Y_train_onehot, epochs=5)
|
|
||||||
|
|
||||||
model.save('grid_stability.h5')
|
history = model.fit(tf.convert_to_tensor(X_train, np.float32),
|
||||||
|
Y_train, epochs=2, validation_data=(X_valid, Y_valid))
|
||||||
|
|
||||||
|
model.save('grid-stability-dense.h5')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user