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)
|
||||
test.to_csv('test.csv', index_col = False)
|
||||
valid.to_csv('valid.csv', index_col = False)
|
||||
|
||||
|
@ -1,23 +1,17 @@
|
||||
import csv
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import tensorflow as tf
|
||||
|
||||
def onezero(label):
|
||||
return 0 if label == 'unstable' else 1
|
||||
|
||||
|
||||
X_test = pd.read_csv('test.csv')
|
||||
|
||||
Y_test = X_test.pop('stabf')
|
||||
Y_test = pd.get_dummies(Y_test)
|
||||
|
||||
Y_test_one_zero = [onezero(x) for x in Y_test]
|
||||
Y_test_onehot = np.eye(2)[Y_test_one_zero]
|
||||
model = tf.keras.models.load_model('grid-stability-dense.h5')
|
||||
results = model.evaluate(X_test, Y_test, batch_size=64)
|
||||
|
||||
model = tf.keras.models.load_model('grid_stability.h5')
|
||||
|
||||
results = model.evaluate(X_test, Y_test_onehot, batch_size=64)
|
||||
|
||||
f = open('eval.csv', 'a+')
|
||||
|
||||
f.write(results[0], ',')
|
||||
f.write(results[1], ',')
|
||||
with open('eval.csv', 'a', newline='') as fp:
|
||||
wr = csv.writer(fp, dialect='excel')
|
||||
wr.writerow(results)
|
||||
|
||||
|
@ -1,36 +1,35 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import tensorflow as tf
|
||||
from tensorflow.keras import layers
|
||||
|
||||
def onezero(label):
|
||||
return 0 if label == 'unstable' else 1
|
||||
|
||||
|
||||
X_train = pd.read_csv('train.csv')
|
||||
X_test = pd.read_csv('test.csv')
|
||||
X_valid = pd.read_csv('valid.csv')
|
||||
|
||||
Y_train = X_train.pop('stabf')
|
||||
Y_train = pd.get_dummies(Y_train)
|
||||
|
||||
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_train_onehot = np.eye(2)[Y_train_one_zero]
|
||||
|
||||
Y_test_one_zero = [onezero(x) for x in Y_test]
|
||||
Y_test_onehot = np.eye(2)[Y_test_one_zero]
|
||||
Y_valid = X_valid.pop('stabf')
|
||||
Y_valid = pd.get_dummies(Y_valid)
|
||||
|
||||
model = tf.keras.Sequential([
|
||||
layers.Input(shape=(12,)),
|
||||
layers.Dense(32),
|
||||
layers.Dense(16),
|
||||
layers.Dense(2, activation='softmax')])
|
||||
layers.Dense(2, activation='softmax')
|
||||
])
|
||||
|
||||
model.compile(
|
||||
loss=tf.losses.BinaryCrossentropy(),
|
||||
optimizer=tf.optimizers.Adam(),
|
||||
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