Pylint fixes for gamestonk_terminal/prediction_techniques/regression.py and sma.py

This commit is contained in:
Artem Veremey
2021-03-02 20:12:48 -08:00
parent 3df20efc03
commit c3b9d247e0
3 changed files with 31 additions and 33 deletions

View File

@@ -1,13 +1,4 @@
from gamestonk_terminal import config_terminal as cfg
import argparse
import datetime
from datetime import datetime
from gamestonk_terminal.helper_funcs import *
import pandas as pd
import matplotlib.pyplot as plt
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
from gamestonk_terminal.prediction_techniques import sma
from gamestonk_terminal.prediction_techniques import knn

View File

@@ -1,29 +1,32 @@
import argparse
import numpy as np
from gamestonk_terminal.helper_funcs import *
import pandas as pd
import matplotlib.pyplot as plt
import pandas as pd
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
from TimeSeriesCrossValidation import splitTrain
from sklearn import linear_model
from sklearn import pipeline
from sklearn import preprocessing
from gamestonk_terminal.helper_funcs import check_positive, get_next_stock_market_days
register_matplotlib_converters()
USER_INPUT = 0
LINEAR = 1
QUADRATIC = 2
CUBIC = 3
# -------------------------------------------------- REGRESSION --------------------------------------------------
# pylint: disable=unused-argument
def regression(l_args, s_ticker, s_interval, df_stock, polynomial):
parser = argparse.ArgumentParser(
prog="regression",
description="""Regression attempts to model the relationship between
two variables by fitting a linear/quadratic/cubic/other equation to
observed data. One variable is considered to be an explanatory variable,
and the other is considered to be a dependent variable. """,
description="""
Regression attempts to model the relationship between
two variables by fitting a linear/quadratic/cubic/other equation to
observed data. One variable is considered to be an explanatory variable,
and the other is considered to be a dependent variable.
""",
)
parser.add_argument(
@@ -126,7 +129,7 @@ def regression(l_args, s_ticker, s_interval, df_stock, polynomial):
plt.axvspan(
df_stock.index[-1], df_pred.index[-1], facecolor="tab:orange", alpha=0.2
)
xmin, xmax, ymin, ymax = plt.axis()
_, _, ymin, ymax = plt.axis()
plt.vlines(
df_stock.index[-1], ymin, ymax, linewidth=1, linestyle="--", color="k"
)
@@ -138,6 +141,6 @@ def regression(l_args, s_ticker, s_interval, df_stock, polynomial):
print(df_pred.to_string())
print("")
except:
except Exception as e:
print(e)
print("")

View File

@@ -1,23 +1,27 @@
import argparse
import numpy as np
from gamestonk_terminal.helper_funcs import *
import pandas as pd
import matplotlib.pyplot as plt
import pandas as pd
from pandas.plotting import register_matplotlib_converters
from gamestonk_terminal.helper_funcs import check_positive, get_next_stock_market_days
register_matplotlib_converters()
# ----------------------------------------------------- SMA -----------------------------------------------------
# pylint: disable=unused-argument
def simple_moving_average(l_args, s_ticker, s_interval, df_stock):
parser = argparse.ArgumentParser(
prog="sma",
description=""" Moving Averages are used to smooth the data in an array to
help eliminate noise and identify trends. The Simple Moving Average is literally
the simplest form of a moving average. Each output value is the average of the
previous n values. In a Simple Moving Average, each value in the time period carries
equal weight, and values outside of the time period are not included in the average.
This makes it less responsive to recent changes in the data, which can be useful for
filtering out those changes. """,
description="""
Moving Averages are used to smooth the data in an array to
help eliminate noise and identify trends. The Simple Moving Average is literally
the simplest form of a moving average. Each output value is the average of the
previous n values. In a Simple Moving Average, each value in the time period carries
equal weight, and values outside of the time period are not included in the average.
This makes it less responsive to recent changes in the data, which can be useful for
filtering out those changes.
""",
)
parser.add_argument(
@@ -89,7 +93,7 @@ def simple_moving_average(l_args, s_ticker, s_interval, df_stock):
plt.axvspan(
df_stock.index[-1], df_pred.index[-1], facecolor="tab:orange", alpha=0.2
)
xmin, xmax, ymin, ymax = plt.axis()
_, _, ymin, ymax = plt.axis()
plt.vlines(
df_stock.index[-1], ymin, ymax, linewidth=1, linestyle="--", color="k"
)
@@ -101,6 +105,6 @@ def simple_moving_average(l_args, s_ticker, s_interval, df_stock):
print(df_pred.to_string())
print("")
except:
except Exception as e:
print(e)
print("")