Skip to content

Commit

Permalink
adding old .py code
Browse files Browse the repository at this point in the history
  • Loading branch information
biswajeetyadavv committed Nov 27, 2024
1 parent 531ed6d commit 01fa237
Show file tree
Hide file tree
Showing 60 changed files with 131 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions Desktop Application/Advanced/Java/Red Black Tree GUI/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1732552145514</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
Binary file modified Desktop Application/Advanced/Java/Red Black Tree GUI/bin/Main.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.example.main.HelloApplication

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions Desktop Application/Intermediate/Java/CMD/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1732552145093</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
Binary file modified Desktop Application/Intermediate/Java/CMD/bin/main/Main.class
Binary file not shown.
Binary file modified Desktop Application/Intermediate/Java/CMD/bin/main/Parser.class
Binary file not shown.
Binary file modified Desktop Application/Intermediate/Java/CMD/bin/main/Terminal.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1732552145095</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@

import pandas as pd
import numpy as np
import difflib
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity

"""feature extracion - #converting text to numbers
cosine similarity - #checking for similarities
"""

movies_dataset=pd.read_csv('F:\OpenSource\Project-Guidance\Machine Learning and Data Science\Basic\Movie Recommendation System\movies.csv')
movies_dataset.head()

movies_dataset.shape

#feature selection
selected_features=['genres', 'keywords', 'tagline', 'cast', 'director']
print(selected_features)

#replacing null values with null string
#replacing null values with string will help in easy understandi
for feature in selected_features:
movies_dataset[feature]=movies_dataset[feature].fillna('')

#combining the 5 features
combined_parameters=movies_dataset['genres']+' '+movies_dataset['keywords']+' '+movies_dataset['tagline']+' '+movies_dataset['cast']+' '+movies_dataset['director']
print(combined_parameters)

#converting text to feature vectors
#models can understand only vectors(numbers)
# so it is necessary to featurize the text data to numerical data
#Tfid gives a numerical statistic to indicate how important a word is to
# a document with respect to a collection of documents
#It is a weighting factor
#It also tells how often a word occurs/ or words that appear important and are common
vectorizer=TfidfVectorizer()
feature_vectors=vectorizer.fit_transform(combined_parameters)
print(feature_vectors)

#using cosine similarity function(compares with other values and recommends)
# Text Similarity has to determine how the two text documents close to each other in terms of their context or meaning.
# Cosine similarity is one of the metric to measure the text-similarity between two documents irrespective of their size in Natural language Processing.
# A word is represented into a vector form. The text documents are represented in n-dimensional vector space.

# Mathematically, Cosine similarity metric measures the cosine of the angle between two n-dimensional vectors projected in a multi-dimensional space.
# The Cosine similarity of two documents will range from 0 to 1. If the Cosine similarity score is 1, it means two vectors have the same orientation.
# The value closer to 0 indicates that the two documents have less similarity.
similarity=cosine_similarity(feature_vectors)
print(similarity)

"""Recommendation System"""

#getting input from the user
movie_name=input("Enter your favorite movie")

list_of_alltitles=movies_dataset['title'].tolist()
print(list_of_alltitles)

#finding the close match - only 1
# get_close_matches(word, possibilities, n, cutoff) accepts four parameters:
# word - the word to find close matches for in our list
# possibilities - the list in which to search for close matches of word
# n (optional) - the maximum number of close matches to return. Must be > 0. Default is 3.
# cutoff (optional) - a float in the range [0, 1] that a possibility must score in order
# to be considered similar to word.
# 0 is very lenient, 1 is very strict. Default is 0.6.
find_close_match=difflib.get_close_matches(movie_name,list_of_alltitles,1)
close_match=find_close_match[0]
print(close_match)

#find the index of the movie
index_of_the_movie=movies_dataset[movies_dataset.title==close_match]['index'].values[0]
print(index_of_the_movie)

similar_movies=list(enumerate(similarity[index_of_the_movie]))
print(similar_movies)

#sort based on similarity confidence
sorted_similar_movies=sorted(similar_movies,key=lambda x:x[1],reverse=True)
print(sorted_similar_movies)

print("Movies suggested:")
i=1
for movie in sorted_similar_movies:
ind=movie[0]
title_from_index=movies_dataset[movies_dataset.index==ind]['title'].values[0]
if(i<=30):
print(i,'.',title_from_index)
i+=1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
#Mon Nov 25 21:59:05 IST 2024
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
zipStoreBase=GRADLE_USER_HOME

0 comments on commit 01fa237

Please sign in to comment.