parent
f47b1cc50f
commit
57cab8b854
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
"""
|
||||||
|
(c) 2018 Smart Top - Free Models
|
||||||
|
Steve L. Nyemba, steve@the-phi.com
|
||||||
|
|
||||||
|
This file contains free models for smart-top, these are basic models that will serve as data visualization
|
||||||
|
The most we will do here is a basic regression (basis for prediction).
|
||||||
|
|
||||||
|
@TODO: Include process counts in the equation so as to add another variable (good for ml)
|
||||||
|
"""
|
||||||
|
from models.basic import model
|
||||||
|
|
||||||
|
class status(model):
|
||||||
|
"""
|
||||||
|
This model will perform a simple count of application status
|
||||||
|
The intent is to quickly inform the user if there's a crash
|
||||||
|
"""
|
||||||
|
def __init(self,**args):
|
||||||
|
model.__init__(self,**args)
|
||||||
|
def compute(self):
|
||||||
|
"""
|
||||||
|
This function performs the actual counts associated with the status of an application
|
||||||
|
"""
|
||||||
|
df = self.data[df.name.str.contains('other',na=False)==False]
|
||||||
|
x_crash = df.status.str.contains('X').sum()
|
||||||
|
x_idle = df.status.str.contains('S').sum()
|
||||||
|
x_run = df.shape[0] - x_crash - x_idle
|
||||||
|
odf = pd.DataFrame({"labels":['crash','idle','running'],"counts":[x_crash,x_idle,x_run]})
|
||||||
|
self.set("type","doughnut")
|
||||||
|
# self.set("labels",["crash","idle","running"])
|
||||||
|
# self.set("data",{"data":[x_crash,x_idle,x_run]})
|
||||||
|
self.set('data',odf)
|
||||||
|
if x_crash > 0 :
|
||||||
|
self.set("analysis"," ".join([x_crash,"applications found out of ",str(df.shape[0]),"monitored" ]))
|
||||||
|
class resource(model):
|
||||||
|
"""
|
||||||
|
This model will group the applications that are monitored and the rest of the system to guage resource consumption (CPU,RAM)
|
||||||
|
The intent of this model is to see how resource intensive the selected applications are relative to the rest of the system
|
||||||
|
"""
|
||||||
|
def __init__(self,**args):
|
||||||
|
model.__init__(self,**args)
|
||||||
|
def compute(self):
|
||||||
|
N = self.data.shape[0] - 1
|
||||||
|
|
||||||
|
df = pd.DataFrame(self.data[self.data.name == 'other'].sum()[['cpu','mem']] ) .T
|
||||||
|
df = df.append(pd.DataFrame( self.data[self.data.name != 'other'].sum()[['cpu','mem']] ).T)
|
||||||
|
df['labels'] = ['other','monitored']
|
||||||
|
self.set("data",df)
|
||||||
|
self.set("type","bar")
|
||||||
|
|
||||||
|
class trend(model):
|
||||||
|
"""
|
||||||
|
This model is designed to display the trends for a given attribute over a period of time
|
||||||
|
Additionally there will be a regression line associated with it
|
||||||
|
"""
|
||||||
|
def __init__(self,**args):
|
||||||
|
model.__init__(self,**args)
|
||||||
|
self.attr_name = args['name']
|
||||||
|
self.attr_values= args['values']
|
||||||
|
def compute(self):
|
||||||
|
df = self.data[self.data[self.attr_name].isin(self.attr_values)]
|
||||||
|
cols = ['cpu','mem']
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
model = keras.Sequential([keras.layers.Dense(2, activation=tf.nn.relu,input_shape=(x.shape[1],)),keras.layers.Dense(2, activation=tf.nn.relu),keras.layers.Dense(1)])
|
||||||
|
|
||||||
|
optimizer = tf.train.RMSPropOptimizer(0.001)
|
||||||
|
|
||||||
|
model.compile(loss='mse', optimizer=optimizer,metrics=['mae'])
|
@ -0,0 +1,10 @@
|
|||||||
|
"""
|
||||||
|
(c) 2018 Smart-Top, Paid Models
|
||||||
|
Steve L. Nyemba <steve@the-phi.com>
|
||||||
|
|
||||||
|
|
||||||
|
The Paid models are largely based around machine learning and will deliver insights into :
|
||||||
|
- Anomaly detection
|
||||||
|
- Clustering
|
||||||
|
- And Crash Prediction (regression)
|
||||||
|
"""
|
Loading…
Reference in new issue