reverse a String
sLower == sLower[::-1]
check if character (char) is part of the String (vowels)
if char in vowels:
counter += 1
Find largest value in array
ans = max(arr)
Reverse array in Python
my_array = [1, 2, 3, 4, 5]
reversed_array = my_array[::-1]
making an integer iterable
for i in range(1, n+1)
create Linear regression model and then fit it
model = smf.ols(
formula=('satisfaction ~ avgHoursWatched'),
data=sampled_users
)
results = model.fit()
-> OLS or linear
create logistic regreesion model and fit
logregmodel = smf.logit(‘variable
logit_model = smf.logit(
'premSub ~ income + avgHoursWatched + satisfaction',
data=sampled_users_logit
).fit()
-> if logistic regression (binary values) logit(‘‘, data = …)
-> Creates a logistic regression model that test the influence of income, average hours watched, and satisfaction on premium subscription
print results from regression models (both linear and logistic)
print(
model_name.summary()
creating the VIF (Variance Inflation Factor):
X = results.model.exog
-> independent variables from the regression model
vif = pd.DataFrame()
vif["VIF Factor"] = [variance_inflation_factor(X, i) for i in range(X.shape[1])]
vif["features"] = results.model.exog_names
Zuletzt geändertvor 2 Tagen