Skip to content
Snippets Groups Projects
Select Git revision
  • main default protected
  • java-operator-sdk
  • rework-state-handling
  • quarkus-36
  • bump-kotlinlogging-to-5.0.2
  • improve-patcher-documentation
  • use-internal-registry protected
  • v0.9 protected
  • kafka-nodeport-config-windows
  • v0.8 protected
  • test-k3d protected
  • simpleuc4 protected
  • reduce-code-duplication
  • test-coverage
  • code-cleanup
  • cleanup-commit-interval protected
  • delete-action-for-other-namespace
  • master protected
  • add-helm-test-debug2
  • add-helm-test-debug
  • v0.9.0 protected
  • v0.8.6 protected
  • v0.8.5 protected
  • v0.8.4 protected
  • v0.8.3 protected
  • v0.8.2 protected
  • v0.8.1 protected
  • v0.8.0 protected
  • v0.7.0 protected
  • v0.5.2 protected
  • v0.6.4 protected
  • v0.6.3 protected
  • v0.6.2 protected
  • v0.6.1 protected
  • v0.6.0 protected
  • v0.5.1 protected
  • v0.5.0 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
40 results

trend_slope_computer.py

Blame
  • user avatar
    Simon Ehrenstein authored
    fbeda69f
    History
    trend_slope_computer.py 831 B
    from sklearn.linear_model import LinearRegression
    import pandas as pd
    import os
    
    def compute(directory, filename, warmup_sec, threshold):
        df = pd.read_csv(os.path.join(directory, filename))
        input = df
        input['sec_start'] = input.loc[0:, 'timestamp'] - input.iloc[0]['timestamp']
        regress = input.loc[input['sec_start'] >= warmup_sec] # Warm-Up
    
        X = regress.iloc[:, 2].values.reshape(-1, 1)  # values converts it into a numpy array
        Y = regress.iloc[:, 3].values.reshape(-1, 1)  # -1 means that calculate the dimension of rows, but have 1 column
        linear_regressor = LinearRegression()  # create object for the class
        linear_regressor.fit(X, Y)  # perform linear regression
        Y_pred = linear_regressor.predict(X)  # make predictions
    
        trend_slope = linear_regressor.coef_[0][0]
    
        return trend_slope