diff --git a/machine-learning-algo/linear-regression.py b/machine-learning-algo/linear-regression.py new file mode 100644 index 0000000..2d83b32 --- /dev/null +++ b/machine-learning-algo/linear-regression.py @@ -0,0 +1,36 @@ +import numpy as np +from sklearn.linear_model import LinearRegression +x = np.array([5, 15, 25, 35, 45, 55]).reshape((-1, 1)) +y = np.array([5, 20, 14, 32, 22, 38]) +print(x) + +print(y) + +model = LinearRegression() + +model.fit(x, y) +model = LinearRegression().fit(x, y) +r_sq = model.score(x, y) +print('coefficient of determination:', r_sq) +print('intercept:', model.intercept_) + +print('slope:', model.coef_) +new_model = LinearRegression().fit(x, y.reshape((-1, 1))) + +print('intercept:', new_model.intercept_) + +print('slope:', new_model.coef_) +y_pred = model.predict(x) + +print('predicted response:', y_pred, sep='\n') +y_pred = model.intercept_ + model.coef_ * x + +print('predicted response:', y_pred, sep='\n') + +x_new = np.arange(5).reshape((-1, 1)) + +print(x_new) + +y_new = model.predict(x_new) + +print(y_new) diff --git a/strings/vowel_count.py b/strings/vowel_count.py index 948f4c4..b34edeb 100644 --- a/strings/vowel_count.py +++ b/strings/vowel_count.py @@ -22,7 +22,7 @@ def vowel_count(str): print("No. of vowels :", count) # Driver code -str = "" #Enter string +str = input("#Enter string =") # Function Call -vowel_count(str) \ No newline at end of file +vowel_count(str)