Lalit's AI / ML Notebook

  • Home
NumPy
  • Introduction to NumPy
Feature Engineering
  • Feature Engineering
Recommendation Systems
  • Recommendation
Natural Language Processing
  • Natural Language Processing
  • Advanced NLP
Deep Learning
  • Neural Networks

Recommendation

Previous Next

Recommendation¶

Purpose: to find and recommend items that a user is most likely to be interested in.

Examples of Recommendation Engines:¶

  1. Product: Amazon, Etsy
  2. Movie: Netflix
  3. Music: Apple Music, Spotify etc
  4. Social connections: Facebook, Linkedin, Instagram

Simple Appoaches to Recommender Systems:¶

1. POPULARITY-BASED RECOMMENDERS¶

Based on simple copunt statistics (numer of ratings given to an item)

user place rating
user A place 1 10
user B place 1 8
user C place 2 8
user D place 2 7
user E place 1 8
user F place 1 7
user G place 1 10
↓
place rating count
place 1 5
place 2 2

Fun facts on Popularity based recommenders:

  • rely on purchase history data
  • are often used by online news sites like Bloomberg
  • cannot produce personalized result
In [1]:
Copied!
import pandas as pd
import numpy as np
import pandas as pd import numpy as np
In [2]:
Copied!
ratings = pd.read_csv('rating_final.csv')
ratings.head()
ratings = pd.read_csv('rating_final.csv') ratings.head()
Out[2]:
userID placeID rating food_rating service_rating
0 U1077 135085 2 2 2
1 U1077 135038 2 2 1
2 U1077 132825 2 2 2
3 U1077 135060 1 2 2
4 U1068 135104 1 1 2
In [3]:
Copied!
cuisines = pd.read_csv('chefmozcuisine.csv')
cuisines.head()
cuisines = pd.read_csv('chefmozcuisine.csv') cuisines.head()
Out[3]:
placeID Rcuisine
0 135110 Spanish
1 135109 Italian
2 135107 Latin_American
3 135106 Mexican
4 135105 Fast_Food
In [11]:
Copied!
# how many people have given ratings to a particuar 'place'
ratings_counts = pd.DataFrame(ratings.groupby('placeID')['rating'].count())
ratings_counts.sort_values('rating', ascending=False).head()
# how many people have given ratings to a particuar 'place' ratings_counts = pd.DataFrame(ratings.groupby('placeID')['rating'].count()) ratings_counts.sort_values('rating', ascending=False).head()
Out[11]:
rating
placeID
135085 36
132825 32
135032 28
135052 25
132834 25
In [13]:
Copied!
cuisine_popularity = pd.merge(ratings_count, cuisines, on='placeID')
cuisine_popularity.sort_values('rating', ascending=False).head()
cuisine_popularity = pd.merge(ratings_count, cuisines, on='placeID') cuisine_popularity.sort_values('rating', ascending=False).head()
Out[13]:
placeID rating Rcuisine
105 135085 36 Fast_Food
28 132825 32 Mexican
71 135032 28 Cafeteria
72 135032 28 Contemporary
86 135052 25 Bar_Pub_Brewery
In [15]:
Copied!
cuisine_popularity['Rcuisine'].describe()
cuisine_popularity['Rcuisine'].describe()
Out[15]:
count         112
unique         23
top       Mexican
freq           28
Name: Rcuisine, dtype: object
In [16]:
Copied!
cuisines['Rcuisine'].describe()
cuisines['Rcuisine'].describe()
Out[16]:
count         916
unique         59
top       Mexican
freq          239
Name: Rcuisine, dtype: object

2. CORRELATION BASED RECOMMENDER SYSTEMS¶

Pearson's correlation coefficient (r) - "Pearson's r"

r description
r = 1 Strong positive linear relationship
r = 0 Not linearly correlated
r = -1 Strong negative linear relationship

Item based similarity:¶

Recommend an item based on how well it correlates with other items with respect to user ratings
In [17]:
Copied!
ratings = pd.read_csv('rating_final.csv')
cuisines = pd.read_csv('chefmozcuisine.csv')
geodata = pd.read_csv('geoplaces2.csv')
ratings = pd.read_csv('rating_final.csv') cuisines = pd.read_csv('chefmozcuisine.csv') geodata = pd.read_csv('geoplaces2.csv')
In [18]:
Copied!
geodata.head()
geodata.head()
Out[18]:
placeID latitude longitude the_geom_meter name address city state country fax ... alcohol smoking_area dress_code accessibility price url Rambience franchise area other_services
0 134999 18.915421 -99.184871 0101000020957F000088568DE356715AC138C0A525FC46... Kiku Cuernavaca Revolucion Cuernavaca Morelos Mexico ? ... No_Alcohol_Served none informal no_accessibility medium kikucuernavaca.com.mx familiar f closed none
1 132825 22.147392 -100.983092 0101000020957F00001AD016568C4858C1243261274BA5... puesto de tacos esquina santos degollado y leon guzman s.l.p. s.l.p. mexico ? ... No_Alcohol_Served none informal completely low ? familiar f open none
2 135106 22.149709 -100.976093 0101000020957F0000649D6F21634858C119AE9BF528A3... El Rinc�n de San Francisco Universidad 169 San Luis Potosi San Luis Potosi Mexico ? ... Wine-Beer only at bar informal partially medium ? familiar f open none
3 132667 23.752697 -99.163359 0101000020957F00005D67BCDDED8157C1222A2DC8D84D... little pizza Emilio Portes Gil calle emilio portes gil victoria tamaulipas ? ? ... No_Alcohol_Served none informal completely low ? familiar t closed none
4 132613 23.752903 -99.165076 0101000020957F00008EBA2D06DC8157C194E03B7B504E... carnitas_mata lic. Emilio portes gil victoria Tamaulipas Mexico ? ... No_Alcohol_Served permitted informal completely medium ? familiar t closed none

5 rows × 21 columns

In [19]:
Copied!
places = geodata[['placeID', 'name']]
places.head()
places = geodata[['placeID', 'name']] places.head()
Out[19]:
placeID name
0 134999 Kiku Cuernavaca
1 132825 puesto de tacos
2 135106 El Rinc�n de San Francisco
3 132667 little pizza Emilio Portes Gil
4 132613 carnitas_mata
In [90]:
Copied!
# Average Rating based ranking w.r.t. places
place_avg_ratings = pd.DataFrame(ratings.groupby('placeID')['rating'].mean())
place_avg_ratings.head()
# Average Rating based ranking w.r.t. places place_avg_ratings = pd.DataFrame(ratings.groupby('placeID')['rating'].mean()) place_avg_ratings.head()
Out[90]:
rating
placeID
132560 0.50
132561 0.75
132564 1.25
132572 1.00
132583 1.00
In [91]:
Copied!
place_avg_ratings['rating_count'] = pd.DataFrame(ratings.groupby('placeID')['rating'].count())
place_avg_ratings.head()
place_avg_ratings['rating_count'] = pd.DataFrame(ratings.groupby('placeID')['rating'].count()) place_avg_ratings.head()
Out[91]:
rating rating_count
placeID
132560 0.50 4
132561 0.75 4
132564 1.25 4
132572 1.00 15
132583 1.00 4
In [92]:
Copied!
place_avg_ratings.describe()
place_avg_ratings.describe()
Out[92]:
rating rating_count
count 130.000000 130.000000
mean 1.179622 8.930769
std 0.349354 6.124279
min 0.250000 3.000000
25% 1.000000 5.000000
50% 1.181818 7.000000
75% 1.400000 11.000000
max 2.000000 36.000000
In [93]:
Copied!
place_avg_ratings.sort_values('rating_count', ascending=False).head()
place_avg_ratings.sort_values('rating_count', ascending=False).head()
Out[93]:
rating rating_count
placeID
135085 1.333333 36
132825 1.281250 32
135032 1.178571 28
135052 1.280000 25
132834 1.000000 25
In [94]:
Copied!
ratings_cross_table = pd.pivot_table(data=ratings, values='rating', index='userID', columns='placeID')
ratings_cross_table.head()
ratings_cross_table = pd.pivot_table(data=ratings, values='rating', index='userID', columns='placeID') ratings_cross_table.head()
Out[94]:
placeID 132560 132561 132564 132572 132583 132584 132594 132608 132609 132613 ... 135080 135081 135082 135085 135086 135088 135104 135106 135108 135109
userID
U1001 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN 0.0 NaN NaN NaN NaN NaN NaN
U1002 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN 1.0 NaN NaN NaN 1.0 NaN NaN
U1003 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... 2.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
U1004 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN 2.0 NaN NaN
U1005 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

5 rows × 130 columns

In [178]:
Copied!
most_popular_place = place_avg_ratings.iloc[place_avg_ratings['rating_count'].argmax()].name
print("most popular place: {}".format(most_popular_place))

most_popular_cuisine = cuisines.loc[cuisines['placeID'] == most_popular_place]['Rcuisine'].name
print("most popular cuisine: {}".format(most_popular_cuisine))

most_popular_place_ratings = ratings_cross_table[most_popular_place]
most_popular_place_ratings[most_popular_place_ratings.notnull()]
most_popular_place = place_avg_ratings.iloc[place_avg_ratings['rating_count'].argmax()].name print("most popular place: {}".format(most_popular_place)) most_popular_cuisine = cuisines.loc[cuisines['placeID'] == most_popular_place]['Rcuisine'].name print("most popular cuisine: {}".format(most_popular_cuisine)) most_popular_place_ratings = ratings_cross_table[most_popular_place] most_popular_place_ratings[most_popular_place_ratings.notnull()]
most popular place: 135085
most popular cuisine: Rcuisine
Out[178]:
userID
U1001    0.0
U1002    1.0
U1007    1.0
U1013    1.0
U1016    2.0
U1027    1.0
U1029    1.0
U1032    1.0
U1033    2.0
U1036    2.0
U1045    2.0
U1046    1.0
U1049    0.0
U1056    2.0
U1059    2.0
U1062    0.0
U1077    2.0
U1081    1.0
U1084    2.0
U1086    2.0
U1089    1.0
U1090    2.0
U1092    0.0
U1098    1.0
U1104    2.0
U1106    2.0
U1108    1.0
U1109    2.0
U1113    1.0
U1116    2.0
U1120    0.0
U1122    2.0
U1132    2.0
U1134    2.0
U1135    0.0
U1137    2.0
Name: 135085, dtype: float64
In [183]:
Copied!
# Evaluating similarity based on "correlation":

similar_to_most_popular = ratings_cross_table.corrwith(most_popular_place_ratings)

corr_most_popular = pd.DataFrame(similar_to_most_popular, columns=['PearsonsR'])
corr_most_popular.dropna(inplace=True)
corr_most_popular.head()
# Evaluating similarity based on "correlation": similar_to_most_popular = ratings_cross_table.corrwith(most_popular_place_ratings) corr_most_popular = pd.DataFrame(similar_to_most_popular, columns=['PearsonsR']) corr_most_popular.dropna(inplace=True) corr_most_popular.head()
/opt/anaconda3/lib/python3.8/site-packages/numpy/lib/function_base.py:2634: RuntimeWarning: Degrees of freedom <= 0 for slice
  c = cov(x, y, rowvar, dtype=dtype)
/opt/anaconda3/lib/python3.8/site-packages/numpy/lib/function_base.py:2493: RuntimeWarning: divide by zero encountered in true_divide
  c *= np.true_divide(1, fact)
Out[183]:
PearsonsR
placeID
132572 -0.428571
132723 0.301511
132754 0.930261
132825 0.700745
132834 0.814823
In [186]:
Copied!
corr_with_most_pop_ratcnt = corr_most_popular.join(place_avg_ratings['rating_count'])
corr_with_most_pop_ratcnt.head()
corr_with_most_pop_ratcnt = corr_most_popular.join(place_avg_ratings['rating_count']) corr_with_most_pop_ratcnt.head()
Out[186]:
PearsonsR rating_count
placeID
132572 -0.428571 15
132723 0.301511 12
132754 0.930261 13
132825 0.700745 32
132834 0.814823 25
In [189]:
Copied!
top_10_places_like_most_pop = corr_with_most_pop_ratcnt[corr_with_most_pop_ratcnt['rating_count'] >= 10
                                                       ].sort_values('PearsonsR', ascending=False
                                                                    )[:10]
top_10_places_like_most_pop
top_10_places_like_most_pop = corr_with_most_pop_ratcnt[corr_with_most_pop_ratcnt['rating_count'] >= 10 ].sort_values('PearsonsR', ascending=False )[:10] top_10_places_like_most_pop
Out[189]:
PearsonsR rating_count
placeID
135076 1.000000 13
135085 1.000000 36
135066 1.000000 12
132754 0.930261 13
135045 0.912871 13
135062 0.898933 21
135028 0.892218 15
135042 0.881409 20
135046 0.867722 11
132872 0.840168 12
In [195]:
Copied!
pd.merge(pd.merge(top_10_places_like_most_pop, cuisines, on='placeID'), places, on='placeID')
pd.merge(pd.merge(top_10_places_like_most_pop, cuisines, on='placeID'), places, on='placeID')
Out[195]:
placeID PearsonsR rating_count Rcuisine name
0 135085 1.000000 36 Fast_Food Tortas Locas Hipocampo
1 132754 0.930261 13 Mexican Cabana Huasteca
2 135028 0.892218 15 Mexican La Virreina
3 135042 0.881409 20 Chinese Restaurant Oriental Express
4 135046 0.867722 11 Fast_Food Restaurante El Reyecito
5 132872 0.840168 12 American Pizzeria Julios

Collaborative Filtering Recommenders¶

Recommend items based on crowdsourced information about users' preferences for items.

2 approaches:

  1. User based

    Based on known user attributes, we know that User B is similar to User D. User D really likes his life insurance policy, so let's recomment it to Uesr B also.

  2. Item based

    User B and User D both gave high ratings to the cell phone and the cell phone case. Since User A also likes the cell phone, let's recommend to her the cell phone case also.

User attributes can be described as a list of values (possibly boolean).

Classification-Based Collaborative Filtering¶

Provides personalizarion by accepting:

  • user and item attribute data
  • purchase history data
  • other contextual data
  • Gives a Yes/No classification! (Will he/she accept/purchase?)

Example classification methods:

  1. Naive Bayes classification
  2. Logistic regression

1. Logistic Regression as classifier¶

In [197]:
Copied!
import numpy as np
import pandas as pd

from pandas import Series, DataFrame
from sklearn.linear_model import LogisticRegression
import numpy as np import pandas as pd from pandas import Series, DataFrame from sklearn.linear_model import LogisticRegression
In [198]:
Copied!
bank_full = pd.read_csv('bank_full_w_dummy_vars.csv')
bank_full.head()
bank_full = pd.read_csv('bank_full_w_dummy_vars.csv') bank_full.head()
Out[198]:
age job marital education default balance housing loan contact day ... job_unknown job_retired job_services job_self_employed job_unemployed job_maid job_student married single divorced
0 58 management married tertiary no 2143 yes no unknown 5 ... 0 0 0 0 0 0 0 1 0 0
1 44 technician single secondary no 29 yes no unknown 5 ... 0 0 0 0 0 0 0 0 1 1
2 33 entrepreneur married secondary no 2 yes yes unknown 5 ... 0 0 0 0 0 0 0 1 0 0
3 47 blue-collar married unknown no 1506 yes no unknown 5 ... 0 0 0 0 0 0 0 1 0 0
4 33 unknown single unknown no 1 no no unknown 5 ... 1 0 0 0 0 0 0 0 1 1

5 rows × 37 columns

In [199]:
Copied!
bank_full.info()
bank_full.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 45211 entries, 0 to 45210
Data columns (total 37 columns):
 #   Column                        Non-Null Count  Dtype 
---  ------                        --------------  ----- 
 0   age                           45211 non-null  int64 
 1   job                           45211 non-null  object
 2   marital                       45211 non-null  object
 3   education                     45211 non-null  object
 4   default                       45211 non-null  object
 5   balance                       45211 non-null  int64 
 6   housing                       45211 non-null  object
 7   loan                          45211 non-null  object
 8   contact                       45211 non-null  object
 9   day                           45211 non-null  int64 
 10  month                         45211 non-null  object
 11  duration                      45211 non-null  int64 
 12  campaign                      45211 non-null  int64 
 13  pdays                         45211 non-null  int64 
 14  previous                      45211 non-null  int64 
 15  poutcome                      45211 non-null  object
 16  y                             45211 non-null  object
 17  y_binary                      45211 non-null  int64 
 18  housing_loan                  45211 non-null  int64 
 19  credit_in_default             45211 non-null  int64 
 20  personal_loans                45211 non-null  int64 
 21  prev_failed_to_subscribe      45211 non-null  int64 
 22  prev_subscribed               45211 non-null  int64 
 23  job_management                45211 non-null  int64 
 24  job_tech                      45211 non-null  int64 
 25  job_entrepreneur              45211 non-null  int64 
 26  job_bluecollar                45211 non-null  int64 
 27  job_unknown                   45211 non-null  int64 
 28  job_retired                   45211 non-null  int64 
 29  job_services                  45211 non-null  int64 
 30  job_self_employed             45211 non-null  int64 
 31  job_unemployed                45211 non-null  int64 
 32  job_maid                      45211 non-null  int64 
 33  job_student                   45211 non-null  int64 
 34  married                       45211 non-null  int64 
 35  single                        45211 non-null  int64 
 36  divorced                      45211 non-null  int64 
dtypes: int64(27), object(10)
memory usage: 12.8+ MB
In [219]:
Copied!
X = bank_full.iloc[:,list(range(18,37))].values

y = bank_full.iloc[:,17].values

print("X shape = {}".format(X.shape))
print("y shape = {}".format(y.shape))
X = bank_full.iloc[:,list(range(18,37))].values y = bank_full.iloc[:,17].values print("X shape = {}".format(X.shape)) print("y shape = {}".format(y.shape))
X shape = (45211, 19)
y shape = (45211,)
In [220]:
Copied!
log_reg = LogisticRegression()
log_reg.fit(X, y)
log_reg = LogisticRegression() log_reg.fit(X, y)
Out[220]:
LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
                   intercept_scaling=1, l1_ratio=None, max_iter=100,
                   multi_class='auto', n_jobs=None, penalty='l2',
                   random_state=None, solver='lbfgs', tol=0.0001, verbose=0,
                   warm_start=False)
In [221]:
Copied!
new_user = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]
y_pred = log_reg.predict([new_user])
y_pred
new_user = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] y_pred = log_reg.predict([new_user]) y_pred
Out[221]:
array([0])

2. Model-based Collaborative filtering¶

Singular Value Decomposition (SVD)¶
  • A linear algebra method that can decompose utilituy matrix into three compressed matrices.
  • Model-based recommender - use these ompressed matrices to make recommendations without having to refer back to the complete data set.
  • Latent variables - ingferred, nonobservable variables that are present within, and affect the behavior of a data set.

$\Large \begin{bmatrix} {}_{A} \end{bmatrix} = \begin{bmatrix} {}_{u} \end{bmatrix} \times \begin{bmatrix} {}_{S} \end{bmatrix} \times \begin{bmatrix} {}_{v} \end{bmatrix}$

$\Large {A} = {u} \times {S} \times {v}$

  • A = Original matrix (utility matrix)
  • u = Left orthogonal matrix - holds important, non-redundant information about users
  • v = Right orthogonal matrix - holds important, non-redundant information on items
  • S = Diagonal matrix - contains all of the information about the decomposition processes performned during the compression

Building a utility matrix

ratings_crosstab = combined_movies_data.pivot_table(
    values='rating', 
    index='user_id',
    columns='movie_title',
    fill_value=0)

# shape = (num_users, num_movies)

This will generate cross table with users as the rows (indices) and each movie as the columns, a typical wide matrix.

Transposing the Matrix

ratings_crosstab.values.T

# shape = (num_movies, num_users)

This will transpose the matrix, rows interchange with columns.

Decomposing the Matrix

SVD = TruncatedSVD(n_components=12, random_state=17)

resultant_matrix = SVD.fit_transform(X)

# shape = (num_movies, n_components=12)

Generating a Correlation Matrix

corr_mat = np.corrcoef(resultant_matrix)

# shape = (num_movies, num_movies)

Isolating top movie from the correlation matrix

movie_names = rating_crosstab.columns
movies_list = list(movie_names)

top_movie = movies_lisst.index('<Top movie title (9999)>')

corr_top_movie = corr_mat[top_movie]
corr_top_movie.shape

# shape = (num_movies,)

Recommending a Highly Correlated Movie

list(movie_names[
    (corr_top_movie < 1.0) & (corr_top_movie > 0.9)
])

# list of highly correlated movie w.r.t. 'Top movie'

Machine Learning based Recommenders¶

Content-based recommender systems¶

Content-based recommenders recomend items based on similarities between features.

Example: A user who loves Miami might also love Austin, based on the similarities between temperature. const of living and Wi-Fi speeds at both places.

K-nearest neighbor algorithm¶

  • Unsupervised classifier
  • Also known as a memory-based system
  • Memorizes instances and then recommends item (a single instance) based on how quantitatively similar it is to a new, incoming instance.

Example:

I want to buy a car that gets 25 MPG, and has a 4.7 L engine with 425 HP.

Solution is to find "1" car closest to the specification provided in cartesian distance.

In [223]:
Copied!
import numpy as np
import pandas as pd

import sklearn
from sklearn.neighbors import NearestNeighbors
import numpy as np import pandas as pd import sklearn from sklearn.neighbors import NearestNeighbors
In [225]:
Copied!
cars = pd.read_csv('mtcars.csv')
cars.columns = ['car_names', 'mpg', 'cyl', 'disp', 'hp', 'drat', 'wt', 'qsec', 'vs', 'am', 'gear', 'carb']
cars.head()
cars = pd.read_csv('mtcars.csv') cars.columns = ['car_names', 'mpg', 'cyl', 'disp', 'hp', 'drat', 'wt', 'qsec', 'vs', 'am', 'gear', 'carb'] cars.head()
Out[225]:
car_names mpg cyl disp hp drat wt qsec vs am gear carb
0 Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4
1 Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4
2 Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1
3 Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1
4 Hornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2
In [226]:
Copied!
specifications_needed = [15, 300, 160, 3.2]
# mpg, disp, hp, wt

X = cars[['mpg', 'disp', 'hp', 'wt']]
X[0:5]
specifications_needed = [15, 300, 160, 3.2] # mpg, disp, hp, wt X = cars[['mpg', 'disp', 'hp', 'wt']] X[0:5]
Out[226]:
mpg disp hp wt
0 21.0 160.0 110 2.620
1 21.0 160.0 110 2.875
2 22.8 108.0 93 2.320
3 21.4 258.0 110 3.215
4 18.7 360.0 175 3.440
In [233]:
Copied!
nearest_neighbors = NearestNeighbors(n_neighbors=1).fit(X)

y, neighbor_coord = nearest_neighbors.kneighbors([specifications_needed])

print("y = {}, neighbor_coord = {}".format(y, neighbor_coord))
nearest_neighbors = NearestNeighbors(n_neighbors=1).fit(X) y, neighbor_coord = nearest_neighbors.kneighbors([specifications_needed]) print("y = {}, neighbor_coord = {}".format(y, neighbor_coord))
y = [[10.77474942]], neighbor_coord = [[22]]
In [242]:
Copied!
cars.iloc[neighbor_coord[0]]
cars.iloc[neighbor_coord[0]]
Out[242]:
car_names mpg cyl disp hp drat wt qsec vs am gear carb
22 AMC Javelin 15.2 8 304.0 150 3.15 3.435 17.3 0 0 3 2
In [243]:
Copied!
cars
cars
Out[243]:
car_names mpg cyl disp hp drat wt qsec vs am gear carb
0 Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4
1 Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4
2 Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1
3 Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1
4 Hornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2
5 Valiant 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1
6 Duster 360 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4
7 Merc 240D 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2
8 Merc 230 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2
9 Merc 280 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4
10 Merc 280C 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4
11 Merc 450SE 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3
12 Merc 450SL 17.3 8 275.8 180 3.07 3.730 17.60 0 0 3 3
13 Merc 450SLC 15.2 8 275.8 180 3.07 3.780 18.00 0 0 3 3
14 Cadillac Fleetwood 10.4 8 472.0 205 2.93 5.250 17.98 0 0 3 4
15 Lincoln Continental 10.4 8 460.0 215 3.00 5.424 17.82 0 0 3 4
16 Chrysler Imperial 14.7 8 440.0 230 3.23 5.345 17.42 0 0 3 4
17 Fiat 128 32.4 4 78.7 66 4.08 2.200 19.47 1 1 4 1
18 Honda Civic 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2
19 Toyota Corolla 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1
20 Toyota Corona 21.5 4 120.1 97 3.70 2.465 20.01 1 0 3 1
21 Dodge Challenger 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2
22 AMC Javelin 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2
23 Camaro Z28 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4
24 Pontiac Firebird 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2
25 Fiat X1-9 27.3 4 79.0 66 4.08 1.935 18.90 1 1 4 1
26 Porsche 914-2 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2
27 Lotus Europa 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2
28 Ford Pantera L 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4
29 Ferrari Dino 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6
30 Maserati Bora 15.0 8 301.0 335 3.54 3.570 14.60 0 1 5 8
31 Volvo 142E 21.4 4 121.0 109 4.11 2.780 18.60 1 1 4 2
In [ ]:
Copied!

Feature Engineering Natural Language Processing
Menu
Home
NumPy
Introduction to NumPy
Feature Engineering
Feature Engineering
Recommendation Systems
Recommendation
Natural Language Processing
Natural Language Processing Advanced NLP
Deep Learning
Neural Networks

On This Page

Examples of Recommendation Engines: Simple Appoaches to Recommender Systems: 1. POPULARITY-BASED RECOMMENDERS 2. CORRELATION BASED RECOMMENDER SYSTEMS Collaborative Filtering Recommenders Classification-Based Collaborative Filtering Machine Learning based Recommenders Content-based recommender systems
Built by Lalit Prakash Vatsal — shadcn theme provided by @asiffer